コード例 #1
0
def _run_solver(args):
    theta, = args
    c = Config()

    c.n12 = 20
    c.final_time = 2
    c.dt = 0.01
    c.approximator = 'henrick-upwind5-lf'
    c.time_integrator = 'dopri5'
    c.io_format = 'ascii'
    c.plot_time_step = 1000
    c.play_animation = False

    c.lambda_tol = 1e-6
    c.q = Q
    c.theta = theta
    c.reaction_rate_version = 'v2'
    c.f = 1
    c.ic_amplitude = 1e-10
    c.ic_type = 'znd'
    c.truncation_coef = 0.01

    outdir = 'theta={:.3f}'.format(theta)
    outdir = os.path.join('_output', outdir)
    if os.path.exists(outdir):
        shutil.rmtree(outdir)
    os.mkdir(outdir)
    solve('linear', c, outdir, log_to_file=True)
コード例 #2
0
def _run_solver(args):
    n12, = args
    c = Config()

    c.n12 = n12
    c.final_time = T_FINAL
    c.dt = 0.005
    c.approximator = 'godunov-minmod'
    c.time_integrator = 'dopri5'
    c.io_format = 'numpy'
    c.plot_time_step = 0
    c.play_animation = False

    c.lambda_tol = 1e-6
    c.q = Q
    c.theta = THETA
    c.reaction_rate_version = 'v2'
    c.f = 1
    c.ic_amplitude = 0
    c.ic_type = 'znd'
    c.truncation_coef = 1e6

    outdir = 'stable-n12={:04d}'.format(n12)
    outdir = os.path.join('_output', outdir)

    if os.path.exists(outdir):
        shutil.rmtree(outdir)
    os.mkdir(outdir)
    solve('nonlinear', c, outdir, log_to_file=True)

    return outdir
コード例 #3
0
def _run_solver(args):
    theta, outdir = args

    c = Config()
    c.n12 = 40
    c.final_time = 300
    c.dt = 0.005
    c.approximator = 'henrick-upwind5-lf'
    c.time_integrator = 'dopri5'
    c.plot_time_step = 0
    c.play_animation = False

    c.lambda_tol = 1e-6
    c.q = 4
    c.theta = theta
    c.reaction_rate_version = 'v2'  # Expression exact as in FariaEtAl2015.
    c.f = 1
    c.ic_amplitude = 1e-4
    c.ic_type = 'znd'
    c.truncation_coef = 1e6

    outdir = os.path.join(OUTPUT_DIR, outdir)
    if os.path.isdir(outdir):
        shutil.rmtree(outdir)
    os.mkdir(outdir)

    solve('linear', c, outdir, log_to_file=False)
def _get_abs_growth_rates(params, outdir, mode_number=0):
    n12 = params['n12']
    q = params['q']
    a, b = params['e_act_a'], params['e_act_b']

    d_a = 'theta={:{fmt}}'.format(a, fmt=FMT_UNSIGNED)
    d_b = 'theta={:{fmt}}'.format(b, fmt=FMT_UNSIGNED)
    outdir_a = os.path.join(outdir, d_a)
    outdir_b = os.path.join(outdir, d_b)

    try:
        if not os.path.exists(outdir_a):
            c_a = _get_config(n12, q, a)
            os.mkdir(outdir_a)
            solve('linear', c_a, outdir_a, log_to_file=True)
            postprocess(outdir_a, savetofile=True)

        r_a = Reader(outdir_a)
        stab_info_a = r_a.get_stability_info()
        mode = stab_info_a[mode_number]
        if type(mode) is list:
            mode = mode[-1]
        rate_a = mode['growth_rate']
        freq_a = mode['frequency']
    except CannotConstructHankelMatrix:
        rate_a = POSITIVE_INDEFINITE_RATE
        freq_a = None
    except ZNDSolverError:
        rate_a = POSITIVE_INDEFINITE_RATE
        freq_a = None
    except Exception:
        rate_a = None
        freq_a = None

    try:
        if not os.path.exists(outdir_b):
            c_b = _get_config(n12, q, b)
            os.mkdir(outdir_b)
            solve('linear', c_b, outdir_b, log_to_file=True)
            postprocess(outdir_b, savetofile=True)

        r_b = Reader(outdir_b)
        stab_info_b = r_b.get_stability_info()
        mode = stab_info_b[mode_number]
        if type(mode) is list:
            mode = mode[-1]
        rate_b = mode['growth_rate']
        freq_b = mode['frequency']
    except CannotConstructHankelMatrix:
        rate_b = POSITIVE_INDEFINITE_RATE
        freq_b = None
    except ZNDSolverError:
        rate_b = POSITIVE_INDEFINITE_RATE
        freq_b = None
    except Exception as e:
        raise e
        rate_b = None
        freq_b = None

    return ((rate_a, freq_a), (rate_b, freq_b))
コード例 #5
0
def _worker_single_task(task, rank):
    theta = task
    worker_name = rank

    try:
        outdir = 'theta={:{fmt}}'.format(theta, fmt=FMT)
        outdir = os.path.join(OUTPUT_DIR, outdir)

        if os.path.exists(outdir):
            shutil.rmtree(outdir)
        os.mkdir(outdir)
        outname = os.path.join(outdir, 'stdout.log')
        errname = os.path.join(outdir, 'stderr.log')
        sys.stdout = open(outname, 'w')
        sys.stderr = open(errname, 'w')
        msg = 'Worker {} | theta={:{fmt}}'.format(worker_name, theta, fmt=FMT)
        print(msg)
    except Exception as e:
        print('theta={:{fmt}} | {}'.format(theta, str(e), fmt=FMT))
        return

    try:
        c = _get_config(theta)
        solve('nonlinear', c, outdir, log_to_file=False)
        reset_logging()
    except Exception as e:
        print('theta={:{fmt}} | {}'.format(theta, str(e), fmt=FMT))
        sys.stdout = sys.__stdout__
        print('theta={:{fmt}} | {}'.format(theta, str(e), fmt=FMT))