Internal API of Parameters#

See also

Tutorial on FluidDyn’s ParamContainer API and documentation of fluiddyn.util.paramcontainer.ParamContainer which is extended for Snek5000.

The function fluidsim_core.params.iter_complete_params() also comes in handy while building default Parameters.

Conversion#

snek5000.params._as_nek_value(input_value)[source]#

Convert Python values to equivalent Nek5000 par values.

snek5000.params._as_python_value(input_value)[source]#

Convert Nek5000 par values to equivalent Python values if possible.

snek5000.params._get_params_nek(params)[source]#

Check if params is the top level object (via the _tag attribute) and return the params.nek object.

Parameters

params (Parameters) – The params object

Returns

params.nek – The params.nek object

Return type

Parameters

Inspection#

snek5000.params._check_path_like(path)[source]#

Ensure input is a path-like object

snek5000.params._check_user_param_index(idx)[source]#

Check if the index of user parameter is within bounds

Input / Output#

snek5000.params._complete_params_from_xml_file(params, path_xml)[source]#

Populate the params.nek object by reading a .xml file and filename_map_user_params.

snek5000.params._save_recorded_user_params(user_params, path_dir)[source]#

Save a JSON file from a dictionary denoting user_params

snek5000.params._load_recorded_user_params(path)[source]#

Load a JSON file and return a dictionary denoting user_params

snek5000.params._save_par_file(params, path, mode='w')[source]#

Save the params.nek object as a .par file.

snek5000.params._str_par_file(params)[source]#

Preview contents of the resulting .par file as a string

Parameters class internals#

class snek5000.params.Parameters(*args, **kwargs)[source]

Container for reading, modifying and writing par files.

Parameters

tag – A string representing name of case files (for example: provide "abl" for files like abl.usr, abl.par etc).

classmethod _load_params_simul(path=None)[source]

Alias for load_params()

_make_dict_attribs()[source]
__update_par_section(section_name, section_dict, has_to_prune_literals=True)

Updates a section of the par_file object from a dictionary.

_sync_par(has_to_prune_literals=True, keep_all_sections=False)[source]

Sync values in param children and attributes to self._par_file object.

__tidy_par(keep_all_sections=False)

Remove internal attributes and disabled sections from par file.

_autodoc_par(indent=0)[source]

Autodoc a code block with ini syntax and set docstring.

_record_nek_user_params(nek_params_keys, overwrite=False)[source]

Record some Nek user parameters

Examples

>>> params._record_nek_user_params({"prandtl": 2, "rayleigh": 3})
>>> params.output.history_points._record_nek_user_params({"write_interval": 4})

This is going to set or modify the internal attribute params.nek.general._recorded_user_params to {2: "prandtl", 3: "rayleigh", 4: "output.other.write_interval"}.

This attribute is then used to write the [GENERAL] section of the .par file.

Note that this attribute is only for params.nek.general and should never be set for other parameter children.

_change_index_userparams(user_params)[source]

Change indices for user parameters

This method can be used in the create_default_params class method of a solver to overwrite the default indices used in the base snek5000 package.

This method checks that no already recorded parameters are overwritten. To overwrite a parameter, use _record_nek_user_params with the overwrite argument.

Examples

>>> params._change_index_userparams({8: "output.history_points.write_interval"}
_save_as_xml(path_file=None, comment=None, find_new_name=False)[source]

Invoke _save_recorded_user_params() and then save to an XML file at path_file.

_as_code()
_contains_doc()
classmethod _create_params(input_info_solver)[source]

Create a Parameters instance from an InfoSolverCore instance.

_get_formatted_doc()
_get_formatted_docs()
_get_key_attribs()
_load_from_elemxml(elemxml)
_load_from_hdf5_file(path_file)
_load_from_hdf5_object(hdf5_object)
_load_from_xml_file(path_file)
classmethod _load_info_solver(path_dir=None)[source]

Load the solver information, return an InfoSolverCore instance.

_make_dict()
_make_dict_tree()

A tree-like nested dictionary, including attributes and children.

_make_element_xml(parentxml=None)
_make_full_tag()
_make_xml_text()

Produce and return a xml text representing the container.

_modif_from_other_params(params)

Modify the object with another similar container.

_pop_attrib(name)
_print_as_code()
_print_as_xml()

Print the xml text representing the container.

_print_doc()
_print_docs()
_repr_json_()
_save_as_hdf5(path_file=None, hdf5_object=None, hdf5_parent=None, invalid_netcdf=False)

Save in a hdf5 file.

_set_as_child(child, change_parent=True)

Associate a ParamContainer as a child.

_set_attrib(key, value)

Add an attribute to the container.

_set_attribs(d)

Add the attributes to the container.

_set_child(tag, attribs=None, doc=None)

Add a child (of the same class) to the container.

_set_doc(doc)
_set_internal_attr(key, value)