Esempio n. 1
0
 def init_solver(self):
     logger.info("### Init Diode Solver Setup ###")
     if self.DIRECT_SOLVER:
         if self.dim == 1:
             raise NotImplementedError(
                 "Direct 1D solving is not yet implemented in mewarpx")
             # self.solver = poisson1d.PoissonSolver1D()
         elif self.dim == 2:
             if self.rz:
                 raise NotImplementedError(
                     "Direct RZ solving is not yet implemented in mewarpx")
             self.solver = poisson_solvers.PoissonSolverPseudo1D(
                 grid=mwxrun.grid
             )
     else:
         self.solver = picmi.ElectrostaticSolver(
             grid=mwxrun.grid,
             method='Multigrid',
             required_precision=1e-6,
             maximum_iterations=10000
         )
     self.solver.self_fields_verbosity = 2 if self.NONINTERAC else 0
Esempio n. 2
0
    number_of_cells = [nx, ny],
    lower_bound = [xmin, ymin],
    upper_bound = [xmax, ymax],
    bc_xmin = 'dirichlet',
    bc_xmax = 'dirichlet',
    bc_ymin = 'periodic',
    bc_ymax = 'periodic',
    warpx_potential_hi_x = "%.1f*sin(2*pi*%.5e*t)" % (VOLTAGE, FREQ),
    lower_boundary_conditions_particles=['absorbing', 'periodic'],
    upper_boundary_conditions_particles=['absorbing', 'periodic'],
    moving_window_velocity = None,
    warpx_max_grid_size = nx//4
)

solver = picmi.ElectrostaticSolver(
    grid=grid, method='Multigrid', required_precision=1e-6
)

##########################
# diagnostics
##########################

field_diag = picmi.FieldDiagnostic(
    name = 'diag1',
    grid = grid,
    period = diagnostic_intervals,
    data_list = ['rho_electrons', 'rho_he_ions', 'phi'],
    write_dir = '.',
    warpx_file_prefix = 'Python_background_mcc_plt'
)
Esempio n. 3
0
##########################

grid = picmi.Cartesian2DGrid(
    number_of_cells = [nx, ny],
    lower_bound = [xmin, ymin],
    upper_bound = [xmax, ymax],
    lower_boundary_conditions = ['dirichlet', 'periodic'],
    upper_boundary_conditions = ['dirichlet', 'periodic'],
    lower_boundary_conditions_particles = ['absorbing', 'periodic'],
    upper_boundary_conditions_particles = ['absorbing', 'periodic'],
    moving_window_velocity = None,
    warpx_max_grid_size = 32
)

solver = picmi.ElectrostaticSolver(
    grid=grid, method='Multigrid', required_precision=1e-6,
    warpx_self_fields_verbosity=0
)

##########################
# physics components
##########################

electrons = picmi.Species(
    particle_type='electron', name='electrons'
)

##########################
# diagnostics
##########################

