def main():

    # -- DEFINE SIMULATION PARAMETERS
    # ... COMPUTATIONAL DOMAIN
    t_max = 4000.       # (fs)
    t_num = 2**14       # (-)
    z_max = 6.0e6       # (micron)
    z_num = 75000       # (-)
    z_skip=   100       # (-)
    n2 = 3.0e-8         # (micron^2/W)

    beta_fun = define_beta_fun_ESM()
    pc = PropConst(beta_fun)

    # -- INITIALIZATION STAGE
    grid = Grid( t_max = t_max, t_num = t_num, z_max = z_max, z_num = z_num)

    #print(grid.dz)
    #exit()
    model = FMAS_S_Raman(w=grid.w, beta_w=pc.beta(grid.w), n2=n2)
    solver = IFM_RK4IP( model.Lw, model.Nw, user_action = model.claw)

    # -- SET UP INITIAL CONDITION
    t = grid.t
    # ... FUNDAMENTAL NSE SOLITON
    w0_S, t0_S = 1.5, 20.   # (rad/fs), (fs)
    A0 = np.sqrt(abs(pc.beta2(w0_S))*model.c0/w0_S/n2)/t0_S
    A0_S = A0/np.cosh(t/t0_S)*np.exp(1j*w0_S*t)
    # ... 1ST DISPERSIVE WAVE; UNITS (rad/fs), (fs), (fs), (-)
    w0_DW1, t0_DW1, t_off1, s1 = 2.06, 60., -600., 0.35
    A0_DW1 = s1*A0/np.cosh((t-t_off1)/t0_DW1)*np.exp(1j*w0_DW1*t)
    # ... 2ND DISPERSIVE WAVE; UNITS (rad/fs), (fs), (fs), (-)
    w0_DW2, t0_DW2, t_off2, s2 = 2.05, 60., -1200., 0.35
    A0_DW2 = s2*A0/np.cosh((t-t_off2)/t0_DW2)*np.exp(1j*w0_DW2*t)
    # ... 3RD DISPERSIVE WAVE; UNITS (rad/fs), (fs), (fs), (-)
    w0_DW3, t0_DW3, t_off3, s3 = 2.04, 60., -1800., 0.35
    A0_DW3 = s3*A0/np.cosh((t-t_off3)/t0_DW3)*np.exp(1j*w0_DW3*t)
    # ... ANALYTIC SIGNAL OF FULL ININITIAL CONDITION
    Eps_0w = AS(np.real(A0_S + A0_DW1 + A0_DW2 + A0_DW3)).w_rep

    solver.set_initial_condition( grid.w, Eps_0w)
    solver.propagate( z_range = z_max, n_steps = z_num, n_skip = z_skip)

    # -- SHOW RESULTS
    v0 = pc.vg(w0_S)
    utz = change_reference_frame(solver.w, solver.z, solver.uwz, v0)

    res = {
        't': grid.t,
        'w': grid.w,
        'z': solver.z,
        'v0': pc.vg(w0_S),
        'utz': utz,
        'Cp': solver.ua_vals
    }

    save_h5('out_file_HR.h5', **res)
def main():

    # -- SET MODEL PARAMETERS
    t_max = -50.0
    Nt = 2**12
    # ... PROPAGATION CONSTANT (POLYNOMIAL MODEL)
    beta = np.poly1d([-0.5, 0.0, 0.0])
    beta1 = np.polyder(beta, m=1)
    beta2 = np.polyder(beta, m=2)
    # ... NONLINEAR PARAMETER
    gamma = 1.0
    # ... SOLITON PARAMTERS
    t0 = 1.0  # duration
    t_off = 20.0  # temporal offset
    w0 = 25.0  # detuning
    P0 = np.abs(beta2(0)) / t0 / t0 / gamma  # peak-intensity
    LD = t0 * t0 / np.abs(beta2(0))  # dispersion length
    # ... EXACT SOLUTION
    u_exact = lambda z, t: np.sqrt(P0) * np.exp(0.5j * gamma * P0 * z
                                                ) / np.cosh(t / t0)

    # -- INITIALIZATION STAGE
    # ... COMPUTATIONAL DOMAIN
    grid = Grid(t_max=t_max, t_num=Nt)
    t, w = grid.t, grid.w
    # ... NONLINEAR SCHROEDINGER EQUATION
    model = NSE(w, beta(w), gamma)
    # ... PROPAGATION ALGORITHM
    solver = LEM(model.Lw, model.N, del_G=1e-7)
    # ... INITIAL CONDITION
    u0_t = u_exact(0.0, t + t_off) * np.exp(1j * w0 * t)
    u0_t += u_exact(0.0, t - t_off) * np.exp(-1j * w0 * t)
    solver.set_initial_condition(w, FT(u0_t))

    # -- RUN SOLVER
    solver.propagate(
        z_range=0.5 * np.pi * LD,
        n_steps=2**9,
        n_skip=2  # propagation range
    )

    # -- STORE RESULTS
    # ... PREPARE DATA DICTIONARY FOR OUTPUT FILE
    results = {
        "t": t,
        "z": solver.z,
        "w": solver.w,
        "u": solver.utz,
        "dz_integration": solver.dz_,
        "dz_a": np.asarray(solver._dz_a),
        "del_rle": np.asarray(solver._del_rle),
    }
    # ... STORE DATA
    save_h5("./res_LEM_SolSolCollision.h5", **results)
def main():
    # -- DEFINE SIMULATION PARAMETERS
    # ... COMPUTATIONAL DOMAIN
    t_max = 3500.  # (fs)
    t_num = 2**14  # (-)
    z_max = 0.16 * 1e6  # (micron)
    z_num = 4000  # (-)
    z_skip = 10  # (-)
    # ... INITIAL CONDITION
    P0 = 1e4  # (W)
    t0 = 28.4  # (fs)
    w0 = 2.2559  # (rad/fs)
    E_0t_fun = lambda t: np.real(
        np.sqrt(P0) / np.cosh(t / t0) * np.exp(-1j * w0 * t))

    # -- INITIALIZATION STAGE
    # ... COMPUTATIONAL DOMAIN
    grid = Grid(t_max=t_max, t_num=t_num, z_max=z_max, z_num=z_num)
    z = grid.z
    print(z[1] - z[0])
    exit()
    # ... CUSTOM PROPAGATION MODEL
    model = CustomModelPCF(w=grid.w)
    # ... PROPAGATION ALGORITHM
    solver = IFM_RK4IP(model.Lw, model.Nw, user_action=model.claw)
    solver.set_initial_condition(grid.w, AS(E_0t_fun(grid.t)).w_rep)

    # -- RUN SIMULATION
    solver.propagate(z_range=z_max, n_steps=z_num, n_skip=z_skip)

    res = {
        "dz_integration": solver.dz_,
        "t": grid.t,
        "z": solver.z,
        "w": solver.w,
        "utz": solver.utz,
        "Cp": solver.ua_vals
    }

    save_h5('res_IFM_SC_Nz%d.h5' % (z_num), **res)

    # -- SHOW RESULTS
    plot_evolution(solver.z,
                   grid.t,
                   solver.utz,
                   t_lim=(-500, 2200),
                   w_lim=(1., 4.),
                   DO_T_LOG=False)
示例#4
0
###############################################################################
# An example that shows how an adequate input file can be generated via python
# is shown under the link below:
#
# :ref:`sphx_glr_auto_tutorials_basics_ng_generate_infile.py`
#
# After the proapgation algorithm (specified in `input_file.h5`) terminates,
# a simple dictionary data structure with the following keys is available

print(res.keys())

###############################################################################
# A simple plot that shows the result of the simulation run can be produced
# using function `plot_evolution` implemented in module `tools`

from fmas.tools import plot_evolution
plot_evolution(res['z'],
               res['t'],
               res['u'],
               t_lim=(-500, 2200),
               w_lim=(1., 4.))

###############################################################################
# The results can be stored for later postprocessing using the function
# `save_h5` implemented in module `data_io`. It will generate a file
# `out_file.h5` with HDF5 format in the current working directory

from fmas.data_io import save_h5
save_h5('out_file.h5', **res)