pyrokinetics.local_species.LocalSpecies#
- class pyrokinetics.local_species.LocalSpecies(*args, **kwargs)[source]#
Bases:
CleverDictDictionary of local species parameters where the key is different species
For example LocalSpecies[‘electron’] contains all the local info for that species in a dictionary
Local parameters are normalised to reference values
name : Name mass : Mass z : Charge dens : Density temp : Temperature omega0 : Angular velocity nu : Collision Frequency
inverse_lt : 1/Lt inverse_ln : 1/Ln domega_drho : Gradient in angular velocity
zeff : Zeff \(\sum_{ions} n_i Z_i^2 / n_e\)
Methods
__init__(*args, **kwargs)add_alias(name, alias)Adds an alias to a given key/name.
add_species(name, species_data[, norms])Adds a new species to LocalSpecies
autosave([fullcopy, silent])Toggles autosave to a config file.
check_if_unallowed_key([mapping, _aliases])check_quasineutrality([tol])Checks quasi-neutrality is satisfied and raises a warning if it is not
clear()convert_physical_units(norms)Convert each species' physical-unit quantities to generic simulation units.
copy()create_save_file()Creates a skeleton file to store autosave data if one doesn't already exist.
delete([name])Called every time a CleverDict key/attribute is deleted.
delete_alias(alias)deletes an alias
enforce_quasineutrality(modify_species)Enforces quasineutrality by adjusting the density and gradient of one species
from_dict(species_dict, **kwargs)Reads local species parameters from a dictionary
from_global_kinetics(kinetics, psi_n, local_norm)from_json([json_data, file_path, ignore, ...])Creates a new CleverDict object and loads data from a JSON object or file.
from_kinetics(kinetics, psi_n, norm)Loads local species data from kinetics object
from_lines([lines, file_path, ...])Creates a new CleverDict object and loads data from a line ('
fromkeys(iterable, value[, ignore, exclude, ...])Instantiates an object using supplied keys/aliases and values e.g.
get(key[, default])Return the value for key if key is in the dictionary, else default.
get_aliases([name])Returns all alliases or aliases for a given name.
get_key(name)Returns the primary key for a given name.
get_new_save_path()Get Operating System specific default for settings folder; Return a (hopefully) unique filename comprising time and variable name
info([as_str, ignore, exclude, only])Prints or returns a string showing variable name equivalence and object attribute/dictionary key equivalence.
items()keys()merge_species(base_species, merge_species[, ...])Merge multiple species into one.
normalise([norms, context])Normalise to pyrokinetics normalisations and calculate total pressure gradient
original_delete([name])Called every time a CleverDict key/attribute is deleted.
original_save([name, value])Called every time a CleverDict value is created or change.
pop(k[,d])If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem()Remove and return a (key, value) pair as a 2-tuple.
remove_species(*names)Removes a species from the LocalSpecies
save([name, value])Called every time a CleverDict value is created or change.
set_autodelete([deletefunc])Overwrites the default (inactive) delete method of an instance with a new custom function.
set_autosave([savefunc])Overwrites the default (dummy) save method of an instance with a new custom function.
set_zeff()Calculates Z_eff from the kinetics object
setattr_direct(name, value)Sets an attribute directly, i.e. without making it into an item.
setdefault(key[, default])Insert key with a value of default if key is not in the dictionary.
to(norms[, context])Thin wrapper for normalise
to_dict([ignore, exclude, only])Returns a regular dict of the core data dictionary
to_json([file_path, fullcopy, ignore, ...])Generates a JSON formatted string representing the CleverDict data and optionally saves to file.
to_lines([file_path, start_from_key, ...])Creates a line ("
to_list([ignore, exclude, only])Creates a list of k,v pairs as a list of tuples.
update([mapping])update_pressure([norms])Calculate inverse_lp and pressure for species
values()Attributes
expandignore_internals- class SingleLocalSpecies(localspecies, species_dict, norms=None)[source]#
Bases:
objectDictionary of local species parameters for one species
For example SingleLocalSpecies[‘electron’] contains all the local info for that species in a dictionary
Local parameters are normalised to reference values
name : Name mass : Mass z : Charge dens : Density temp : Temperature omega0 : Angular Velocity nu : Collision Frequency
inverse_lt : 1/Lt [units] [1 / lref_minor_radius] inverse_ln : 1/Ln [units] [1 / lref_minor_radius] domega_drho : domega/drho [units] [vref / lref_minor_radius**2]
- Parameters:
norms (SimulationNormalisation | None)
- property dens#
- property domega_drho#
- property inverse_ln#
- property inverse_lt#
- property temp#
- check_quasineutrality(tol=0.01)[source]#
Checks quasi-neutrality is satisfied and raises a warning if it is not
- convert_physical_units(norms)[source]#
Convert each species’ physical-unit quantities to generic simulation units.
- property domega_drho#
- enforce_quasineutrality(modify_species)[source]#
Enforces quasineutrality by adjusting the density and gradient of one species
- Parameters:
modify_species (
str) – Name of species to modify- Raises:
ValueError – If there is no species with given name or the quasineutrality can’t be set with that species for some reason
- Return type:
- classmethod from_global_kinetics(kinetics, psi_n, local_norm)[source]#
- Parameters:
kinetics (Kinetics)
psi_n (float)
local_norm (SimulationNormalisation)
- merge_species(base_species, merge_species, keep_base_species_z=False, keep_base_species_mass=False)[source]#
Merge multiple species into one. Performs a weighted average depending on the densities of each species to preserve quasineutrality.
- Parameters:
base_species (
str) – Names of species that will absorb other speciesmerge_species (
Iterable[str]) – List of species names to be merged into the base_specieskeep_base_species_z (
bool) –- Charge of new species
True preserves base_species charge and adjusts ion density False/None preserves ion density (before/after merge) and adjusts z
keep_base_species_mass (
bool) –- Mass of new species
True keeps base_species mass False/None results in a density-weighted average
- Raises:
ValueError – If there is no species with a given name.
- Return type:
- normalise(norms=None, context=None)[source]#
Normalise to pyrokinetics normalisations and calculate total pressure gradient
- property nspec#
- remove_species(*names)[source]#
Removes a species from the LocalSpecies
- Parameters:
names (
str) – Names of species to remove- Raises:
ValueError – If there is no species with a given name.
- Return type: