Parameters
Parameters to define multi-simulation sweeps.
Parameter
- class onscale.Parameter(name: str, start_val: float | None = None, end_val: float | None = None, steps: int = 1, use_log_scale: bool = False, inverse_log: bool = False, min_val: float | None = None, max_val: float | None = None)
A parameter range that will be used to generate simulation sweeps.
Examples
>>> import onscale as on >>> import numpy as np >>> >>> # Testing >>> with on.Simulation('example') as sim: ... on.Parameter('test-param', 0, 100, 10)
- Parameters:
name – Name for this parameter.
start_val – Start value for the sweep.
end_val – End value for the sweep.
steps – The number of sweep steps between start_val and end_val.
use_log_scale – if true, the logarithmic scale should be used. default to False.
inverse_log – if true, the logarithmic scale is inverse. default to False.
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- sim_count(sim=None) int
Defines how many swept simulations this variable implies
- to_json() str
Convert this node into JSON representation
- to_list() List[float]
Return enumerated values of this parameter
- property uuid: str
Get the UUID associated with this node.
CustomParameter
- class onscale.CustomParameter(name: str, values: List[float] | ndarray)
User-defined array of values to use for parametric sweep.
- Parameters:
name – Name for this parameter.
values – A 1D array-like object enumerating values to sweep.
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- sim_count(sim=None) int
Defines how many swept simulations this variable implies
- to_json() str
Convert this node into JSON representation
- to_list() List[float]
Return enumerated values of this parameter
- property uuid: str
Get the UUID associated with this node.
ParameterGroup
- class onscale.ParameterGroup(alias: str | None = None)
A group of parameter values. Parameters can only belong to 1 group.
The purpose of a ParameterGroup is to iterate over multiple parameters together, instead of taking all possible combinations of them.
All parameters have a “sim_count”, indicating how many simulations will be generated from them. If multiple parameters are defined in a simulation, the resulting sweep will have the product of all parameter “sim_count” number of simulations. If multiple parameter are defined in a ParameterGroup, then all of those parameters must have the same “sim_count”, and the resulting sweep will have that “sim_count” number of simulations.
- Parameters:
alias – Optional alias for this node.
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.
- onscale.parametrize(*args: List[float] | ndarray) List[CustomParameter]
Create a series of grouped parameters from arrays of values.
Examples
>>> import numpy as np >>> import onscale as on >>> >>> # Sweep a force vector 360deg around the z-axis over 20 sims >>> with on.Simulation('example') as sim: ... theta = np.linspace(0, 2 * np.pi, 20) ... x = np.cos(theta) ... y = np.sin(theta) ... z = np.zeros(len(x)) ... x, y, z = on.parametrize(x, y, z) ... force = on.loads.Force(250, [x, y, z])
- Parameters:
args – A series of array-like objects. All of these arrays must have the same length.
- Returns:
- A list of CustomParameter objects, all grouped together. Returns
one CustomParameter object for each array given.