def __init__(self, composition, name=None, density_kg_m3=None, absorption_energy_eV=None, elastic_scattering=(0.0, 0.0), cutoff_energy_inelastic_eV=50.0, cutoff_energy_bremsstrahlung_eV=50.0, interaction_forcings=None, maximum_step_length_m=1e15, *args, **kwargs): """ Creates a new material. :arg name: name of the material :type name: :class:`str` :arg composition: composition in weight fraction. The composition is specified by a list of tuples. The first element of each tuple can either be the atomic number or the symbol of the element. It will automatically be converted to the atomic number. The second is the weight fraction between ]0.0, 1.0] or ``?`` indicating that the weight fraction is unknown and shall be automatically calculated to make the total weight fraction equal to 1.0. :type composition: :class:`list` :arg density_kg_m3: material's density in kg/m3. If the density is ``None`` or less than 0 (default), it will be automatically calculated based on the density of the elements and their weight fraction. :type density_kg_m3: :class:`float` :arg elastic_scattering: elastic scattering coefficients. They can either be specified as a :class:`tuple`: ``(C1, C2)`` or as a single :class:`float` value, where ``C1=C2``. The value of C1 or C2 must be between 0.0 and 0.2 inclusively. :type elastic_scattering: :class:`tuple` or :class:`float` :arg cutoff_energy_inelastic_eV: cutoff energy for inelastic collisions (in eV). :arg cutoff_energy_bremsstrahlung_eV: cutoff energy for Bremsstrahlung emission (in eV). :arg interaction_forcings: interaction forcing(s) :arg maximum_step_length_m: maximum length of an electron trajectory """ _Material.__init__(self, composition, name, density_kg_m3, absorption_energy_eV) elastic_scattering = ElasticScattering(*elastic_scattering) if elastic_scattering.c1 < 0.0 or elastic_scattering.c1 > 0.2: raise ValueError('C1 must be between [0.0, 0.2]') if elastic_scattering.c2 < 0.0 or elastic_scattering.c2 > 0.2: raise ValueError('C2 must be between [0.0, 0.2]') self._elastic_scattering = elastic_scattering if cutoff_energy_inelastic_eV < 0.0: raise ValueError( 'Cutoff energy for inelastic collisions must be greater or equal to 0.0' ) self._cutoff_energy_inelastic_eV = cutoff_energy_inelastic_eV if cutoff_energy_inelastic_eV < 0.0: raise ValueError( 'Cutoff energy for Bremsstrahlung emission must be greater or equal to 0.0' ) self._cutoff_energy_bremsstrahlung_eV = cutoff_energy_bremsstrahlung_eV if interaction_forcings is None: interaction_forcings = set() self._interaction_forcings = frozenset(interaction_forcings) if maximum_step_length_m < 0.0: raise ValueError("Length must be greater than 0.0") if maximum_step_length_m > 1e20: warnings.warn('Maximum step length set to maximum value: 1e20') maximum_step_length_m = 1e20 self._maximum_step_length_m = maximum_step_length_m
def __init__(self, composition, name=None, density_kg_m3=None, absorption_energy_eV=None, elastic_scattering=(0.0, 0.0), cutoff_energy_inelastic_eV=50.0, cutoff_energy_bremsstrahlung_eV=50.0, interaction_forcings=None, maximum_step_length_m=1e15, *args, **kwargs): """ Creates a new material. :arg name: name of the material :type name: :class:`str` :arg composition: composition in weight fraction. The composition is specified by a list of tuples. The first element of each tuple can either be the atomic number or the symbol of the element. It will automatically be converted to the atomic number. The second is the weight fraction between ]0.0, 1.0] or ``?`` indicating that the weight fraction is unknown and shall be automatically calculated to make the total weight fraction equal to 1.0. :type composition: :class:`list` :arg density_kg_m3: material's density in kg/m3. If the density is ``None`` or less than 0 (default), it will be automatically calculated based on the density of the elements and their weight fraction. :type density_kg_m3: :class:`float` :arg elastic_scattering: elastic scattering coefficients. They can either be specified as a :class:`tuple`: ``(C1, C2)`` or as a single :class:`float` value, where ``C1=C2``. The value of C1 or C2 must be between 0.0 and 0.2 inclusively. :type elastic_scattering: :class:`tuple` or :class:`float` :arg cutoff_energy_inelastic_eV: cutoff energy for inelastic collisions (in eV). :arg cutoff_energy_bremsstrahlung_eV: cutoff energy for Bremsstrahlung emission (in eV). :arg interaction_forcings: interaction forcing(s) :arg maximum_step_length_m: maximum length of an electron trajectory """ _Material.__init__(self, composition, name, density_kg_m3, absorption_energy_eV) elastic_scattering = ElasticScattering(*elastic_scattering) if elastic_scattering.c1 < 0.0 or elastic_scattering.c1 > 0.2: raise ValueError('C1 must be between [0.0, 0.2]') if elastic_scattering.c2 < 0.0 or elastic_scattering.c2 > 0.2: raise ValueError('C2 must be between [0.0, 0.2]') self._elastic_scattering = elastic_scattering if cutoff_energy_inelastic_eV < 0.0: raise ValueError('Cutoff energy for inelastic collisions must be greater or equal to 0.0') self._cutoff_energy_inelastic_eV = cutoff_energy_inelastic_eV if cutoff_energy_inelastic_eV < 0.0: raise ValueError('Cutoff energy for Bremsstrahlung emission must be greater or equal to 0.0') self._cutoff_energy_bremsstrahlung_eV = cutoff_energy_bremsstrahlung_eV if interaction_forcings is None: interaction_forcings = set() self._interaction_forcings = frozenset(interaction_forcings) if maximum_step_length_m < 0.0: raise ValueError("Length must be greater than 0.0") if maximum_step_length_m > 1e20: warnings.warn('Maximum step length set to maximum value: 1e20') maximum_step_length_m = 1e20 self._maximum_step_length_m = maximum_step_length_m