General setup class
- class ulula.setup_base.Setup(unit_l=1.0, unit_t=1.0, unit_m=1.0)
General setup class
This abstract container must be partially overwritten by child classes, but also contains defaults for a number of standard routines. In particular, the user must implement the routines that provide a short name and that set the initial conditions.
Some optionally overwritten routines determine how plots look and are automatically passed to the plotting functions when using the
run()
function.- Parameters:
- unit_l: float
Code unit for length in units of centimeters.
- unit_t: float
Code unit for time in units of seconds.
- unit_m: float
Code unit for mass in units of gram.
Methods
initialConditions
(sim, nx)Wrapper function to set initial data
internalEnergyFromTemperature
(T, mu, gamma)Conversion for isothermal EOS
plotColorMaps
(q_plot)Return colormaps for plotted quantities
plotLimits
(q_plot)Return min/max limits for plotted quantities
setInitialData
(sim, nx)Set the initial conditions (must be overwritten)
Short name for the problem (to be used in output filenames)
trueSolution
(sim, x, q_plot)Return a true solution for this setup
- abstract shortName()
Short name for the problem (to be used in output filenames)
- initialConditions(sim, nx)
Wrapper function to set initial data
This function calls the problem-specific setup, which is assumed to set the primitive variables. Those are also converted to conserved variables.
- Parameters:
- sim: Simulation
Simulation object in which the ICs are to be set
- nx: int
Number of cells in the x-direction
- abstract setInitialData(sim, nx)
Set the initial conditions (must be overwritten)
This function
- Parameters:
- sim: Simulation
Simulation object in which the ICs are to be set
- nx: int
Number of cells in the x-direction
- trueSolution(sim, x, q_plot)
Return a true solution for this setup
This function can be passed to the Ulula 1D plotting routine
plot1d()
. It must return a 2D array, with the solution in primitive variables for a given input vector of coordinates. The solution must be returned in code units.- Parameters:
- sim: Simulation
Simulation object
- x: array_like
The coordinates where the true solution is to be computed.
- q_plot: array_like
List of quantities for which to return the true solution. Quantities are identified via the short strings given in the
fields
dictionary.
- Returns:
- solution: array_like
A 2D array with dimensions (len(q_plot), len(x)) in code units.
- plotLimits(q_plot)
Return min/max limits for plotted quantities
This function can be passed to the Ulula plotting routines. By default, no limits are returned, which means the plotting functions automatically select limits. The limits must be in code units.
- Parameters:
- q_plot: array_like
List of quantities for which to return the plot limits. Quantities are identified via the short strings given in the
fields
dictionary.
- Returns:
- limits_lower: array_like
List of lower limits for the given plot quantities. If
None
, a limit is chosen automatically. Individual items can also beNone
.- limits_upper: array_like
List of upper limits for the given plot quantities. If
None
, a limit is chosen automatically. Individual items can also beNone
.- log: array_like
List of True/False that determine whether to plot in log space. If
None
, all quantities are plotted in linear space. If log is chosen, the limits must be positive.
- plotColorMaps(q_plot)
Return colormaps for plotted quantities
This function can be passed to the Ulula plotting routines. By default, velocities are plotted with a divergent colormap, whereas density and pressure are plotted with a perceptually uniform colormap.
- Parameters:
- q_plot: array_like
List of quantities for which to return the colormaps. Quantities are identified via the short strings given in the
fields
dictionary.
- Returns:
- cmaps: array_like
List of colormaps for the given quantities. If
None
, a colormap is chosen automatically. Individual items can also beNone
.
- internalEnergyFromTemperature(T, mu, gamma)
Conversion for isothermal EOS
If we are choosing an isothermal EOS, we need to pass the temperature in the form of an equivalent internal energy in code units, which can be a little tedious to compute. This function takes care of it. The result can be passed as the
eint_fixed
parameter to thesetEquationOfState()
function.- Parameters:
- T: float
Temperature in Kelvin.
- mu: float
Mean particle weight in proton masses.
- Returns:
- eint: float
Internal energy in code units corresponding to the given temperature.