Usage#
This guide covers the two ways to run PyFracVAL: the command-line interface,
and the run_simulation function as a library call. Both implement the
PCA/CCA workflow of [Morán et al., 2019], with morphology conventions
from [Filippov et al., 2000].
Command-line interface#
Generating a single aggregate with default parameters:
pyfracval
This writes one .dat file to a RESULTS/ subdirectory. Parameters are set
via flags, for example an aggregate of 512 particles with Df=1.9,
kf=1.4, and polydisperse primary particles (rp_g=50, rp_gstd=1.25):
pyfracval -n 512 --df 1.9 --kf 1.4 --rp-g 50 --rp-gstd 1.25
Options#
Flag |
Meaning |
|---|---|
|
Total number of primary particles (N). |
|
Target fractal dimension. |
|
Target fractal prefactor. |
|
Geometric mean radius of primary particles. |
|
Geometric standard deviation of radii (>= 1.0). Takes precedence over |
|
Approximate arithmetic standard deviation of radii, used to estimate |
|
CCA sticking geometry variant (0 or 1). |
|
Overlap tolerance for particle sticking. |
|
Target fraction of N for PCA subcluster size. |
|
Number of aggregates to generate sequentially. |
|
Output directory (default: |
|
Random seed for reproducible generation. |
|
Maximum retry attempts per aggregate if generation fails (default: 5). |
|
Path to a TOML/YAML/JSON config file. Algorithm-tuning options not exposed as flags (retry modes, densification, etc.) are only settable this way - see the experiments retrospective for what is available. Explicit flags override the corresponding config value. |
|
Display the generated aggregate(s) interactively via PyVista. |
|
Increase logging verbosity (INFO, DEBUG, TRACE). |
|
Redirect log output to a file. |
|
List all options and their current defaults. |
--rp-gstd versus --rp-std:
# --rp-std is estimated into a geometric standard deviation; check -vv output
# for the WARNING that reports the value actually used.
pyfracval -n 200 --df 1.9 --kf 1.2 --rp-g 20 --rp-std 5 -vv
# --rp-gstd, when given explicitly, takes precedence over --rp-std.
pyfracval -n 100 --df 1.8 --rp-gstd 1.3 --rp-std 5
Generating multiple aggregates with plots shown afterward:
pyfracval -n 100 --df 1.7 --kf 1.1 --num-aggregates 3 -p
Streamlit explorer#
pyfracval explore
launches a Streamlit app (pyfracval/app.py) for interactively browsing
generated aggregates; requires the plot dependency group.
Library usage#
import numpy as np
from pathlib import Path
from pyfracval.main_runner import run_simulation
from pyfracval.visualization import plot_particles
sim_config = {
"N": 128,
"Df": 1.8,
"kf": 1.3,
"rp_g": 10.0,
"rp_gstd": 1.2,
"tol_ov": 1e-4,
"n_subcl_percentage": 0.15,
"ext_case": 0,
}
output_directory = Path("./my_aggregates")
success, final_coords, final_radii = run_simulation(
iteration=1,
sim_config_dict=sim_config,
output_base_dir=str(output_directory),
seed=42,
)
if success:
print(f"Generated {final_coords.shape[0]} particles in {output_directory}")
center_of_mass = np.mean(final_coords, axis=0)
plotter = plot_particles(final_coords, final_radii)
plotter.add_text(
f"N={final_coords.shape[0]}, Df={sim_config['Df']}, kf={sim_config['kf']}",
position="upper_left",
)
plotter.show()
run_simulation also accepts max_runtime_seconds to bound the worst-case
wall-clock time spent retrying a difficult parameter combination. See the
API reference for the full signature.