Exemplo n.º 1
0
def run_tdse_sims(
    amplitudes=np.array([0.3, 0.5]) * atomic_electric_field,
    number_of_cycleses=(6, 12),
    omegas=np.array([0.2]) * atomic_angular_frequency,
    r_bound=100 * bohr_radius,
    mask_inner=75 * bohr_radius,
    mask_outer=100 * bohr_radius,
    r_points=500,
    l_points=300,
):
    mesh_identifier = f"R={r_bound / bohr_radius:3f}_Nr={r_points}_L={l_points}"

    specs = []
    for amplitude, number_of_cycles, omega in itertools.product(
        amplitudes, number_of_cycleses, omegas
    ):
        pulse = BauerGaussianPulse(
            amplitude=amplitude, number_of_cycles=number_of_cycles, omega=omega
        )
        pulse_identifier = get_pulse_identifier(pulse)

        times = np.linspace(-pulse.pulse_center, pulse.pulse_center * 3, 1000)

        si.vis.xy_plot(
            f"field__{pulse_identifier}",
            times,
            pulse.get_electric_field_amplitude(times),
            pulse.get_electric_field_envelope(times) * pulse.amplitude,
            x_unit="fsec",
            y_unit="atomic_electric_field",
            **PLOT_KWARGS,
        )

        specs.append(
            ion.SphericalHarmonicSpecification(
                f"tdse__{mesh_identifier}__{pulse_identifier}",
                r_bound=r_bound,
                r_points=r_points,
                l_points=l_points,
                time_initial=times[0],
                time_final=times[-1],
                time_step=1 * asec,
                electric_potential=pulse,
                mask=potentials.RadialCosineMask(
                    inner_radius=mask_inner, outer_radius=mask_outer
                ),
                use_numeric_eigenstates=True,
                numeric_eigenstate_max_energy=20 * eV,
                numeric_eigenstate_max_angular_momentum=5,
                checkpoints=True,
                checkpoint_dir=SIM_LIB,
                checkpoint_every=datetime.timedelta(minutes=1),
            )
        )

    return si.utils.multi_map(run, specs, processes=2), mesh_identifier
Exemplo n.º 2
0
def get_tdse_spec(pulse, times):
    spec = ion.SphericalHarmonicSpecification(
        pulse_identifier(pulse),
        r_bound=100 * u.bohr_radius,
        r_points=500,
        l_bound=200,
        time_initial=times[0],
        time_final=times[-1],
        electric_potential=pulse,
        store_energy_expectation_value=True,
        store_electric_dipole_moment_expectation_value=True,
        use_numeric_eigenstates=True,
        numeric_eigenstate_max_energy=20 * u.eV,
        numeric_eigenstate_max_angular_momentum=3,
        electric_potential_dc_correction=True,
        checkpoints=True,
        checkpoint_every=datetime.timedelta(minutes=1),
        checkpoint_dir=SIM_LIB,
    )

    return spec
            mask=ion.RadialCosineMask(
                inner_radius=0.9 * r_bound * bohr_radius,
                outer_radius=r_bound * bohr_radius,
            ),
            store_data_every=10,
            snapshot_type=ion.SphericalHarmonicSnapshot,
            snapshot_times=[(t_bound + (n * 100)) * asec for n in range(100)],
            snapshot_kwargs=dict(
                plane_wave_overlap__max_wavenumber=60 * per_nm,
                plane_wave_overlap__wavenumber_points=200,
                plane_wave_overlap__theta_points=100,
            ),
        )

        sim = ion.SphericalHarmonicSpecification(
            f"R={r_bound}_amp={amp}_phase={phase / pi:3f}pi_tB={t_bound}_tE={t_extra}",
            **spec_kwargs,
        ).to_sim()

        OUT_DIR = os.path.join(OUT_DIR, sim.name)

        print(sim.info())
        sim.run()
        sim.save(target_dir=OUT_DIR)
        print(sim.info())

        # sim.mesh.plot_g(target_dir = OUT_DIR)
        # sim.mesh.plot_g(target_dir = OUT_DIR, name_postfix = '_25', plot_limit = 25 * bohr_radius)

        for log in (True, False):
            si.vis.xy_plot(
                f"norm_vs_time__log={log}",
Exemplo n.º 4
0
            initial_state=ion.HydrogenBoundState(1, 0),
            time_initial=-t_bound * asec,
            time_final=(t_bound + t_extra) * asec,
            time_step=1 * asec,
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=50 * eV,
            numeric_eigenstate_max_angular_momentum=5,
            electric_potential=efield,
            electric_potential_dc_correction=True,
            mask=ion.RadialCosineMask(inner_radius=0.8 * bound * bohr_radius,
                                      outer_radius=bound * bohr_radius),
            store_data_every=-1,
        )

        sim = ion.SphericalHarmonicSpecification(
            f"PWTest_amp={amp}aef_phase={phase / pi:3f}pi__tB={t_bound}pw__tE={t_extra}asec",
            **spec_kwargs,
        ).to_sim()

        sim.run()
        print(sim.info())

        # sim.mesh.plot_g(target_dir = OUT_DIR)
        # sim.mesh.plot_g(target_dir = OUT_DIR, name_postfix = '_25', plot_limit = 25 * bohr_radius)
        #
        # plot_kwargs = dict(
        #     target_dir = OUT_DIR,
        #     bound_state_max_n = 4,
        # )
        #
        # sim.plot_wavefunction_vs_time(**plot_kwargs, name_postfix = '__no_grouping')
        # sim.plot_wavefunction_vs_time(**plot_kwargs, name_postfix = '__no_grouping__collapsed_l',
