pyrokinetics.local_species.LocalSpecies#
- class pyrokinetics.local_species.LocalSpecies(*args, **kwargs)[source]#
Bases:
CleverDict
Dictionary 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
()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
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])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 key is not found, default is returned if given, otherwise KeyError is raised
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_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])- param The same as dict.update():
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
update_pressure
([norms])Calculate inverse_lp and pressure for species
values
()Attributes
expand
ignore_internals
- class SingleLocalSpecies(localspecies, species_dict, norms=None)[source]#
Bases:
object
Dictionary 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
- property domega_drho#
- 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)[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: