Batch_Simulation#
- class PySeismoSoil.class_batch_simulation.Batch_Simulation(list_of_simulations: list[PySeismoSoil.class_simulation_results.Simulation_Results], use_ctx: bool = False)[source]#
Bases:
object
Run site response simulations in batch.
- Parameters:
list_of_simulations (list[Simulation_Results]) – A list of simulation objects. Valid simulation objects include objects from these classes:
Linear_Simulation
,Equiv_Linear_Simulation
, andNonlinear_Simulation
.use_ctx (bool) – For unix systems, provides the option to use the forkserver context for spawning subprocesses when running simulations in batch. The forkserver context is recommended to avoid slowdowns when PySeismoSoil is being run in batch as part of a code that contains additional non-PySeismoSoil variables and module imports. If use_ctx is set to True, the top-level code must be guarded under if __name__ == “__main__”:.
- list_of_simulations#
Same as the input parameter list_of_simulations.
- Type:
list[Simulation_Results]
- n_simulations#
Number of simulations in the list.
- Type:
int
- sim_type#
The object type of the site response simulations.
- Type:
{
Linear_Simulation
,Equiv_Linear_Simulation
,Nonlinear_Simulation
}
- Raises:
TypeError – When
list_of_simulations
is not a listValueError – When
list_of_simulations
has length 0
Methods Summary
run
([parallel, n_cores, base_output_dir, ...])Run simulations in batch.
Methods Documentation
- run(parallel: bool = False, n_cores: int | None = 1, base_output_dir: str | None = None, catch_errors: bool = False, verbose: bool = True, options: dict[str, Any] | None = None) list[PySeismoSoil.class_simulation_results.Simulation_Results] [source]#
Run simulations in batch.
- Parameters:
parallel (bool) – Whether to use multiple CPU cores to run simulations.
n_cores (int | None) – Number of CPU cores to be used. If
None
, all CPU cores will be used.base_output_dir (str | None) – The parent directory for saving the output files/figures of the current batch.
catch_errors (bool) – Optionally allows for ValueErrors to be caught during batch simulation, so a single error simulation doesn’t interrupt the running of others in the batch. Simulations that have caught errors will be replaced by None in the results list.
verbose (bool) – Whether to print the parallel computing progress info.
options (dict[str, Any] | None) – Options to be passed to the
run()
methods of the relevant simulation classes (linear, equivalent linear, or nonlinear). Check out the API documentation of therun()
methods here: https://pyseismosoil.readthedocs.io/en/stable/api_docs/class_simulation.html If None, it is equivalent to an empty dict.
- Returns:
sim_results – Simulation results corresponding to each simulation object.
- Return type:
list[Simulation_Results]