field_diag = picmi.FieldDiagnostic(
Esempio n. 4
0
    def setup_run(self):
        """Setup simulation components."""

        #######################################################################
        # Set geometry and boundary conditions                                #
        #######################################################################

        self.grid = picmi.Cartesian1DGrid(
            number_of_cells=[self.nz],
            warpx_max_grid_size=128,
            lower_bound=[0],
            upper_bound=[self.gap],
            lower_boundary_conditions=['dirichlet'],
            upper_boundary_conditions=['dirichlet'],
            lower_boundary_conditions_particles=['absorbing'],
            upper_boundary_conditions_particles=['absorbing'],
            warpx_potential_hi_z=self.voltage,
        )

        #######################################################################
        # Field solver                                                        #
        #######################################################################

        self.solver = picmi.ElectrostaticSolver(grid=self.grid,
                                                method='Multigrid',
                                                required_precision=1e-12,
                                                warpx_self_fields_verbosity=0)

        #######################################################################
        # Particle types setup                                                #
        #######################################################################

        self.electrons = picmi.Species(
            particle_type='electron',
            name='electrons',
            initial_distribution=picmi.UniformDistribution(
                density=self.plasma_density,
                rms_velocity=[
                    np.sqrt(constants.kb * self.elec_temp / constants.m_e)
                ] * 3,
            ))
        self.ions = picmi.Species(
            particle_type='He',
            name='he_ions',
            charge='q_e',
            mass=self.m_ion,
            initial_distribution=picmi.UniformDistribution(
                density=self.plasma_density,
                rms_velocity=[
                    np.sqrt(constants.kb * self.gas_temp / self.m_ion)
                ] * 3,
            ))

        #######################################################################
        # Collision  initialization                                           #
        #######################################################################

        cross_sec_direc = '../../../../warpx-data/MCC_cross_sections/He/'
        mcc_electrons = picmi.MCCCollisions(
            name='coll_elec',
            species=self.electrons,
            background_density=self.gas_density,
            background_temperature=self.gas_temp,
            background_mass=self.ions.mass,
            scattering_processes={
                'elastic': {
                    'cross_section':
                    cross_sec_direc + 'electron_scattering.dat'
                },
                'excitation1': {
                    'cross_section': cross_sec_direc + 'excitation_1.dat',
                    'energy': 19.82
                },
                'excitation2': {
                    'cross_section': cross_sec_direc + 'excitation_2.dat',
                    'energy': 20.61
                },
                'ionization': {
                    'cross_section': cross_sec_direc + 'ionization.dat',
                    'energy': 24.55,
                    'species': self.ions
                },
            })

        mcc_ions = picmi.MCCCollisions(
            name='coll_ion',
            species=self.ions,
            background_density=self.gas_density,
            background_temperature=self.gas_temp,
            scattering_processes={
                'elastic': {
                    'cross_section': cross_sec_direc + 'ion_scattering.dat'
                },
                'back': {
                    'cross_section': cross_sec_direc + 'ion_back_scatter.dat'
                },
                # 'charge_exchange' : {
                #    'cross_section' : cross_sec_direc+'charge_exchange.dat'
                # }
            })

        #######################################################################
        # Initialize simulation                                               #
        #######################################################################

        self.sim = picmi.Simulation(
            solver=self.solver,
            time_step_size=self.dt,
            max_steps=self.max_steps,
            warpx_collisions=[mcc_electrons, mcc_ions],
            warpx_load_balance_intervals=self.max_steps // 5000,
            verbose=self.test)

        self.sim.add_species(self.electrons,
                             layout=picmi.GriddedLayout(
                                 n_macroparticle_per_cell=[self.seed_nppc],
                                 grid=self.grid))
        self.sim.add_species(self.ions,
                             layout=picmi.GriddedLayout(
                                 n_macroparticle_per_cell=[self.seed_nppc],
                                 grid=self.grid))

        #######################################################################
        # Add diagnostics for the CI test to be happy                         #
        #######################################################################

        field_diag = picmi.FieldDiagnostic(
            name='diag1',
            grid=self.grid,
            period=0,
            data_list=['rho_electrons', 'rho_he_ions'],
            write_dir='.',
            warpx_file_prefix='Python_background_mcc_1d_plt')
        self.sim.add_diagnostic(field_diag)
Esempio n. 5
0
    def setup_run(self):

        self.rmax = 1e-3
        self.rmin = self.rmax - self.D_CA - self.USE_EB * 10e-6
        self.zmax = (self.rmax - self.rmin) / self.NR * self.NZ / 2.0
        self.zmin = -self.zmax

        self.V_ANODE = self.V_CATHODE + self.V_ANODE_CATHODE

        if self.DIAG_STEPS is None:
            self.DIAG_STEPS = ((self.TOTAL_TIMESTEPS //
                                5) if self.TOTAL_TIMESTEPS > 10 else
                               self.TOTAL_TIMESTEPS)

        #######################################################################
        # Set geometry, boundary conditions and timestep                      #
        #######################################################################

        mwxrun.init_grid(
            lower_bound=[self.rmin, self.zmin],
            upper_bound=[self.rmax, self.zmax],
            number_of_cells=[self.NR, self.NZ],  # min_tiles=1,
            use_rz=True,
            bc_fields_z_min='periodic',
            bc_fields_z_max='periodic',
            bc_particles_z_min='periodic',
            bc_particles_z_max='periodic',
            bc_fields_r_min='dirichlet',
            bc_fields_r_max='dirichlet',
        )
        mwxrun.init_timestep(DT=self.DT)
        mwxrun.simulation.max_steps = self.TOTAL_TIMESTEPS
        mwxrun.simulation.load_balance_intervals = self.TOTAL_TIMESTEPS // 5000

        #######################################################################
        # Field solver                                                        #
        #######################################################################

        self.solver = picmi.ElectrostaticSolver(grid=mwxrun.grid,
                                                method='Multigrid',
                                                required_precision=1e-6,
                                                warpx_self_fields_verbosity=0,
                                                maximum_iterations=1000)
        mwxrun.simulation.solver = self.solver

        #######################################################################
        # Conductors setup and installation                                   #
        #######################################################################

        self.cathode = assemblies.CylinderZ(V=self.V_CATHODE,
                                            T=self.CATHODE_TEMP,
                                            WF=self.CATHODE_PHI,
                                            name='cathode',
                                            r_outer=self.rmax + 1e-6,
                                            r_inner=self.rmax)
        self.anode = assemblies.CylinderZ(
            V=self.V_ANODE,
            T=self.ANODE_TEMP,
            WF=self.ANODE_PHI,
            name='anode',
            r_outer=(self.rmin if not self.USE_EB else self.rmax - self.D_CA))

        #######################################################################
        # Particle types setup                                                #
        #######################################################################

        self.electrons = mespecies.Species(particle_type='electron',
                                           name='electrons')

        #######################################################################
        # Scraper setup                                                       #
        #######################################################################

        for species in [self.electrons]:
            species.save_particles_at_xhi = 1
            if self.USE_EB:
                species.save_particles_at_eb = 1
            else:
                species.save_particles_at_xlo = 1

        #######################################################################
        # Thermionic emission                                                 #
        #######################################################################

        self.cathode_emitter = emission.ZCylinderEmitter(
            conductor=self.cathode, rdir=-1)
        self.cathode_injector = emission.ThermionicInjector(
            emitter=self.cathode_emitter,
            species=self.electrons,
            A=self.CATHODE_A,
            npart_per_cellstep=self.NPPC,
            use_Schottky=self.USE_SCHOTTKY)

        #######################################################################
        # Clean up and output RunInfo                                         #
        #######################################################################

        runvars = CylinderVacuumTEC.__dict__.copy()
        runvars.update(self.__dict__)

        self.runinfo = runinfo.RunInfo(
            local_vars=runvars,
            electrode_params={
                "CATHODE_A": self.CATHODE_A,
                "CATHODE_TEMP": self.CATHODE_TEMP,
                "CATHODE_PHI": self.CATHODE_PHI,
                "ANODE_PHI": self.ANODE_PHI
            },
            surface_dict={
                'cathode': self.cathode,
                'anode': self.anode
            },
            injector_dict={'cathode': self.cathode_injector},
        )
        # overwrite runinfo area to properly normalize currents
        self.runinfo.area = self.cathode_emitter.area

        #######################################################################
        # Add diagnostics                                                     #
        #######################################################################

        self.text_diag = diags.TextDiag(diag_steps=self.DIAG_STEPS,
                                        preset_string='perfdebug')
        # self.field_diag = diags.FieldDiagnostic(
        #    diag_steps=self.DIAG_STEPS, style='roelof', save_pdf=False
        # )
        self.fluxdiag = diags.FluxDiagnostic(diag_steps=self.DIAG_STEPS,
                                             runinfo=self.runinfo,
                                             check_charge_conservation=False,
                                             overwrite=True)

        #######################################################################
        # Initialize run and print diagnostic info                            #
        #######################################################################

        mwxrun.init_run()