Skip to content

N-fork#79

Open
alemelis wants to merge 17 commits intomasterfrom
nfork
Open

N-fork#79
alemelis wants to merge 17 commits intomasterfrom
nfork

Conversation

@alemelis
Copy link
Copy Markdown
Collaborator

No description provided.

alemelis added 16 commits April 23, 2026 21:59
overview.md: rewrite — remove rotting external image links, simplify
  acknowledgements, add numerical scheme section.

quickstart.md: fix verbose default (true not false), add savedir kwarg,
  replace prose with tables for output format and convergence stats.

config.md: fix inaccuracies — inlet_file optional (defaults to
  <project_name>_inlet.dat), gamma_profile underscore, wk3 inferred from
  R2 presence not outlet: key, add visco-elastic/initial condition params,
  rewrite template.

examples.md: model table, runnable Julia snippet, result-reading snippet,
  minimal single-vessel config.

plotting.md (new): matplotlib and Julia plotting examples with unit
  conversion table.

benchmarking.md (new): PkgBenchmark workflow and manual harness usage.

index.md: fix two typos (accompaigning, backgound, accompaining).

make.jl: add plotting and benchmarking pages, remove stale TODO.
overview.md: rewrite — remove rotting external image links, simplify
  acknowledgements, add numerical scheme section.

quickstart.md: fix verbose default (true not false), add savedir kwarg,
  replace prose with tables for output format and convergence stats.

config.md: fix inaccuracies — inlet_file optional (defaults to
  <project_name>_inlet.dat), gamma_profile underscore, wk3 inferred from
  R2 presence not outlet: key, add visco-elastic/initial condition params,
  rewrite template.

examples.md: model table, runnable Julia snippet, result-reading snippet,
  minimal single-vessel config.

plotting.md (new): matplotlib and Julia plotting examples with unit
  conversion table.

benchmarking.md (new): PkgBenchmark workflow and manual harness usage.

index.md: fix two typos (accompaigning, backgound, accompaining).

make.jl: add plotting and benchmarking pages, remove stale TODO.
Adds test/test_golden_master.jl covering bifurcation (ibif), conjunction
+ bifurcation (adan56), and anastomosis (circle_of_willis). Each run is
compared against the pre-existing serialised references (test/ref_*.jls)
with a 1e-12 relative tolerance on all saved waveform fields.

Adds Serialization stdlib to Project.toml so the test environment can
load the .jls reference files.
Introduces src/junction.jl with the Junction struct and its constructor.
Validates that k ≥ 2, sides are :inlet/:outlet, lengths match, and that
every junction has at least one vessel of each side. Preallocates work
arrays (x, F, J, dx) to avoid per-step allocation once the solver lands.

Exports Junction from openBF.jl. No behavioural change — existing solver
path is untouched.
Adds the full Newton solver to src/junction.jl:
- pack_initial_guess! reads (A, Q) from each vessel's boundary face
- residual! builds the 2k-component F: characteristic invariants (block 1),
  mass conservation (block 2), pressure continuity (block 3)
- jacobian! fills the analytic 2k×2k Jacobian; no finite-differences
- solve_junction! drives Newton to norm(F) < 1e-5 (matching legacy tolerance)
- unpack_solution! writes converged (A, Q, u) back to each vessel face

use_total_pressure=true switches pressure continuity from static to
static+dynamic, matching the existing conjunction solver (join_vessels!/2).

test/test_junction_k2.jl verifies that solve_junction! with
use_total_pressure=true reproduces join_vessels! to 1e-10 relative on A, Q, u.
test_junction_k3_bifurcation.jl: constructs a synthetic 1-parent/2-daughter
setup with ibif-like vessel parameters, runs join_vessels!(v1,v2,v3) and
solve_junction! from the same initial state, asserts A/Q/u agree to 1e-10
relative on all three vessels.

test_junction_k3_anastomosis.jl: same pattern for a 2-parent/1-daughter
junction, comparing against solveAnastomosis.

Both use use_total_pressure=false (static pressure), matching the legacy
bifurcation and anastomosis solvers.
…flag

Phase 4 of nfork plan. Adds Junction struct and solve_junction! using
(u, α) parameterisation matching the legacy NR solvers exactly. The
generic path is opt-in via run_simulation(yaml; use_generic_junctions=true)
and verified to agree with legacy waveforms to within 1e-10 relative on ibif.
Phase 5: use_generic_junctions defaults to true in both Network and
run_simulation. Legacy path remains reachable via use_generic_junctions=false.
Phase 6. Removes bifurcations.jl, conjunctions.jl, anastomosis.jl and all
associated dead code (anastomosis_solved, use_generic_junctions flag,
_apply_junctions!, legacy solve! branch). Also drops the unused StaticArrays
dependency. Test count grows from 30 to 42 with the ibif smoke test.
Phase 7. Verifies Junction struct allocates correctly (8-element work arrays,
8×8 Jacobian) for a 1-outlet / 3-inlet junction.
Phase 8. validate_network() checks self-loops, missing inlet/outlet,
all-inlet/all-outlet junctions, high-k junctions, and disconnected subgraphs.
Exported from the module; run.jl wires it as `julia run.jl --validate <yaml>`.
MMatrix (mutable) allocates on the heap. Switch to reading jc.J/jc.F into an
SMatrix/SVector (immutable, stack-allocated) for the linear solve, then copy
the SVector result back to the pre-allocated jc.dx. Also precompute Wstar into
a new jc.Wstar field instead of ntuple+collect.

Result: solve_junction! is 0-alloc for k=2 and k=3 (all real models).
Benchmarks vs baseline: cca -19% time, ibif -15% time / -25% allocs;
adan56 -10% time (more convergence cycles due to parallel vs sequential
junction update order; per-cycle cost is not regressed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant