8.5 KiB
GUI Parameter And Run Architecture
Decision
Use MATLAB struct as the primary runtime and persistence format.
Reasons:
- App Designer works naturally with nested
structdata. - Existing solver code already expects MATLAB variables and structs, not object models.
structavoids unnecessary conversion while the GUI is being built.- JSON can still be added later as an optional export/import layer.
Recommended flow:
- Load a case template into
configas a MATLAB struct. - Let the GUI edit
config. - Save or load
configdirectly as MATLAB data first. - Convert
configinto solver inputs through a single entry point later:run_case(config).
Unified Config Layout
The GUI should be built around the following top-level fields:
config.meta
config.model
config.grid
config.fracture
config.discretization
config.flow
config.initial
config.wells
config.schedule
config.solver
config.output
Part Mapping
The existing main1.m scripts are structurally consistent and map well to the GUI:
model: model selectiongrid: matrix grid definitionfracture: fracture input and geometrydiscretization: SP/DP discretization and medium setupflow+initial: flow model, PVT, relative permeability, initial statewells+schedule: wells, perforations, stage schedulesolver: nonlinear and timestep controlsoutput: run execution and result presentation
Parameter Layers
The previous inventory mixed together direct inputs and fields created during preprocessing. The GUI should distinguish them explicitly.
Layer A: Editable Input Parameters
These are the parameters the GUI should expose directly or through advanced panels.
Layer B: Derived Or Runtime Fields
These are generated by preprocessing, discretization, solver assembly, or postprocessing. They should usually be displayed or logged, but not edited directly.
Core Parameter Inventory
This is the revised first-pass grouping of parameters already identified in the repository.
meta
case_namecase_iddescriptionsource_case_foldercreated_from_templateversion
model
modelflaggrid_modelflow_model
Known values:
modelflag: currently fixed to classical EDFM in all 7 examplesgrid_model:1single-medium,2dual-mediumflow_model:1gas-water,2oil-water,3multi-component
grid
Editable inputs:
dxdydznxnynzNTG
Derived by GridProp_pre and later preprocessing:
coordinatesnodesnPnmcdxvdyvdzvvmzmxraoyraozraocell_mid_coords
Important correction:
boundaryis not defined inGridProp_pre.m.- In case 1 it is defined in
grid_discretization_SP_model.m. - This means geometric grid size and reservoir validity boundary are separate parameter groups and should not be merged.
fracture
input_styleinput_contentffellipfractureLinesfractureHeightsflowBarrierFlagsfrac_informationnf
Observed input modes:
- Engineering input table
- Vector input
- 2D line input
- Reserved
.fabimport mode
discretization
Editable inputs:
grid_modelboundaryinvalid_layervalid_gridsgeneration rule- matrix permeability definition rule
- matrix porosity definition rule
- matrix reference pressure
prpor - matrix compressibility
cpor - rock density
rock_density - fracture permeability
Kf - fracture aperture
Wf - fracture porosity
Porf - fracture reference pressure
prporf - fracture compressibility
cporf stress_factor_fracturestress_factor_matrixstress_factor_ref_pressure- dual-medium only:
kx_matrixLayerky_matrixLayerkz_matrixLayerpori_matrixLayersigma
Observed editable rock-property expressions in current cases:
- case 1 SP:
- polygon
boundary kx/ky/kzas spatial functions ofcell_mid_coordsporias spatial function ofcell_mid_coords
- polygon
- cases 2/4/6:
- constant matrix properties
invalid_layercontrols inactive layers
- cases 5/7:
- constant matrix properties, different values from cases 2/4/6
- case 3 DP:
- fracture-layer permeability set
- matrix-layer permeability set
- matrix-layer porosity
- shape factor
sigma
Derived fields:
- fracture-matrix discretization result
- fracture-fracture discretization result
- EDFM connection data
- operator generation inputs for
OperatorRS - runtime fields added onto
r, includingrock_density,valid_grids, stress-factor fields, and dual-medium derived fields
flow
Shared categories:
- phase density
- reference pressure
- formation volume factor
- compressibility
- viscosity
- viscosity-pressure coefficient
- capillary pressure switch
- non-Darcy coefficient
- threshold pressure gradient
- matrix relative permeability table
- fracture relative permeability table
Additional note:
- Many of these are hidden inside helper files such as
gas_water_flow.m,oil_water_flow.m, andmulti_component_flow.m, so they must be treated as editable physics parameters even though they are not visible inmain1.m.
Gas-water specific:
gas_prop.VLgas_prop.PLgas_prop.Kngas_prop.Kn_modified_factorgas_prop.beta_non_Darcy_flowdensity_g_scgas_model- gas PVT table or generated PVT parameters
Oil-water specific:
density_o_scoil_model- oil PVT table or generated PVT parameters
Multi-component specific:
DsDb- adsorption table
c_ca_table - chemistry parameters
R,Vm,Temperature,chemistry_cof - dynamic relative permeability tables
cs_Nc,kr_nosurf,kr_surf,PC - fracture counterparts of the same tables
number_state_variables
initial
Gas-water and oil-water:
PSw
Multi-component:
PSwCsCb
wells
Conventional well definition:
well1- well name
- perforation count
- perforation grid indices
- wellbore radius
- skin
- well type
Fracture-well definition:
num_fracture_wellswellocperfnumwell2
Combined runtime well structure:
Wellc
schedule
number_phaseswell_schedulestimedtmaxdtmin
Per-row schedule fields observed:
- well name
- well state
- well role
- control mode
- target value 1
- target value 2
- optional
Cs_inj - optional
Cb_inj
solver
yitapyitasomegaNmaxepsaveepsmax
output
Runtime outputs observed:
TimesOutputRsWellparatrun
Useful progress fields for the future GUI:
- current stage index
- current simulation time
- current
dt - Newton iteration count
- cumulative linear solve time
- cumulative Jacobian assembly time
Preset Strategy
The seven example folders should be treated as presets, not as independent long-term entry points.
Recommended future structure:
load_case_template(1)...load_case_template(7)- each template returns a complete
config - GUI edits the
config run_case(config)executes the solver
This avoids binding the GUI to seven different hard-coded scripts.
Run Page Scope
Pause and abort are explicitly deferred for now.
Current target for the run page:
- show active case name
- show active stage
- show current simulation time
- show current timestep
- show Newton count
- show text log
- optionally plot selected well response during run
The existing solver already prints progress with fprintf, but the proper GUI solution will be to add a progress callback later.
File-Level Sources Confirmed So Far
Primary input sources already confirmed:
main1.mGridProp_pre.mgrid_discretization_SP_model.mgrid_discretization_DP_model.mpreprocess_heterogeneous.mgas_water_flow.moil_water_flow.mmulti_component_flow.m
This matters because not all user-facing parameters live in main1.m.
The parameter registry must therefore be built from the full call chain, not from entry scripts only.
Next Implementation Steps
- Build a complete field-level parameter registry file from the 7 case folders.
- Keep
create_empty_configas the primary configuration skeleton. - Use
run_case(config)as the single runtime entry point for all three flow models. - Build App Designer pages around model-specific parameter panels.
Runtime Status
Current runtime direction:
run_case(config)is now the unified execution entry.flow_modelis treated as mutually exclusive.- GUI should only show the active model's parameter set.
- Non-active model parameters should remain hidden and unused.