SimVascular / SimVascular/svZeroDSolver
Simplify input files
Nobody has claimed this yet.
- 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:
- Sometimes we use dictionaries (main input file, vessel, boundary condition, ...), sometimes lists (all vessels, all boundary conditions, ...).
- Some blocks have a name and an ID (e.g., vessels), making it confusing what to use.
- Attribute names (
name,type,values) are longer than necessary, e.g.,vessel_name,bc_name,junction_name(see #85) - Some blocks differentiate between inlet and outlet even though there is mathematically no difference (e.g.,
Junction) vessel_lengthappears 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:
- Make everything into a dictionary and don't use lists. This makes it easier to modify in Python.
- Use the name as the dictionary key and drop the ID. Use the name to connect blocks.
- Unify everything to
name,type,values - Replace
inletandoutletwithconnectionswhen it doesn't make a difference - Remove
vessel_lengthfrom 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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