Exemplo n.º 5
0
            time_final=time_bound * pw,
            time_step=1 * asec,
            mask=ion.RadialCosineMask(
                inner_radius=(r_bound * 0.8) * bohr_radius,
                outer_radius=r_bound * bohr_radius,
            ),
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=10 * eV,
            numeric_eigenstate_max_angular_momentum=10,
            electric_potential_dc_correction=True,
            store_data_every=20,
        )

        specs = [
            ion.SphericalHarmonicSpecification(
                "cosine", electric_potential=cosine_pulse, **shared_kwargs
            ),
            ion.SphericalHarmonicSpecification(
                "sine", electric_potential=sine_pulse, **shared_kwargs
            ),
        ]

        cosine_sim = specs[0].clone().to_sim()
        times = cosine_sim.times

        print(specs)

        rand_pulses = []
        for i in range(num_random_pulses):
            rand_pulses.append(
                ion.GenericElectricPotential.from_pulse(
Exemplo n.º 6
0
 ion.SphericalHarmonicSpecification(
     # fr'cep={phase / pi:3f}pi',
     f"pw={pulse_width / asec:3f}as_flu={fluence / Jcm2:3f}jcm2_cep={phase / pi:3f}pi",
     r_bound=100 * bohr_radius,
     r_points=400,
     l_bound=100,
     time_initial=-10 * pulse_width,
     time_final=10 * pulse_width,
     time_step=1 * asec,
     use_numeric_eigenstates=True,
     numeric_eigenstate_max_energy=30 * eV,
     numeric_eigenstate_max_angular_momentum=10,
     electric_potential=pulse,
     electric_potential_dc_correction=True,
     initial_state=initial_state,
     # animators = [
     #     ion.animators.PolarAnimator(
     #         postfix = '__g_wavefunction',
     #         axman_wavefunction = ion.animators.SphericalHarmonicPhiSliceMeshAxis(
     #             which = 'g',
     #             colormap = plt.get_cmap('richardson'),
     #             norm = si.vis.RichardsonNormalization(),
     #             plot_limit = 30 * bohr_radius,
     #         ),
     #         axman_lower_right = ion.animators.ElectricPotentialPlotAxis(
     #             show_electric_field = True,
     #             show_vector_potential = False,
     #             show_y_label = False,
     #             show_ticks_right = True,
     #         ),
     #         axman_upper_right = ion.animators.WavefunctionStackplotAxis(states = [initial_state]),
     #         axman_colorbar = None,
     #         target_dir = OUT_DIR,
     #         fig_dpi_scale = 2,
     #         length = 30,
     #         fps = 30,
     #     ),
     # ]
 ))
Exemplo n.º 7
0
        spec_kwargs = dict(
            r_bound=bound * bohr_radius,
            r_points=bound * ppbr,
            l_bound=30,
            initial_state=state_a,
            time_initial=0 * asec,
            time_step=dt * asec,
            mask=ion.RadialCosineMask(inner_radius=0.8 * bound * bohr_radius,
                                      outer_radius=bound * bohr_radius),
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=20 * eV,
            numeric_eigenstate_max_angular_momentum=10,
            store_data_every=10,
        )

        dummy = ion.SphericalHarmonicSpecification("dummy",
                                                   **spec_kwargs).to_sim()

        state_a = dummy.mesh.analytic_to_numeric[state_a]
        state_b = dummy.mesh.analytic_to_numeric[state_b]

        dipole_moment = np.abs(
            dummy.mesh.z_dipole_moment_inner_product(b=state_b))

        # print(f'calculated dipole moment between {state_a} and {state_b} is {dipole_moment / (proton_charge * bohr_radius)}')
        # print(np.sqrt(2) * (2 ** 7) / (3 ** 5))

        specs = []

        for amplitude, cycle, gauge in itertools.product(
                amplitudes, cycles, gauges):
            electric_field = ion.SineWave.from_photon_energy(
Exemplo n.º 8
0
FILE_NAME = os.path.splitext(os.path.basename(__file__))[0]
OUT_DIR = os.path.join(os.getcwd(), "out", FILE_NAME)

if __name__ == "__main__":
    with si.utils.LogManager("simulacra",
                             "ionization",
                             stdout_logs=True,
                             stdout_level=logging.DEBUG) as logger:
        bound = 100
        points_per_bohr_radius = 4

        sim = ion.SphericalHarmonicSpecification(
            "test",
            r_bound=bound * bohr_radius,
            r_points=bound * points_per_bohr_radius,
            l_bound=50,
            initial_state=ion.HydrogenBoundState(1, 0),
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=10 * eV,
            numeric_eigenstate_max_angular_momentum=5,
        ).to_sim()

        print(sim.info())
        print()

        # for wavenumber, v in sim.mesh.analytic_to_numeric.items():
        #     print(f'{wavenumber} -> {v}')

        print()
        a_state = ion.HydrogenBoundState(1, 0)
        print(a_state)
        print(sim.mesh.get_g_for_state(a_state))
Exemplo n.º 9
0
            numeric_eigenstate_max_energy=50 * eV,
            numeric_eigenstate_max_angular_momentum=20,
            electric_potential=efield,
            electric_potential_dc_correction=True,
            mask=ion.RadialCosineMask(inner_radius=0.8 * bound * bohr_radius,
                                      outer_radius=bound * bohr_radius),
            store_norm_by_l=True,
            store_data_every=store_every,
            animators=ani,
            snapshot_times=[10 * pw * asec],
            snapshot_indices=[-1],
            snapshot_type=ion.SphericalHarmonicSnapshot,
        )

        sim = ion.SphericalHarmonicSpecification(
            "SumOfSines__flu={}jcm2__{}at{}x{}__data_rate={}".format(
                flu, bound, points_per_bohr_radius, l_bound, store_every),
            **spec_kwargs).to_sim()

        print(sim.info())
        sim.run()
        print(sim.info())

        # path = sim.save(target_dir = OUT_DIR, save_mesh = True)
        # sim = si.Simulation.load(path)

        sim.mesh.plot_g2(target_dir=OUT_DIR)
        sim.mesh.plot_g2(target_dir=OUT_DIR,
                         name_postfix="_25",
                         plot_limit=50 * bohr_radius)

        plot_kwargs = dict(target_dir=OUT_DIR, bound_state_max_n=4)
    points_per_bohr_radius = 4

    spec_kwargs = {
        "r_bound": bound * bohr_radius,
        "r_points": bound * points_per_bohr_radius,
        "l_bound": 100,
        "initial_state": ion.HydrogenBoundState(1, 0),
        "time_initial": -1000 * asec,
        "time_final": 1000 * asec,
        "time_step": 1 * asec,
        "test_states": test_states,
    }

    OUT_DIR = os.path.join(
        OUT_DIR, "bound={}_ppbr={}".format(bound, points_per_bohr_radius))
    sim = ion.SphericalHarmonicSpecification("eig", **spec_kwargs).to_sim()

    with si.utils.LogManager(
            "simulacra",
            "ionization",
            stdout_logs=True,
            stdout_level=logging.DEBUG,
            file_logs=True,
            file_mode="w",
            file_dir=OUT_DIR,
            file_name="log",
    ) as logger:

        # CONSTRUCT EIGENBASIS
        numerical_basis = {}
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=200 * eV,
            numeric_eigenstate_max_angular_momentum=50,
            electric_potential=ion.SineWave.from_photon_energy(
                rydberg + 5 * eV, amplitude=0.5 * atomic_electric_field),
            mask=ion.RadialCosineMask(inner_radius=0.8 * bound * bohr_radius,
                                      outer_radius=bound * bohr_radius),
        )

        analytic_test_states = [
            ion.HydrogenBoundState(n, l) for n in range(6) for l in range(n)
        ]

        sims = [
            ion.SphericalHarmonicSpecification("dt={}as_every{}".format(
                dt, store_every),
                                               store_data_every=store_every,
                                               **spec_kwargs).to_sim()
        ]

        for sim in sims:
            sim.run()

            sim.save(target_dir=OUT_DIR, save_mesh=False)

            plot_kwargs = dict(target_dir=OUT_DIR,
                               img_format="pdf",
                               bound_state_max_n=4)

            sim.plot_wavefunction_vs_time(**plot_kwargs,
                                          name_postfix="__no_grouping")
            sim.plot_wavefunction_vs_time(
def make_plot(args):
    pulse_type, pw, flu, cep = args

    t_bound = T_BOUND_MAP[pulse_type]
    p_bound = P_BOUND_MAP[pulse_type]

    times = np.linspace(-t_bound * pw, t_bound * pw, 1e4)

    window = ion.potentials.LogisticWindow(
        window_time=p_bound * pw, window_width=0.2 * pw
    )
    pulse = pulse_type(pulse_width=pw, fluence=flu, phase=cep, window=window)
    corrected_pulse = ion.DC_correct_electric_potential(pulse, times)

    efield = corrected_pulse.get_electric_field_amplitude(times)
    afield = corrected_pulse.get_vector_potential_amplitude_numeric_cumulative(times)

    starts = range(0, len(times), 50)[50:-50]

    sliced_times = list(times[start:] for start in starts)
    sliced_alphas = list(
        (proton_charge / electron_mass)
        * integ.cumtrapz(
            y=integ.cumtrapz(y=efield[start:], x=times[start:], initial=0),
            x=times[start:],
            initial=0,
        )
        for start in starts
    )

    identifier = f"{pulse_type.__name__}__pw={pw / asec:0f}as_flu={flu / Jcm2:2f}jcm2_cep={cep / pi:2f}pi"

    spec = ion.SphericalHarmonicSpecification(
        identifier,
        r_bound=250 * bohr_radius,
        r_points=250 * 4,
        l_bound=500,
        time_initial=times[0],
        time_final=times[-1],
        use_numeric_eigenstates=True,
        numeric_eigenstate_max_energy=10 * eV,
        numeric_eigenstate_max_angular_momentum=5,
        electric_potential=pulse,
        electric_potential_dc_correction=True,
        mask=ion.RadialCosineMask(
            inner_radius=225 * bohr_radius, outer_radius=250 * bohr_radius
        ),
        checkpoints=True,
        checkpoint_every=50,
        checkpoint_dir=SIM_LIB,
    )

    sim = si.utils.find_or_init_sim(spec, search_dir=SIM_LIB)
    if sim.status != si.Status.FINISHED:
        sim.run_simulation()
        sim.save(target_dir=SIM_LIB)

    si.vis.xxyy_plot(
        identifier,
        [times, times, sim.times, *sliced_times],
        [
            efield / atomic_electric_field,
            afield * (proton_charge / atomic_momentum),
            sim.radial_position_expectation_value_vs_time / bohr_radius,
            *(alpha / bohr_radius for alpha in sliced_alphas),
        ],
        line_labels=[
            rf"$ {ion.vis.LATEX_EFIELD}(t) $",
            rf"$ e \, {ion.LATEX_AFIELD}(t) $",
            rf"$ \left\langle r(t) \right\rangle $",
            rf"$ \alpha(t) $",
        ],
        line_kwargs=[
            None,
            None,
            None,
            *({"color": "black", "alpha": 0.5} for _ in starts),
        ],
        x_label=r"Time $t$",
        x_unit="asec",
        # y_label = r'Field Amplitude (a.u.) / Distance ($a_0$)',
        title=rf"$ \tau = {pw / asec:0f} \, \mathrm{{as}}, \; H = {flu / Jcm2:2f} \, \mathrm{{J/cm^2}}, \; \varphi = {cep / pi:2f}\pi $",
        **PLOT_KWARGS,
    )
Exemplo n.º 13
0
                        axman_lower_right=deepcopy(axman_lower_right),
                        axman_upper_right=animation.animators.
                        WavefunctionStackplotAxis(states=[initial_state]),
                        **animator_kwargs,
                    ),
                ]

                specs.append(
                    ion.SphericalHarmonicSpecification(
                        name,
                        electric_potential=efield,
                        time_initial=-t_bound * pw,
                        time_final=t_bound * pw,
                        time_step=dt * asec,
                        r_points=r_points,
                        r_bound=r_bound * bohr_radius,
                        l_bound=l_bound,
                        initial_state=initial_state,
                        mask=mask,
                        use_numeric_eigenstates=True,
                        numeric_eigenstate_max_energy=50 * eV,
                        numeric_eigenstate_max_angular_momentum=20,
                        animators=deepcopy(animators),
                        electric_potential_dc_correction=True,
                        store_data_every=5,
                    ))

            si.utils.multi_map(run, specs, processes=4)

        print(timer)
Exemplo n.º 14
0
            number_of_cycles=10)

        shared_kwargs = dict(
            electric_potential=pulse,
            time_initial=-time_bound * pulse.pulse_width,
            time_final=time_bound * pulse.pulse_width,
            # electric_potential_dc_correction = True,
        )

        tdse_spec = ion.SphericalHarmonicSpecification(
            "tdse",
            r_bound=100 * bohr_radius,
            r_points=500,
            l_bound=100,
            time_step=1 * asec,
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=20 * eV,
            numeric_eigenstate_max_angular_momentum=20,
            mask=potentials.RadialCosineMask(inner_radius=75 * bohr_radius,
                                             outer_radius=100 * bohr_radius),
            **shared_kwargs,
        )

        ide_spec = ide.IntegroDifferentialEquationSpecification(
            "ide",
            time_step=0.5 * asec,
            kernel=ide.
            LengthGaugeHydrogenKernelWithContinuumContinuumInteraction(),
            **shared_kwargs,
        )
Exemplo n.º 15
0
def compare_quasistatic_to_tdse(intensity, photon_energy):
    dummy = ion.SineWave.from_photon_energy(0.5 * eV)

    time_initial = 0
    time_final = 8 * dummy.period_carrier

    time_front = 1 * dummy.period_carrier
    time_plateau = 5 * dummy.period_carrier

    efield = ion.SineWave.from_photon_energy_and_intensity(
        photon_energy, intensity)
    efield.window = ion.potentials.SmoothedTrapezoidalWindow(
        time_front=time_front, time_plateau=time_plateau)

    r_bound = 100
    r_points = 4 * r_bound
    l_bound = 400
    dt = 4
    store = 5

    h = hash((
        intensity,
        photon_energy,
        time_initial,
        time_final,
        time_front,
        time_plateau,
        r_bound,
        r_points,
        l_bound,
        dt,
        store,
    ))

    title = f"P={intensity / atomic_intensity:5f}_E={photon_energy / eV:1f}_R={r_bound}_Rp={r_points}_L={l_bound}_dt={dt}_sde={store}"

    spec = ion.SphericalHarmonicSpecification(
        f"tdse_{h}",
        r_bound=r_bound * bohr_radius,
        r_points=r_points,
        l_bound=l_bound,
        internal_potential=ion.SoftCoulomb(softening_distance=0.05 *
                                           bohr_radius),
        time_initial=time_initial,
        time_final=time_final,
        time_step=dt * asec,
        electric_potential=efield,
        use_numeric_eigenstates=True,
        numeric_eigenstate_max_energy=20 * eV,
        numeric_eigenstate_max_angular_momentum=5,
        store_data_every=store,
        checkpoints=True,
        checkpoint_dir=SIM_LIB,
        checkpoint_every=50,
        mask=ion.RadialCosineMask(0.9 * r_bound * bohr_radius,
                                  r_bound * bohr_radius),
    )

    sim = si.utils.find_or_init_sim(spec, search_dir=SIM_LIB)

    sim.info().log()
    if not sim.status == si.Status.FINISHED:
        sim.run_simulation(progress_bar=True)
        sim.info().log()

    sim.save(target_dir=SIM_LIB)

    sim.plot_wavefunction_vs_time(**PLOT_KWARGS)

    times = np.linspace(time_initial, time_final, 1e3)

    si.vis.xy_plot(
        title + "__efield_vs_time",
        times,
        efield.get_electric_field_amplitude(times),
        x_label=r"Time $t$",
        x_unit="asec",
        y_label=fr"$ {ion.vis.LATEX_EFIELD}(t) $)",
        y_unit="atomic_electric_field",
        **PLOT_KWARGS,
    )

    tunneling_rate_vs_time = instantaneous_tunneling_rate(
        efield.get_electric_field_amplitude(times),
        sim.spec.initial_state.energy)

    si.vis.xy_plot(
        title + "__tunneling_rate_vs_time",
        times,
        tunneling_rate_vs_time * asec,
        x_label=r"Time $t$",
        x_unit="asec",
        y_label=r"Tunneling Rate ($\mathrm{as}^{-1}$)",
        **PLOT_KWARGS,
    )

    wavefunction_remaining = np.empty_like(times)
    wavefunction_remaining[0] = 1
    for ii, tunneling_rate in enumerate(tunneling_rate_vs_time[:-1]):
        wavefunction_remaining[ii + 1] = wavefunction_remaining[ii] * (
            1 - (tunneling_rate * np.abs(times[ii + 1] - times[ii])))

    cycle_avg_rate = averaged_tunneling_rate(efield.amplitude)
    cycle_avg_norm_remaining_plat = np.exp(-cycle_avg_rate * time_plateau)
    cycle_avg_norm_remaining_all = np.exp(-cycle_avg_rate * (time_plateau +
                                                             (2 * time_front)))

    for log in (True, False):
        si.vis.xxyy_plot(
            title + f"__comparison__log={log}",
            (sim.data_times, sim.data_times, sim.data_times, times),
            (
                sim.norm_vs_time,
                sim.total_bound_state_overlap_vs_time,
                sim.state_overlaps_vs_time[sim.spec.initial_state],
                wavefunction_remaining,
            ),
            line_labels=(
                "TDSE Norm",
                "TDSE Bound States",
                "TDSE Initial State",
                "Tunneling",
            ),
            x_label=r"Time $t$",
            x_unit="fsec",
            y_label="Remaining Wavefunction",
            y_log_axis=log,
            hlines=[
                cycle_avg_norm_remaining_plat, cycle_avg_norm_remaining_all
            ],
            hline_kwargs=[{
                "linestyle": "--"
            }, {
                "linestyle": ":"
            }],
            **PLOT_KWARGS,
        )
Exemplo n.º 16
0
 ion.LineSpecification(
     prefix + "__fsw_len",
     internal_potential=internal_potential,
     initial_state=fsw_initial_state,
     evolution_gauge="LEN",
     **shared_kwargs,
 ),
 # ion.LineSpecification(
 #     prefix + '__line_vel',
 #     internal_potential = internal_potential,
 #     initial_state = ion.FiniteSquareWellState.from_potential(internal_potential, mass = test_mass),
 #     evolution_gauge = 'VEL',
 #     **shared_kwargs,
 # ),
 ion.SphericalHarmonicSpecification(prefix + "__hyd_len",
                                    evolution_gauge="LEN",
                                    **shared_kwargs),
 # ion.SphericalHarmonicSpecification(
 #     prefix + '__hyd_vel',
 #     evolution_gauge = 'VEL',
 #     **shared_kwargs,
 # ),
 ide.IntegroDifferentialEquationSpecification(
     prefix + "__ide_len",
     integral_prefactor=ide.gaussian_prefactor_LEN(
         test_width, test_charge),
     kernel=ide.gaussian_kernel_LEN,
     kernel_kwargs={
         "tau_alpha":
         ide.gaussian_tau_alpha_LEN(test_width, test_mass)
     },
Exemplo n.º 17
0
            for l in range(test_states_l_points)
        ]

        # test_states += coulomb_states

        logger.info("Warning: using {} test states".format(len(test_states)))

        # SET UP SIM
        sim = ion.SphericalHarmonicSpecification(
            identifier,
            r_bound=space_bound,
            r_points=r_points,
            l_bound=l_bound,
            # time_initial = - time_bound, time_final = time_bound, time_step = dt,
            time_initial=0,
            time_final=electric_field.period_carrier * 20,
            time_step=dt,
            internal_potential=ion.Coulomb(),
            electric_potential=electric_field,
            initial_state=initial_state,
            test_states=test_states,
            mask=mask,
        ).to_sim()

        sim.info().log()
        sim.run()
        sim.info().log()

        sim.plot_wavefunction_vs_time(target_dir=OUT_DIR)

        overlap_by_energy = {s.energy: 0 for s in coulomb_states}
