pylbo.gimli.amrvac
Classes
Class to prepare Legolas data for use in MPI-AMRVAC (https://amrvac.org). |
Functions
|
Writes a subroutine where all equilibrium functions are defined for reuse |
|
|
|
|
|
|
|
Module Contents
- pylbo.gimli.amrvac.write_equilibrium_functions(file, eq, to_fetch_total, to_fetch_split)
Writes a subroutine where all equilibrium functions are defined for reuse in other routines. `get_equilibrium’ then returns the total equilibrium functions plus the current if needed (if not, this part of the array is zero).
- Parameters:
file (file) – The file object to write to.
eq (Equilibrium) – The equilibrium object containing the user-defined equilibria.
to_fetch_total (list) – The list of equilibrium functions to write to the file.
to_fetch_split (list) – The list of split equilibrium functions to write to the file.
- pylbo.gimli.amrvac.write_split_equilibrium_functions(file, to_fetch, field)
- pylbo.gimli.amrvac.write_physics_pointers(file, eq)
- pylbo.gimli.amrvac.write_physics_subroutines(file, eq)
- pylbo.gimli.amrvac.get_code_expression(expr, translation, assign)
- class pylbo.gimli.amrvac.Amrvac(config)
Class to prepare Legolas data for use in MPI-AMRVAC (https://amrvac.org).
- Parameters:
config (dict) – The configuration dictionary detailing everything needed for the desired functionalities.
- config
- _validate_config()
Validates the presence and value of physics_type in the configuration dictionary.
- Raises:
KeyError – If physics_type is missing.
ValueError – If physics_type is invalid.
- _validate_datfile()
Validates whether a valid Legolas data file was specified in the configuration. Further checks whether all necessary parameters are present in the configuration to prepare Legolas data for use with MPI-AMRVAC.
- Raises:
AssertionError – If the length of weights is not equal to the number of eigenvalues or if the elements of the weights do not add up to 1; if ef_factor does not have modulus 1; if norm_range does not have length 2; if norm_range’s first element is larger than the second.
KeyError – If no datfile is specified; if no initial guess for the eigenvalue is specified.
TypeError – If ev_guess is not a single float/complex number or a list/NumPy array of float/complex numbers; if weights is not a list or NumPy array; if ef_factor is not a list with length equal to the number of eigenvalues, or an integer, float, or complex number; if quantity is not a string; if percentage is not a float; if norm_range is not a NumPy array.
ValueError – If quantity is not in the list of equilibrium quantities.
Exception – If the datfile is invalid.
- _validate_config_for_mod_usr()
Validates whether the configuration dictionary contains all the arguments to generate a mod_usr.t file for use with MPI-AMRVAC.
- _validate_simulation_dict()
- _get_combined_perturbation(ef, clean=True)
Takes Legolas’s perturbations of different eigenvalues and adds them up to a single perturbation.
- Parameters:
ef (str) – The eigenfunction to combine.
- Returns:
The combined perturbation.
- Return type:
np.ndarray
- _get_total_perturbation(ef_type, clean=True)
Combines the perturbations of different eigenvalues into a single perturbation. Derives the pressure perturbation from the density and temperature perturbations.
- Parameters:
ef_type (str) – The eigenfunction to calculate.
- Returns:
The total perturbation.
- Return type:
np.ndarray
- _integrate_energy_term(array, order)
- _get_ef_normalisation(clean=True)
Normalises the perturbation of the specified quantity by the maximum background value.
- Returns:
The normalisation factor.
- Return type:
- _get_energy_normalisation(clean=True)
Normalises the perturbation eigenfunctions by the energy.
- Returns:
The normalisation factor.
- Return type:
- _get_normalisation(clean=True)
Selects which procedure to follow for the normalisation.
- Returns:
The normalisation factor.
- Return type:
- _check_physical_perturbation(ef_name, pert)
- prepare_legolas_data(name=None, loc=None, clean=True)
Prepares a file (.ldat) from the Legolas data for use with MPI-AMRVAC.
- Parameters:
- Raises:
ValueError – If the datfile is invalid.
Examples
>>> from pylbo.gimli import Amrvac >>> amrvac_config = { >>> "datfile": "./datfile.dat", >>> "physics_type": "mhd", >>> "ev_guess": [-0.1, 0.1], >>> "percentage": 0.01, >>> "quantity": "rho0" >>> } >>> amrvac = gimli.Amrvac(amrvac_config) >>> amrvac.prepare_legolas_data()
- user_module(filename='mod_usr', loc=None)
Writes the user module for MPI-AMRVAC.
- parfile(basename='amrvac_config', loc=None, subdir=True, prefix_numbers=False, nb_prefix_digits=4)
Generates parfiles based on the parfile dictionary. The separate namelists do not have to be taken into account, and a normal dictionary should be supplied where the keys correspond to the namelist items that are required. Typechecking is done automatically during parfile generation.
- Parameters:
basename (str) – The basename for the parfile, the .par suffix is added automatically and is not needed. If multiple parfiles are generated, these will be prepended by a 4-digit number (e.g. 0003myparfile.par). If not provided, the basename will default to amrvac_config.
output_dir (str, PathLike) – Output directory where the parfiles are saved, defaults to the current working directory if not specified. A subdirectory called parfiles will be created in which the parfiles will be saved.
subdir (boolean) – If True (default), creates a subdirectory parfiles in the output folder.
prefix_numbers (boolean) – If True prepends the basename by a n-digit number (e.g. xxxxmyparfile.par). The number of digits is specified by nb_prefix_digits.
nb_prefix_digits (int) – Number of digits to prepend to the basename if prefix_numbers is True. Defaults to 4.
- Returns:
parfiles – A list with the paths to the parfiles that were generated.
- Return type: