pyoomph.utils.paramscan module

class pyoomph.utils.paramscan.ParallelParameterScan(script_to_call, output_dir=None, max_procs=2, single_threaded_childs=True, interpreter='/home/docs/checkouts/readthedocs.org/user_builds/pyoomph/envs/latest/bin/python')[source]

Bases: object

A class for performing parallel parameter scans.

Parameters:
  • script_to_call (str) – The script to call for each parameter simulation.

  • output_dir (Optional[str]) – The output directory for the parameter simulations. If not provided, a default directory will be created based on the script’s name.

  • max_procs (Optional[int]) – The maximum number of processes to use for parallel execution. Defaults to the number of CPUs in the system.

  • single_threaded_childs (bool) – Whether to run each child process in single-threaded mode. Defaults to True.

  • interpreter (str) – The path to the Python interpreter to use. Defaults to the system’s default interpreter.

clear()[source]

Remove all simulations from the list.

new_sim(subdir=None, additional_args=[])[source]

Create a new simulation. You can set the parameters of the simulation by setting attributes of the returned instance.

Parameters:
  • subdir (str, optional) – The subdirectory where the simulation will be saved. Defaults to None, will be determined automatically based on the parameters.

  • additional_args (List[str], optional) – Additional arguments to be passed to the simulation. Defaults to an empty list.

Returns:

The newly created simulation instance.

Return type:

SingleParallelParameterSimulation

run_all(skip_done=False)[source]

Run all added simulations in parallel, by default single-CPU each, always using a maximum of max_procs processes.

Parameters:

skip_done (bool, optional) – Whether to skip simulations that are already completed. Defaults to False.

class pyoomph.utils.paramscan.SimulationNamespace[source]

Bases: object

A class representing a namespace for simulation parameters for the parallel parameter scan. If your problem has e.g. an nested property like problem.droplet.contact_angle, you must create a SimulationNamespace object for the SingleParallelParameterSimulation object, i.e.

sim.droplet=SimulationNamespace() sim.droplet.contact_angle=…

Otherwise, nested properties cannot be set.

class pyoomph.utils.paramscan.SingleParallelParameterSimulation(subdir, additional_args)[source]

Bases: object

Storage class for the used parameters of a single simulation in a parallel parameter scan. Instances are generated by

sim=ParallelParameterScan.new_sim(...)

Once generated, the parameters can be set as attributes of the instance sim, e.g.

sim.paramA=...

For nested parameters, use the SimulationNamespace class, e.g.

sim.droplet=SimulationNamespace()
sim.droplet.contact_angle=...