Exemplo n.º 18
0
    ) as logger:
        bound = 70
        points_per_bohr_radius = 4

        spec_kwargs = dict(
            r_bound=bound * bohr_radius,
            r_points=bound * points_per_bohr_radius,
            l_bound=70,
            initial_state=ion.HydrogenBoundState(1, 0),
            time_initial=0 * asec,
            time_final=500 * asec,
            time_step=1 * asec,
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=200 * eV,
            numeric_eigenstate_max_angular_momentum=50,
            electric_potential=ion.SineWave.from_photon_energy(
                rydberg + 5 * eV, amplitude=0.5 * atomic_electric_field),
            mask=ion.RadialCosineMask(inner_radius=0.8 * bound * bohr_radius,
                                      outer_radius=bound * bohr_radius),
            out_dir=OUT_DIR,
        )

        every = [1, 5, 10, 100, 600]
        specs = [
            ion.SphericalHarmonicSpecification("eig_{}".format(e),
                                               store_data_every=e,
                                               **spec_kwargs) for e in every
        ]

        si.utils.multi_map(run, specs, processes=2)
                fluence=flu,
                phase=cep,
                number_of_cycles=n_cycles,
                number_of_pulse_widths=3,
                window=ion.potentials.LogisticWindow(
                    window_time=pulse_time_bound * pw, window_width=0.2 * pw),
            )

            specs.append(
                ion.SphericalHarmonicSpecification(
                    f"{pulse_type.__name__}__Nc={n_cycles}_pw={pw / asec:3f}as_flu={flu / Jcm2:3f}jcm2_cep={cep / pi:3f}pi__R={r_bound / bohr_radius:3f}br_ppbr={r_points_per_br}_L={l_bound}_dt={dt / asec:3f}as",
                    r_bound=r_bound,
                    r_points=r_points_per_br * r_bound / bohr_radius,
                    l_bound=l_bound,
                    time_step=dt,
                    time_initial=-sim_time_bound * pw,
                    time_final=(sim_time_bound + extra_end_time) * pw,
                    mask=ion.RadialCosineMask(0.8 * r_bound, r_bound),
                    electric_potential=pulse,
                    electric_potential_dc_correction=True,
                    use_numeric_eigenstates=True,
                    numeric_eigenstate_max_energy=20 * eV,
                    numeric_eigenstate_max_angular_momentum=20,
                    checkpoints=True,
                    checkpoint_dir=SIM_LIB,
                    checkpoint_every=datetime.timedelta(minutes=1),
                    store_radial_probability_current=True,
                ))

        si.utils.multi_map(run_spec, specs, processes=4)
Exemplo n.º 20
0
    with si.utils.LogManager(
        "simulacra",
        "ionization",
        stdout_logs=True,
        stdout_level=logging.DEBUG,
        file_logs=False,
        file_mode="w",
        file_dir=OUT_DIR,
        file_name="log",
    ) as logger:
        bound = 100
        points_per_bohr_radius = 4
        l_max = 10
        energy = 20

        sim = ion.SphericalHarmonicSpecification(
            "eig",
            r_bound=bound * bohr_radius,
            r_points=bound * points_per_bohr_radius,
            l_bound=50,
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=energy * eV,
            numeric_eigenstate_max_angular_momentum=l_max,
        ).to_sim()

        print("max?:", ((bound * points_per_bohr_radius) - 2) * (l_max + 1))
        print("total:", len(sim.spec.test_states))
        bound = len(list(sim.bound_states))
        free = len(list(sim.free_states))
        print("{} free + {} bound = {} total".format(free, bound, free + bound))
Exemplo n.º 21
0
            r_points=100 * 10,
            l_bound=500,
            use_numeric_eigenstates=False,
            numeric_eigenstate_max_energy=20 * u.eV,
            numeric_eigenstate_max_angular_momentum=10,
            store_data_every=10,
            checkpoints=True,
            checkpoint_dir=SIM_LIB,
            checkpoint_every=datetime.timedelta(minutes=1),
        )

        specs = [
            ion.SphericalHarmonicSpecification(
                "uncorrected_cos",
                electric_potential=uncorrected_cos_pulse,
                electric_potential_dc_correction=False,
                electric_potential_fluence_correction=False,
                **spec_kwargs,
            ),
            ion.SphericalHarmonicSpecification(
                "uncorrected_sin",
                electric_potential=uncorrected_sin_pulse,
                electric_potential_dc_correction=False,
                electric_potential_fluence_correction=False,
                **spec_kwargs,
            ),
            ion.SphericalHarmonicSpecification(
                "dc_corrected_cos",
                electric_potential=uncorrected_cos_pulse,
                electric_potential_dc_correction=True,
                electric_potential_fluence_correction=False,
    points_per_bohr_radius = 4

    spec_kwargs = {
        "r_bound": bound * bohr_radius,
        "r_points": bound * points_per_bohr_radius,
        "l_bound": 100,
        "initial_state": ion.HydrogenBoundState(1, 0),
        "time_initial": 0 * asec,
        "time_final": 200 * asec,
        "time_step": 1 * asec,
    }

    OUT_DIR = os.path.join(
        OUT_DIR, "bound={}_ppbr={}".format(bound, points_per_bohr_radius)
    )
    sim = ion.SphericalHarmonicSpecification("eig", **spec_kwargs).to_sim()

    with si.utils.LogManager(
        "simulacra",
        "ionization",
        stdout_logs=True,
        stdout_level=logging.INFO,
        file_logs=True,
        file_mode="w",
        file_dir=OUT_DIR,
        file_name="log",
    ) as logger:
        for l in range(l_bound):
            logger.info("working on l = {}".format(l))
            h = sim.mesh._get_internal_hamiltonian_matrix_operator_single_l(l=l)
            with si.utils.BlockTimer() as t:
Exemplo n.º 23
0
            end_time=300 * asec,
            amplitude=1 * atomic_electric_field,
        )

        base_spec_kwargs = dict(
            r_bound=50 * bohr_radius,
            r_points=200,
            l_bound=50,
            time_initial=0 * asec,
            time_final=400 * asec,
            use_numeric_eigenstates=True,
            electric_potential=efield,
            electric_potential_dc_correction=True,
        )

        specs = []
        for name, dt in zip(
            (".5as", "1as", "5as", "dense_center"),
            (0.5 * asec, 1 * asec, 5 * asec, dense_center),
        ):
            specs.append(
                ion.SphericalHarmonicSpecification(
                    name, time_step=dt, **base_spec_kwargs
                )
            )

        results = si.utils.multi_map(run_spec, specs)

        for r in sorted(results, key=lambda r: r.running_time):
            print(r.running_time, r.name)
        pulse_widths = [290, 310, 390, 410]
        # pulse_widths = [50, 100, 200, 400, 600, 800]
        t_step = 2 * asec

        mask = ion.RadialCosineMask(inner_radius=100 * bohr_radius,
                                    outer_radius=150 * bohr_radius)

        specs = []
        for phase in ("cos", "sin"):
            for pw in pulse_widths:
                sinc = ion.potentials.SincPulse.from_amplitude_density(
                    pulse_width=pw * asec,
                    amplitude_density=source.amplitude_omega,
                    phase=phase,
                )

                specs.append(
                    ion.SphericalHarmonicSpecification(
                        "pw={}asec_phase={}".format(pw, phase),
                        r_bound=150 * bohr_radius,
                        r_points=600,
                        l_bound=100,
                        electric_potential=sinc,
                        mask=mask,
                        time_initial=-15 * pw * asec,
                        time_final=15 * pw * asec,
                        time_step=t_step,
                    ))

        si.utils.multi_map(run, specs)
Exemplo n.º 25
0
        animators = [
            src.ionization.animators.SphericalHarmonicAnimator(
                postfix="_nm", target_dir=OUT_DIR, distance_unit="nm"),
            src.ionization.animators.SphericalHarmonicAnimator(
                postfix="_br", target_dir=OUT_DIR,
                distance_unit="bohr_radius"),
        ]
        specs.append(
            ion.SphericalHarmonicSpecification(
                "sph_harm",
                time_initial=t_init * asec,
                time_final=t_final * asec,
                time_step=dt * asec,
                r_bound=bound * bohr_radius,
                r_points=radial_points,
                l_bound=angular_points,
                initial_state=initial_state,
                electric_potential=e_field,
                mask=mask,
                animators=animators,
            ))

        #######

        mass = electron_mass
        pot = ion.HarmonicOscillator.from_energy_spacing_and_mass(
            energy_spacing=1 * eV, mass=mass)

        init = ion.QHOState.from_potential(
            pot, mass, n=1) + ion.QHOState.from_potential(pot, mass, n=2)
            #         target_dir = OUT_DIR,
            #         axman_wavefunction = ion.animators.SphericalHarmonicPhiSliceMeshAxis(
            #             norm = si.vis.AbsoluteRenormalize(),
            #         ),
            #     )
            # ]
        )

        specs = []
        for gauge in ("LEN", "VEL"):
            for r_points, l_bound in itertools.product([200, 201], [30, 31]):
                specs.append(
                    ion.SphericalHarmonicSpecification(
                        f"{gauge}__R={r_points}_L={l_bound}",
                        r_points=r_points,
                        l_bound=l_bound,
                        evolution_gauge=gauge,
                        **spec_base,
                    ))

        results = si.utils.multi_map(run_sim, specs, processes=3)

        si.vis.xxyy_plot(
            "dipole_moment",
            (r.data_times for r in results),
            (r.electric_dipole_moment_expectation_value_vs_time
             for r in results),
            line_labels=(r.name for r in results),
            line_kwargs=({
                "linestyle": "-"
            }, {
Exemplo n.º 27
0
                axman_lower_right=deepcopy(epot_axman),
                axman_upper_right=deepcopy(wavefunction_axman),
                axman_colorbar=None,
                fig_dpi_scale=2,
                **anim_kwargs,
            ),
        ]

        sim = ion.SphericalHarmonicSpecification(
            "sph_harm",
            time_initial=0 * asec,
            time_final=100 * asec,
            r_bound=50 * bohr_radius,
            l_bound=20,
            r_points=200,
            electric_potential=ion.potentials.Rectangle(
                start_time=25 * asec,
                end_time=75 * asec,
                amplitude=1 * atomic_electric_field,
            ),
            # test_states = (ion.HydrogenBoundState(n, l) for n in range(5) for l in range(n)),
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=10 * eV,
            numeric_eigenstate_max_angular_momentum=5,
            animators=animators,
        ).to_sim()

        sim.info().log()
        sim.run()
        sim.info().log()
        for r_points, time_step in it.product(r_points_list, time_step_list):
            spec_name = [prefix] + [
                "{}x{}".format(r_points, l_bound),
                "dt={}as".format(time_step),
            ]

            specs.append(
                ion.SphericalHarmonicSpecification(
                    "__".join(spec_name),
                    r_bound=r_bound * bohr_radius,
                    r_points=int(r_points),
                    l_bound=l_bound,
                    time_step=time_step * asec,
                    time_initial=-t_bound * asec,
                    time_final=t_bound * asec,
                    electric_potential=electric_potential,
                    use_numeric_eigenstates=True,
                    numeric_eigenstate_max_energy=10 * eV,
                    numeric_eigenstate_max_angular_momentum=0,
                    store_data_every=0,
                    dr=r_bound / r_points,
                    dt=time_step,
                ))

        sims = si.utils.multi_map(run_spec, specs, processes=6)

        # with open(os.path.join(OUT_DIR, 'ref_info.txt'), mode = 'w') as f:
        #     print(sims[0].info(), file = f)

        # r_points_per_br_set = set(sim.spec.r_points_per_br for sim in sims)
        # time_steps_set = set(sim.spec.dt for sim in sims)
Exemplo n.º 29
0
                            plot_limit=30 * bohr_radius,
                        ),
                        src.ionization.animators.SphericalHarmonicAnimator(
                            postfix="100",
                            target_dir=OUT_DIR,
                            plot_limit=100 * bohr_radius,
                        ),
                    ]
                    spec = ion.SphericalHarmonicSpecification(
                        prefix + "harm_CN_4",
                        time_initial=t_init,
                        time_final=t_final,
                        time_step=dt,
                        r_bound=bound * bohr_radius,
                        r_points=bound * 4,
                        l_bound=angular_points,
                        initial_state=state,
                        internal_potential=internal_potential,
                        electric_potential=e_field,
                        animators=animators,
                        mask=mask,
                        evolution_method="CN",
                    )
                    specs.append(spec)

                    spec = ion.SphericalHarmonicSpecification(
                        prefix + "harm_SO_4",
                        time_initial=t_init,
                        time_final=t_final,
                        time_step=dt,
                        r_bound=bound * bohr_radius,
Exemplo n.º 30
0
        pulse = ion.potentials.SincPulse(
            pulse_width=pw,
            fluence=1 * Jcm2,
            window=ion.potentials.LogisticWindow(window_time=30 * pw,
                                                 window_width=0.2 * pw),
        )

        sim = ion.SphericalHarmonicSpecification(
            "very_long_pulse",
            r_bound=200 * bohr_radius,
            r_points=1000,
            l_bound=400,
            mask=ion.RadialCosineMask(inner_radius=80 * bohr_radius,
                                      outer_radius=100 * bohr_radius),
            time_initial=-32 * pw,
            time_final=32 * pw,
            time_step=dt,
            electric_potential=pulse,
            use_numeric_eigenstates=True,
            numeric_eigenstate_max_energy=10 * eV,
            numeric_eigenstate_max_angular_momentum=10,
            electric_potential_dc_correction=True,
            store_data_every=20,
        ).to_sim()

        sim.info().log()

        si.vis.xy_plot(
            "efield_vs_time",
            sim.times,
            sim.spec.electric_potential.get_electric_field_amplitude(