SimVascular / svZeroDSolver-Archived

A Python lumped-parameter solver for blood flow and pressure in hemodynamic networks
Other
12 stars 15 forks source link

Use combo block to model vessels #42

Closed JonathanPham closed 3 years ago

JonathanPham commented 3 years ago

Addresses Issue #38

Implemented the ComboBlock in blocks.py to allow users to model vessels using an arbitrary combination of a resistor, a capacitor, an inductor, and/or a stenosis element. This ComboBlock effectively replaces the R, RC, RL, RCL, and StenosisBlock elements, since we can model all of these using the ComboBlock now.

Tested the accuracy of the ComboBlock by checking that it yields the same 0d simulation results as a StenosisBlock for the attached 0d input files (from VMR). zero_d_json.zip

Here's an example of how to use the ComboBlock to model three different elements: 1) R-C-L-stenosis, 2) R-L, and 3) R-C-stenosis:

"vessels": [
        {
            "boundary_conditions": {
                "outlet": "RCR_2"
            },
            "vessel_id": 4,
            "vessel_length": 5.182877077031685,
            "vessel_name": "branch4_seg0",
            "zero_d_element_type": "COMBO", # an R-C-L-stenosis element
            "zero_d_element_values": {
                "R_poiseuille": 24.134876235052637,
                "C" : 0.0001,
                "L" : 1.0,
                "stenosis_coefficient": 1.2547136459605657 
            }
        },
        {
            "boundary_conditions": {
                "outlet": "RCR_3"
            },
            "vessel_id": 5,
            "vessel_length": 4.060560280870732,
            "vessel_name": "branch5_seg0",
            "zero_d_element_type": "COMBO", # an R-L element
            "zero_d_element_values": {
                "R_poiseuille": 3.0172124611092825,
                "L" : 10.0
            }
        },
        {
            "boundary_conditions": {
                "outlet": "RCR_4"
            },
            "vessel_id": 6,
            "vessel_length": 11.544295833769882,
            "vessel_name": "branch6_seg0",
            "zero_d_element_type": "COMBO", # an R-C-stenosis element
            "zero_d_element_values": {
                "R_poiseuille": 10.256448651856623,
                "C" : 0.0001,
                "stenosis_coefficient": 4.732081168911113 
            }
        }
    ]

We can also easily extend the new json input file format and the ComboBlock implementation to incorporate more complex features, such as the ones described in M. Mirramezani and S.C. Shadden. A distributed lumped parameter model of blood flow. Annals of Biomedical Engineering. 2020.

Also resolving a small part of Issue #37. Added description comments to the json input files for the test cases.

ktbolt commented 3 years ago

Comments are indeed a good idea. However, there is no need to use an underscore _comments field. Why not just have a description field?

mrp089 commented 3 years ago

Awesome, @JonathanPham, thank you for these quick changes! Do you think it makes sense to get rid of the zero_d_element_type entirely and just default to ComboBlock (with whatever zero_d_element_values are given)?

Let me know if you have any objections! I'm mainly thinking of "classic" cardiovascular models, but you have a broader view of 0D capabilities.

mrp089 commented 3 years ago

If we go through with that we could rename Combo to BloodVessel or something similar.

JonathanPham commented 3 years ago

@mrp089 Good question. While the BloodVessel (originally ComboBlock) block is now the only built-in block capable of modeling blood vessels, there are still some advanced users (e.g. Ingrid and Mattia) who want to develop their own blocks for modeling vessels. As such, I think we should leave the zero_d_element_type field in the json input file so that those advanced users can use their own special blocks.

JonathanPham commented 3 years ago

@mrp089 and @ktbolt Thanks for your suggestions!

The following updates were made:

  1. Deleted the redundant blocks (R, RC, RL, RCL, Stenosis) that could be modeled using the ComboBlock. I also updated the all tests cases reflect these changes. All test cases now use the ComboBlock.
  2. Capacitors or inductors are never used by themselves to model blood vessels. Instead, they are used in conjunction with some kind of resistor, e.g. a Poiseuille resistor. Thus, I also removed the individual capacitor and inductor blocks in solver.py and blocks.py to prevent novice misuse of these blocks.
  3. Furthermore, to prevent specification of only capacitance or inductance in the ComboBlock, we need to require that users provide a viscous Poiseuille-based resistance when they use the ComboBlock. This requirement also aligns with our previous RC, RL, RCL, and StenosisBlock implementations, all of which required specification of a viscous Poiseuille-based resistance.
  4. Added description and derivation of analytical results for each test case
  5. Renamed ComboBlock to BloodVessel since the ComboBlock is now the only (built-in) block capable of modeling blood vessels.
  6. Allow for non-periodic flow, pressure, and coronary inlet BCs.

The above address the comments in Issues #37, #38, #43.