-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
enhancementNew feature or requestNew feature or request
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 Unify attribute names? #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
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request