utils
moment_kinetics.utils
— ModuleUtility functions
moment_kinetics.utils.enum_from_string
— Methodenum_from_string(enum_type, name)
Get an the value of enum_type
, whose name is given by the String (or Symbol) name
.
Returns nothing
if the name is not found.
moment_kinetics.utils.get_CFL
— Functionget_CFL!(CFL, speed, coord)
Calculate the CFL factor 'speed/(grid spacing)' (with no prefactor) corresponding to advection speed speed
for advection. Note that moment_kinetics is set up so that dimension in which advection happens is the first dimension of speed
- coord
is the coordinate corresponding to this dimension.
The result is written in CFL
. This function is only intended to be used in post-processing.
moment_kinetics.utils.get_backup_filename
— MethodAppend a number to the filename, to get a new, non-existing filename to backup the file to.
moment_kinetics.utils.get_default_restart_filename
— Methodget_default_restart_filename(io_input, prefix; error_if_no_file_found=true)
Get the default name for the file to restart from, using the input from io_input
.
prefix
gives the type of file to open, e.g. "moments", "dfns", or "initial_electron".
If no matching file is found, raise an error unless error_if_no_file_found=false
is passed, in which case no error is raised and instead the function returns nothing
.
moment_kinetics.utils.get_minimum_CFL_neutral_vz
— Methodget_minimum_CFL_neutral_vz(speed, vz)
Calculate the minimum (over a shared-memory block) of the CFL factor 'speed/(grid spacing)' (with no prefactor) corresponding to advection speed speed
for advection of neutrals in the vz direction.
Reduces the result over the shared-memory block (handling distributed parallelism is left to the calling site). The result is only to be used on rank-0 of the shared-memory block.
moment_kinetics.utils.get_minimum_CFL_neutral_z
— Methodget_minimum_CFL_neutral_z(speed, z)
Calculate the minimum (over a shared-memory block) of the CFL factor 'speed/(grid spacing)' (with no prefactor) corresponding to advection speed speed
for advection of neutrals in the z direction.
Reduces the result over the shared-memory block (handling distributed parallelism is left to the calling site). The result is only to be used on rank-0 of the shared-memory block.
moment_kinetics.utils.get_minimum_CFL_vpa
— Methodget_minimum_CFL_vpa(speed, vpa)
Calculate the minimum (over a shared-memory block) of the CFL factor 'speed/(grid spacing)' (with no prefactor) corresponding to advection speed speed
for advection in the vpa direction.
Reduces the result over the shared-memory block (handling distributed parallelism is left to the calling site). The result is only to be used on rank-0 of the shared-memory block.
moment_kinetics.utils.get_minimum_CFL_z
— Methodget_minimum_CFL_z(speed, z)
Calculate the minimum (over a shared-memory block) of the CFL factor 'speed/(grid spacing)' (with no prefactor) corresponding to advection speed speed
for advection in the z direction.
Reduces the result over the shared-memory block (handling distributed parallelism is left to the calling site). The result is only to be used on rank-0 of the shared-memory block.
moment_kinetics.utils.get_prefix_iblock_and_move_existing_file
— Methodget_prefix_iblock_and_move_existing_file(restart_filename, output_dir)
Move restart_filename
to a backup location (if it is in output_dir
), returning a prefix and block-index (which might be nothing
) which can be used to open the file for reloading variables.
moment_kinetics.utils.get_unnormalized_parameters
— Functionget_unnormalized_parameters(input::AbstractDict)
get_unnormalized_parameters(input_filename::String)
Get many parameters for the simulation setup given by input
or in the file input_filename
, in SI units and eV, returned as an OrderedDict.
moment_kinetics.utils.merge_dict_with_kwargs!
— MethodDict merge function for named keyword arguments for case when input AbstractDict is a mixed AbstractDict of AbstractDicts and non-AbstractDict float/int/string entries, and the keyword arguments are also a mix of AbstractDicts and non-AbstractDicts
moment_kinetics.utils.print_unnormalized_parameters
— Methodprint_unnormalized_parameters(input)
Print many parameters for the simulation setup given by input
(an AbstractDict of parameters or a String giving a filename), in SI units and eV.
moment_kinetics.utils.recursive_merge
— Functionrecursive_merge(a, b)
Merge two AbstractDicts a
and b
. Any elements that are AbstractDicts are also merged (rather than just replacing with the entry in b
).
moment_kinetics.utils.to_hours
— Methodto_hours(x::T) where {T<:TimePeriod}
Convert a time period x
to seconds
moment_kinetics.utils.to_minutes
— Methodto_minutes(x::T) where {T<:TimePeriod}
Convert a time period x
to seconds
moment_kinetics.utils.to_seconds
— Methodto_seconds(x::T) where {T<:TimePeriod}
Convert a time period x
to seconds