Skip to content

Commit

Permalink
steady state max chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
lueckem committed Nov 29, 2024
1 parent 7386075 commit be157fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sponet"
version = "2.5.0"
version = "2.5.1"
description = "Spreading Processes on Networks"
license = "GPL-3.0-or-later"
authors = ["Marvin Lücke"]
Expand Down
12 changes: 9 additions & 3 deletions sponet/steady_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@


def estimate_steady_state(
params: Parameters, col_var: CollectiveVariable, tol_abs: float = 0.01
params: Parameters,
col_var: CollectiveVariable,
tol_abs: float = 0.01,
max_chunk_size: int = 1000,
) -> np.ndarray:
"""
Estimate steady state of collective variable via a long simulation.
Expand All @@ -25,6 +28,8 @@ def estimate_steady_state(
col_var: CollectiveVariable
tol_abs : float, optional
absolute tolerance
max_chunk_size : int, optional
bound how many samples are acquired in one step to reduce memory consumption
Returns
-------
Expand All @@ -42,8 +47,6 @@ def estimate_steady_state(
raise ValueError("Parameters not valid.")

delta_t = float(delta_t)
print(f"delta_t = {delta_t}")

# transient phase: integrate until steady state
print("Integrating through transient phase...")
_, x = model.simulate(1000 * delta_t, len_output=2)
Expand All @@ -55,7 +58,10 @@ def estimate_steady_state(

while remaining_samples > 0:
print(f"Current esimate: {mean_c}")
print(f"Approximately {remaining_samples} more samples are required.")
remaining_samples = min(remaining_samples, max_chunk_size)
print(f"Acquiring {remaining_samples} more samples...")
print("")

_, x = model.simulate(
remaining_samples * delta_t, x[-1], len_output=remaining_samples + 1
Expand Down

0 comments on commit be157fb

Please sign in to comment.