SimVascular / SimVascular/svZeroDSolver

Simplify input files

Open
#167 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
22
Forks
44
PR merge metrics
No merged PRs in 30d

Description

Problem

When manually creating and modifying input files, I noticed a couple of things that made the process more difficult than it needed to be:

  1. Sometimes we use dictionaries (main input file, vessel, boundary condition, ...), sometimes lists (all vessels, all boundary conditions, ...).
  2. Some blocks have a name and an ID (e.g., vessels), making it confusing what to use.
  3. Attribute names (name, type, values) are longer than necessary, e.g., vessel_name, bc_name, junction_name (see #85)
  4. Some blocks differentiate between inlet and outlet even though there is mathematically no difference (e.g., Junction)
  5. vessel_length appears in most input files but is not used by the solver

A simplified example:

{
    "boundary_conditions": [
        {
            "bc_name": "BC_Q_LAD",
            "bc_type": "FLOW",
            "bc_values": {"Q": [1.0, 1.0], "t": [0.0, 1.0]}
        },
        {
            "bc_name": "BC_PLV",
            "bc_type": "PRESSURE",
            "bc_values": {"P": [5000.0, 5000.0], "t": [0.0, 1.0]}
        }
    ],
    "vessels": [
        {
            "vessel_id": 0,
            "vessel_name": "Ra",
            "zero_d_element_type": "Resistance",
            "zero_d_element_values": {"R": 1000.0},
            "boundary_conditions": {"inlet": "BC_Q_LAD"}
        },
        {
            "vessel_id": 1,
            "vessel_name": "Ca",
            "zero_d_element_type": "Capacitance",
            "zero_d_element_values": {"C": 0.0001},
            "boundary_conditions": {"outlet": "BC_Pv0"}
        }
    ],
    "junctions": [
        {
            "junction_name": "J0",
            "junction_type": "NORMAL_JUNCTION",
            "inlet_vessels": [0],
            "outlet_vessels": [1]
        }
    ]
}
Solution

Here are some improvements I came up with:

  1. Make everything into a dictionary and don't use lists. This makes it easier to modify in Python.
  2. Use the name as the dictionary key and drop the ID. Use the name to connect blocks.
  3. Unify everything to name, type, values
  4. Replace inlet and outlet with connections when it doesn't make a difference
  5. Remove vessel_length from all blocks

I'd be happy to discuss other ideas here! I would drop backwards compatibility but provide a Python script that converts from the old to the new input file format.

The simplified example would look like:

{
    "boundary_conditions": {
        "BC_Q_LAD": {
            "type": "FLOW",
            "values": {"Q": [1.0, 1.0], "t": [0.0, 1.0]}
        },
        "BC_PLV": {
            "type": "PRESSURE",
            "values": {"P": [5000.0, 5000.0], "t": [0.0, 1.0]}
        }
    },
    "vessels": {
        "Ra": {
            "type": "Resistance",
            "values": {"R": 1000.0},
            "boundary_conditions": {"inlet": "BC_Q_LAD"}
        },
        "Ca": {
            "type": "Capacitance",
            "values": {"C": 0.0001},
            "boundary_conditions": {"outlet": "BC_Pv0"}
        }
    },
    "junctions": {
        "J0": {
            "type": "NORMAL_JUNCTION",
            "connections": ["Ra", "Ca"]
        }
    }
}

Additional context

No response

Code of Conduct
  • I agree to follow this project's Code of Conduct and Contributing Guidelines

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by locating the current input-file parsing and validation path, then review how the proposed dictionary-based format and old-to-new Python conversion script would affect each block type. Done means an agreed new format and a conversion path, with the solver handling the revised inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.