示例#1
0
文件: animate.py 项目: zongzhaoyu/nls
def main():
    model = Problem().model(
        model='1d',
        dx=1.0e-1,
        dt=1.0e-3,
        t0=0.0,
        u0=0.1,
        order=5,
        num_nodes=400,
        num_iters=10000,
        #pumping = GaussianPumping1D(power=20, x0=0.0, y0=0.0, variation=3.14),
        pumping=GaussianRingPumping1D(power=20.0, radius=10.0, variation=3.14),
        original_params={
            'R': 0.0242057488654,
            'gamma': 0.0242057488654,
            'g': 0.00162178517398,
            'tilde_g': 0.0169440242057,
            'gamma_R': 0.242057488654,
        },
        dimless_params={})

    # Animate solution profile as iterations increase
    animation = IterationIncreaseAnimation(model, 200, 50)
    #animation.render('point-iteration-increase.mp4')
    animation.report()

    # Animate solution profile as radius increase
    animation = PumpingRadiusIncreaseAnimation(model, 200, 0.15)
    #animation.render('ring-radius-increase.mp4')
    animation.report()

    # Animate solution profile as power increase
    animation = PumpingPowerIncreaseAnimation(model, 200, 0.005)
    animation.render('point-power-increase.mp4')
    animation.report()
示例#2
0
def solve_problem(desc):
    desc = loads(desc.encode('utf8'))

    model = Problem().model(model='2d',
                            dx=2.0e-1,
                            dt=2.0e-3,
                            t0=0.0,
                            u0=0.1,
                            order=5,
                            num_nodes=200,
                            num_iters=2000,
                            pumping=GaussianPumping2D(power=desc['power'],
                                                      variation=5.0),
                            original_params={
                                'R': 0.0242057488654,
                                'gamma': 0.0242057488654,
                                'g': 0.00162178517398,
                                'tilde_g': 0.0169440242057,
                                'gamma_R': 0.242057488654,
                            },
                            dimless_params={})

    solution = model.solve()
    solution.report()
    solution.store()

    return True
示例#3
0
文件: solve1d.py 项目: zongzhaoyu/nls
def main():
    model = Problem().model(model='1d',
                            dx=1.0e-1,
                            dt=1.0e-3,
                            t0=0.0,
                            u0=0.1,
                            order=5,
                            num_nodes=400,
                            num_iters=10000,
                            pumping=GaussianRingPumping1D(power=20.0,
                                                          radius=10.0,
                                                          variation=3.14),
                            original_params={
                                'R': 0.0242057488654,
                                'gamma': 0.0242057488654,
                                'g': 0.00162178517398,
                                'tilde_g': 0.0169440242057,
                                'gamma_R': 0.242057488654,
                            },
                            dimless_params={})

    # Obtain steady state solution
    solution = model.solve()
    solution.report()
    solution.visualize()
    solution.show()
示例#4
0
def main():
    parser = ArgumentParser(
        prog='NLSe Solution Visualizer',
        description='Visualize saved solutions with nls package.')
    parser.add_argument('solution_path',
                        metavar='solution',
                        type=unicode,
                        help='.mat file that contains solution')
    parser.add_argument('--1d',
                        '-1',
                        action='store_true',
                        help='Force loading solution as one dimensional')
    parser.add_argument('--2d',
                        '-2',
                        action='store_true',
                        help='Force loading solution as two dimensional')
    parser.add_argument('--default',
                        action='store_true',
                        help='Visualize solution in default way')
    parser.add_argument('--contour',
                        action='store_true',
                        help='Show contour plot')
    parser.add_argument('--stream',
                        action='store_true',
                        help='Show stream plot')
    parser.add_argument('--filename',
                        '-f',
                        metavar='path',
                        default=None,
                        type=unicode,
                        help='Filename to save figure')
    parser.add_argument('--show',
                        '-s',
                        action='store_true',
                        help='Show visualized solution.')
    parser.add_argument('--no-show',
                        '-ns',
                        action='store_true',
                        help='Do not show visualized solution.')

    args = parser.parse_args()

    model = Problem().model(filename=args.solution_path)
    solution = Solution(model).restore(args.solution_path)
    solution.visualize(
        filename=args.filename,
        contour=args.contour,
        stream=args.stream,
    )

    if not args.no_show:
        solution.show()
示例#5
0
文件: check.py 项目: zongzhaoyu/nls
def main():
    parser = ArgumentParser(
        prog='NLSe Solution Checker',
        description=
        'Check convergence and consistance of saved solutions with nls package.'
    )
    parser.add_argument('solution_path',
                        metavar='solution',
                        type=unicode,
                        help='.mat file that contains solution')
    parser.add_argument('--1d',
                        '-1',
                        action='store_true',
                        help='Force loading solution as one dimensional')
    parser.add_argument('--2d',
                        '-2',
                        action='store_true',
                        help='Force loading solution as two dimensional')
    parser.add_argument('--verbose', '-V', action='store_true')
    parser.add_argument('--check-convergence',
                        '-c',
                        action='store_true',
                        help='Check whether eigenvalue stabilzed')
    parser.add_argument('--check-integral',
                        '-i',
                        action='store_true',
                        help='Check complex-valued integrand is zero')

    args = parser.parse_args()

    if not args.check_integral and not args.check_convergence:
        args.check_integral = args.check_convergence = True

    model = Problem().model(filename=args.solution_path)
    solution = Solution(model).restore(args.solution_path)

    print(timestamp(), 'Model description:')
    print(model)

    checks = {}

    if args.check_convergence:
        checks['convergence'] = check_convergence(solution)
    if args.check_integral:
        checks['integral'] = check_integral(solution)

    for key in sorted(checks.keys()):
        print(timestamp(), '{0} check: {1}'.format(key.capitalize(),
                                                   checks[key]))
示例#6
0
def create_model(num_nodes=200, num_iters=2000, order=5):
    return Problem().model(
        model = '2d',
        dx = 2.0e-1,
        dt = 2.0e-3,
        t0 = 0.0,
        u0 = 0.1,
        order = order,
        num_nodes = num_nodes,
        num_iters = num_iters,
        pumping = GaussianPumping2D(power=15.0, variation=3.14),
        original_params = {
            'R': 0.0242057488654,
            'gamma': 0.0242057488654,
            'g': 0.00162178517398,
            'tilde_g': 0.0169440242057,
            'gamma_R': 0.242057488654
        })