Exemplo n.º 1
0
 def add_species(self, species, layout, initialize_self_field=False):
     # Call method of parent class
     PICMI_Simulation.add_species(self, species, layout,
                                  initialize_self_field)
     # Call generic method internally
     self._add_species_generic(species,
                               layout,
                               injection_plane_position=None,
                               injection_plane_normal_vector=None,
                               initialize_self_field=initialize_self_field)
Exemplo n.º 2
0
    def add_species(self, species, layout, initialize_self_field=False):
        # Call method of parent class
        PICMI_Simulation.add_species(self, species, layout,
                                     initialize_self_field)

        # Extract list of species
        if type(species) == PICMI_Species:
            species_instances_list = [species]
        elif type(species) == PICMI_MultiSpecies:
            species_instances_list = species.species_instances_list
        else:
            raise ValueError('Unknown type: %s' % type(species))

        # Loop over species and create FBPIC species
        for s in species_instances_list:

            # Get their charge and mass
            if s.particle_type is not None:
                s.charge = particle_charge[s.particle_type]
                s.mass = particle_mass[s.particle_type]
            # If `charge_state` is set, redefine the charge and mass
            if s.charge_state is not None:
                s.charge = s.charge_state * e
                s.mass -= s.charge_state * m_e

            # Add the species to the FBPIC simulation
            fbpic_species = self._create_new_fbpic_species(
                s, layout, initialize_self_field)

            # Register a pointer to the FBPIC species in the PICMI species itself
            # (Useful for particle diagnostics later on)
            s.fbpic_species = fbpic_species

        # Loop over species and handle ionization
        for s in species_instances_list:
            for interaction in s.interactions:
                assert interaction[0] == 'ionization'
                assert interaction[1] == 'ADK'
                picmi_target = interaction[2]
                if not hasattr(picmi_target, 'fbpic_species'):
                    raise RuntimeError(
                        'For ionization with PICMI+FBPIC:\n'
                        'You need to add the target species to the simulation,'
                        ' before the other species.')
                fbpic_target = picmi_target.fbpic_species
                fbpic_source = s.fbpic_species
                fbpic_source.make_ionizable(element=s.particle_type,
                                            level_start=s.charge_state,
                                            target_species=fbpic_target)