Skip to content

Conversation

@LasNikas
Copy link
Collaborator

@LasNikas LasNikas commented Oct 2, 2025

Lumped parameter model to simulate vascular systems

@LasNikas LasNikas mentioned this pull request Oct 8, 2025
@LasNikas LasNikas force-pushed the add-rcr-windkessel-model branch from 8096a2d to bfbf3b6 Compare October 13, 2025 14:50
@LasNikas LasNikas mentioned this pull request Oct 13, 2025
7 tasks
@LasNikas LasNikas added the enhancement New feature or request label Oct 27, 2025
@LasNikas LasNikas self-assigned this Oct 27, 2025
@LasNikas LasNikas marked this pull request as ready for review October 27, 2025 16:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the RCR-Windkessel lumped parameter model for simulating vascular systems at open boundaries. The model captures the relationship between pressure and flow in pulsatile systems using three components: characteristic resistance (R1), peripheral resistance (R2), and compliance (C).

Key changes:

  • Added RCRWindkesselModel struct and associated calculation methods
  • Integrated pressure model support into the OpenBoundarySystem and BoundaryZone infrastructure
  • Added comprehensive validation tests using ferret vascular system data

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/schemes/boundary/open_boundary/pressure_model.jl Core implementation of the RCR-Windkessel model including pressure and flow rate calculations
src/schemes/boundary/open_boundary/system.jl Extended OpenBoundarySystem to support pressure models with new fields and initialization logic
src/schemes/boundary/open_boundary/boundary_zones.jl Added pressure_model field to BoundaryZone with validation logic
src/schemes/boundary/open_boundary/dynamical_pressure.jl Modified pressure reference to support pressure model computations
src/schemes/boundary/open_boundary/mirroring.jl Updated boundary quantity handling to work with pressure models
src/callbacks/update.jl Modified update callback to pass timestep to open boundary updates
test/schemes/boundary/open_boundary/pressure_model.jl Comprehensive tests including pulsatile flow validation against ODE solution
docs/src/systems/boundary.md Added documentation section for pressure models
docs/src/refs.bib Added references for Gasser (2021) and Westerhof (2008)
Other files Minor updates for file inclusion and exports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@LasNikas
Copy link
Collaborator Author

LasNikas commented Nov 7, 2025

/run-gpu-tests

end
end

function extract_pressure_models(boundary_zones)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this has to be so complicated.
It looks like this model can only be used if reference_pressure = nothing is passed to the BoundaryZone, so it is essentially just a complex function for reference_pressure. It is also only used where a reference_pressure function would be used (imposed_pressure) plus it is updated. These are the only two occurrences.

So why do you need this extra struct and extra field in the boundary zone? Why can't you just make this a functor? Basically, just add a field pressure to the struct and make it a functor as

function (model::RCRWindkesselModel)(x, t)
    return model.pressure[]
end

And then the only thing you have to change in the open boundary system and boundary zones files is that you add an update. This update function updates reference_pressure for each boundary zone. If it's ::RCRWindkesselModel, do the update, otherwise do nothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understood correctly. What happens if some BoundaryZones use a pressure_model while others have a prescribed pressure (as a function or scalar)?
Is this then type stable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, IIRC, storing RefValues in a GPU array is not allowed.

previous_flow_rate = flow_rate[]
flow_rate[] = current_flow_rate

# Calculate new pressure according to eq. 22 in Zhang et al. (2025)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. What do Zhang et al. have to do with this? You listed different references.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I implemented this, I based it on this literature because it was also mentioned in the SPH context. It's a simple ODE. I don't really care which literature I cite here...
The other references are purely in a biomechanical context where Zhang is in a SPH context.

# dp[1] = -p[1] / (R_2 * C) + R_1 * dq_dt + q_func(t) * (R_2 + R_1) / (R_2 * C)
# end
#
# The solution is obtained using simple Euler integration over the time interval `tspan`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Euler? You could just use the default, which is an adaptive method that doesn't even need a time step.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then? It doesn't makes a difference here, since I only needed this for the pressure reference values

@LasNikas LasNikas requested a review from efaulhaber November 11, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants