pisces.extensions.simulation.core.initial_conditions.InitialConditions.create_ics#
- classmethod InitialConditions.create_ics(directory: str | Path, *models, particle_files: dict[str, str | Path] = None, **kwargs)[source]#
Create a new initial conditions (IC) directory with optional particle datasets.
This is a convenience constructor for building an InitialConditions instance from scratch. It will:
Create (or overwrite) the target IC directory on disk.
Process and validate the provided models via
_process_models
, copying or moving model files into the IC directory.Optionally process particle dataset files via
_process_particle_files
ifparticle_files
is provided.Generate the
IC_CONFIG.yaml
file containing metadata and model configuration.
- Parameters:
directory (
str
orPath
) – Path to the directory where the new initial conditions will be created. If the directory already exists and is non-empty,overwrite=True
must be provided inkwargs
to remove its contents before creation.*models (
tuple
) –One or more model specifications to include in the initial conditions. Each model specification should be a tuple of the form:
(name, model, position, velocity[, orientation][, spin])
Where:
name
: str Unique name/identifier for the model.model
: str, ~pathlib.Path or ~pisces.models.core.base.BaseModel Path to a model file on disk or an already loadedBaseModel
instance.position
: sequence or ~unyt.array.unyt_array Position vector of lengthndim
with length units (default: meters).velocity
: sequence or ~unyt.array.unyt_array Velocity vector of lengthndim
with velocity units (default: km/s).orientation
: optional, sequence or array Orientation vector (shape:(ndim,)
) or rotation matrix (shape:(ndim, ndim)
). If omitted, the identity is used.spin
: optional, float Scalar spin value (unitless). Defaults to0.0
.
particle_files (
dict
of{str: (str or Path)}
, optional) – Mapping from model name to path to a particle dataset file. Only processed if provided. Files will be copied or moved into the IC directory with the naming scheme<model_name>_p.hdf5
.**kwargs –
Additional keyword arguments forwarded to
_process_models
and_process_particle_files
. Common options include:file_processing_mode
: {“copy”, “move”} Whether to copy (default) or move files into the IC directory.overwrite
: bool IfTrue
, existing files or directories will be overwritten.
- Returns:
An initialized
InitialConditions
instance for the newly created directory.- Return type:
- Raises:
FileExistsError – If
directory
exists and is non-empty, andoverwrite
is not True.FileNotFoundError – If any provided model or particle file does not exist.
ValueError – If model definitions are invalid or missing required parameters.