test: prepare isolated uniform full9 DFG pilot
This commit is contained in:
1 parent
939c10c867
commit
c0be841b2e
5 files changed
+444
-5
No files matched your search
@@ -39,8 +39,8 @@ def helpers(source):
|
||||
return h, periodic
|
||||
|
||||
|
||||
def config(h, diameter):
|
||||
cfg, body, p = h.make_config(diameter, SPEED, "SRT", "neq_extrap", "zou_he_local")
|
||||
def config(h, diameter, inlet_scheme="zou_he_local"):
|
||||
cfg, body, p = h.make_config(diameter, SPEED, "SRT", "neq_extrap", inlet_scheme)
|
||||
cfg["method"]["outlet"]["srt_neq_damp"] = 0.5
|
||||
return cfg, body, p
|
||||
|
||||
@@ -159,7 +159,8 @@ def verify_source(source):
|
||||
return expected
|
||||
|
||||
|
||||
def run_case(a, h, periodic, case):
|
||||
def run_case(a, h, periodic, case, *, inlet_scheme="zou_he_local",
|
||||
sparse_pilot=False, receipt_identity=None, progress=None):
|
||||
from CelerisLab.simulation import Simulation
|
||||
from CelerisLab.cuda.context import CudaContext
|
||||
from CelerisLab.lbm.refinement_stepper import FixedPatchStepper
|
||||
@@ -167,10 +168,18 @@ def run_case(a, h, periodic, case):
|
||||
from contextlib import ExitStack
|
||||
|
||||
refined = case == "refined"
|
||||
cfgdict, bodydict, p = config(h, 40 if refined else 80)
|
||||
if refined and inlet_scheme != "zou_he_local":
|
||||
raise ValueError("Experimental inlet is uniform-only")
|
||||
cfgdict, bodydict, p = config(h, 40 if refined else 80, inlet_scheme)
|
||||
identity = {} if receipt_identity is None else dict(receipt_identity)
|
||||
calibration_batches = []
|
||||
executed_steps = 0
|
||||
cap = 5.0 if a.mode == "pilot" else 300.0
|
||||
max_steps = math.ceil(cap * p["diameter"] / SPEED)
|
||||
rows = []
|
||||
if progress is not None:
|
||||
progress.update(executed_steps=0, last_observed_step=0, history=rows,
|
||||
calibration_batches_seconds=calibration_batches)
|
||||
healthy = True
|
||||
step_seconds = 0.0
|
||||
started = time.monotonic()
|
||||
@@ -233,7 +242,7 @@ def run_case(a, h, periodic, case):
|
||||
check_deadline(a.deadline)
|
||||
width = (
|
||||
0.02
|
||||
if a.mode == "pilot" or begin * SPEED / p["diameter"] >= 240
|
||||
if (a.mode == "pilot" and not sparse_pilot) or begin * SPEED / p["diameter"] >= 240
|
||||
else 0.5
|
||||
)
|
||||
n = min(max(1, round(width * p["diameter"] / SPEED)), max_steps - begin)
|
||||
@@ -259,8 +268,14 @@ def run_case(a, h, periodic, case):
|
||||
while done < n:
|
||||
check_deadline(a.deadline)
|
||||
batch = min(100, n - done)
|
||||
batch_started = time.monotonic() if sparse_pilot else None
|
||||
sim.run(batch)
|
||||
executed_steps += batch
|
||||
if progress is not None:
|
||||
progress["executed_steps"] = executed_steps
|
||||
impulse += sim.read_force(0).astype(np.float64) * batch
|
||||
if sparse_pilot and len(calibration_batches) < 5:
|
||||
calibration_batches.append(time.monotonic() - batch_started)
|
||||
done += batch
|
||||
check_deadline(a.deadline)
|
||||
step_seconds += time.monotonic() - tick
|
||||
@@ -320,6 +335,8 @@ def run_case(a, h, periodic, case):
|
||||
check_deadline(a.deadline)
|
||||
ensure_finite(row)
|
||||
rows.append(row)
|
||||
if progress is not None:
|
||||
progress["last_observed_step"] = row["step"]
|
||||
if writer is None:
|
||||
writer = csv.DictWriter(out, fieldnames=row)
|
||||
writer.writeheader()
|
||||
@@ -335,6 +352,9 @@ def run_case(a, h, periodic, case):
|
||||
break
|
||||
if len(rows) == 1:
|
||||
ready = dict(
|
||||
**identity,
|
||||
calibration_batches_seconds=calibration_batches,
|
||||
calibration_note="First 100 steps warmup, next 400 timed; all included in trajectory and force interval",
|
||||
case=case,
|
||||
mode=a.mode,
|
||||
step=begin,
|
||||
@@ -347,6 +367,12 @@ def run_case(a, h, periodic, case):
|
||||
)
|
||||
print("READY " + json.dumps(ready, allow_nan=False), flush=True)
|
||||
result = dict(
|
||||
**identity,
|
||||
calibration_batches_seconds=calibration_batches,
|
||||
first_observed_failure_step=executed_steps if not healthy and not refined else None,
|
||||
last_observed_step=rows[-1]["step"] if rows else 0,
|
||||
failure_timing="First unhealthy observation; onset between observations is unknown" if not healthy else None,
|
||||
executed_steps=executed_steps if not refined else begin,
|
||||
case=case,
|
||||
mode=a.mode,
|
||||
history=rows,
|
||||
|
||||
Reference in new issue
Block a user