初版gui
This commit is contained in:
@@ -0,0 +1,248 @@
|
||||
function config = create_empty_config()
|
||||
%CREATE_EMPTY_CONFIG Create a unified GUI/runtime config skeleton.
|
||||
|
||||
config = struct();
|
||||
|
||||
config.meta = struct( ...
|
||||
'case_name', '', ...
|
||||
'case_id', '', ...
|
||||
'description', '', ...
|
||||
'source_case_folder', '', ...
|
||||
'created_from_template', '', ...
|
||||
'version', '0.1');
|
||||
|
||||
config.model = struct( ...
|
||||
'modelflag', 1, ...
|
||||
'grid_model', 1, ...
|
||||
'flow_model', 1);
|
||||
|
||||
config.grid = struct( ...
|
||||
'dx', [], ...
|
||||
'dy', [], ...
|
||||
'dz', [], ...
|
||||
'nx', 0, ...
|
||||
'ny', 0, ...
|
||||
'nz', 0, ...
|
||||
'NTG', [], ...
|
||||
'coordinates', [], ...
|
||||
'nodes', [], ...
|
||||
'nP', 0, ...
|
||||
'nmc', 0, ...
|
||||
'dxv', [], ...
|
||||
'dyv', [], ...
|
||||
'dzv', [], ...
|
||||
'zm', [], ...
|
||||
'vm', [], ...
|
||||
'xrao', [], ...
|
||||
'yrao', [], ...
|
||||
'zrao', [], ...
|
||||
'cell_mid_coords', []);
|
||||
|
||||
config.fracture = struct( ...
|
||||
'input_style', 1, ...
|
||||
'input_content', {{}}, ...
|
||||
'f', [], ...
|
||||
'fellip', [], ...
|
||||
'fractureLines', [], ...
|
||||
'fractureHeights', [], ...
|
||||
'flowBarrierFlags', [], ...
|
||||
'frac_information', [], ...
|
||||
'nf', 0);
|
||||
|
||||
config.discretization = struct( ...
|
||||
'mode', 1, ...
|
||||
'use_operator', true, ...
|
||||
'sp', struct( ...
|
||||
'boundary_polygon', [], ...
|
||||
'invalid_layer', [], ...
|
||||
'valid_grids', [], ...
|
||||
'matrix', struct( ...
|
||||
'kx', [], ...
|
||||
'ky', [], ...
|
||||
'kz', [], ...
|
||||
'pori', [], ...
|
||||
'prpor', 20, ...
|
||||
'cpor', 1.0e-5, ...
|
||||
'rock_density', 2700), ...
|
||||
'fracture', struct( ...
|
||||
'Kf', [], ...
|
||||
'Wf', [], ...
|
||||
'Porf', [], ...
|
||||
'prporf', 20, ...
|
||||
'cporf', 1.0e-5), ...
|
||||
'stress', struct( ...
|
||||
'fracture_factor', 0, ...
|
||||
'matrix_factor', 0, ...
|
||||
'ref_pressure', 20)), ...
|
||||
'dp', struct( ...
|
||||
'valid_grids', [], ...
|
||||
'NTG', [], ...
|
||||
'prpor', 20, ...
|
||||
'cpor', 1.0e-5, ...
|
||||
'rock_density', 2700, ...
|
||||
'fracture_layer', struct( ...
|
||||
'kx', [], ...
|
||||
'ky', [], ...
|
||||
'kz', [], ...
|
||||
'pori', []), ...
|
||||
'matrix_layer', struct( ...
|
||||
'kx', [], ...
|
||||
'ky', [], ...
|
||||
'kz', [], ...
|
||||
'pori', []), ...
|
||||
'shape_factor', [], ...
|
||||
'fracture', struct( ...
|
||||
'Kf', [], ...
|
||||
'Wf', [], ...
|
||||
'Porf', [], ...
|
||||
'prporf', 20, ...
|
||||
'cporf', 1.0e-5), ...
|
||||
'stress', struct( ...
|
||||
'fracture_factor', 0, ...
|
||||
'matrix_factor', 0, ...
|
||||
'ref_pressure', 20)), ...
|
||||
'notes', '');
|
||||
|
||||
config.flow = struct( ...
|
||||
'gas_water', struct( ...
|
||||
'gas_prop', struct( ...
|
||||
'VL', 0, ...
|
||||
'PL', 0, ...
|
||||
'Kn', 0, ...
|
||||
'Kn_modified_factor', 1, ...
|
||||
'beta_non_darcy_flow', 0), ...
|
||||
'p_grad_threshold', 0, ...
|
||||
'density_g_sc', 0, ...
|
||||
'density_w_sc', 1000, ...
|
||||
'gas_model', 1, ...
|
||||
'prg', [], ...
|
||||
'Bgi', [], ...
|
||||
'cg', [], ...
|
||||
'vgi', [], ...
|
||||
'cvg', [], ...
|
||||
'Ppr', [], ...
|
||||
'BG', [], ...
|
||||
'MUG', [], ...
|
||||
'prw', [], ...
|
||||
'Bwi', [], ...
|
||||
'cw', [], ...
|
||||
'vwi', [], ...
|
||||
'cvw', [], ...
|
||||
'ifpcgl', 0, ...
|
||||
'Ppr', [], ...
|
||||
'BG', [], ...
|
||||
'MUG', [], ...
|
||||
'matrix_relperm_table', [], ...
|
||||
'fracture_relperm_table', []), ...
|
||||
'oil_water', struct( ...
|
||||
'density_o_sc', 0, ...
|
||||
'density_w_sc', 1000, ...
|
||||
'oil_model', 1, ...
|
||||
'pro', [], ...
|
||||
'Boi', [], ...
|
||||
'co', [], ...
|
||||
'voi', [], ...
|
||||
'cvo', [], ...
|
||||
'Ppr', [], ...
|
||||
'BO', [], ...
|
||||
'MUO', [], ...
|
||||
'prw', [], ...
|
||||
'Bwi', [], ...
|
||||
'cw', [], ...
|
||||
'vwi', [], ...
|
||||
'cvw', [], ...
|
||||
'ifpcow', 0, ...
|
||||
'Ppr', [], ...
|
||||
'BO', [], ...
|
||||
'MUO', [], ...
|
||||
'matrix_relperm_table', [], ...
|
||||
'fracture_relperm_table', [], ...
|
||||
'beta_non_darcy_flow', 0, ...
|
||||
'p_grad_threshold', 0), ...
|
||||
'multi_component', struct( ...
|
||||
'Ds', [], ...
|
||||
'Db', [], ...
|
||||
'c_ca_table', [], ...
|
||||
'cs_data', [], ...
|
||||
'cb_data', [], ...
|
||||
'csa_data', [], ...
|
||||
'cba_data', [], ...
|
||||
'R', [], ...
|
||||
'Vm', [], ...
|
||||
'Temperature', [], ...
|
||||
'chemistry_cof', [], ...
|
||||
'x_matrix', 0.9, ...
|
||||
'x_fracture', 1.0, ...
|
||||
'cs_Nc', [], ...
|
||||
'Nc_nosurf', [], ...
|
||||
'Nc_surf', [], ...
|
||||
'kr_nosurf', [], ...
|
||||
'kr_surf', [], ...
|
||||
'PC', [], ...
|
||||
'cs_Nc_fracture', [], ...
|
||||
'kr_nosurf_fracture', [], ...
|
||||
'kr_surf_fracture', [], ...
|
||||
'PC_fracture', [], ...
|
||||
'ifpcgl', 0, ...
|
||||
'p_grad_threshold', 0, ...
|
||||
'gas_prop', struct( ...
|
||||
'VL', 0, ...
|
||||
'PL', 0, ...
|
||||
'Kn', 0, ...
|
||||
'Kn_modified_factor', 1, ...
|
||||
'stress_factor_fracture', 0, ...
|
||||
'stress_factor_matrix', 0, ...
|
||||
'stress_factor_ref_pressure', 20, ...
|
||||
'beta_non_darcy_flow', 0), ...
|
||||
'density_g_sc', 0, ...
|
||||
'density_w_sc', 1000, ...
|
||||
'gas_model', 1, ...
|
||||
'prg', [], ...
|
||||
'Bgi', [], ...
|
||||
'cg', [], ...
|
||||
'vgi', [], ...
|
||||
'cvg', [], ...
|
||||
'Ppr', [], ...
|
||||
'BG', [], ...
|
||||
'MUG', [], ...
|
||||
'prw', [], ...
|
||||
'Bwi', [], ...
|
||||
'cw', [], ...
|
||||
'vwi', [], ...
|
||||
'cvw', [], ...
|
||||
'number_state_variables', 4));
|
||||
|
||||
config.initial = struct( ...
|
||||
'pressure', [], ...
|
||||
'sw', [], ...
|
||||
'cs', [], ...
|
||||
'cb', []);
|
||||
|
||||
config.wells = struct( ...
|
||||
'well1', {{}}, ...
|
||||
'num_fracture_wells', 0, ...
|
||||
'welloc', {{}}, ...
|
||||
'perfnum', {{}}, ...
|
||||
'well2', {{}}, ...
|
||||
'Wellc', []);
|
||||
|
||||
config.schedule = struct( ...
|
||||
'number_phases', 0, ...
|
||||
'well_schedules', {{}}, ...
|
||||
'time', [], ...
|
||||
'dtmax', [], ...
|
||||
'dtmin', []);
|
||||
|
||||
config.solver = struct( ...
|
||||
'yitap', 5, ...
|
||||
'yitas', 0.04, ...
|
||||
'omega', 0.5, ...
|
||||
'Nmax', 50, ...
|
||||
'epsave', 1e-6, ...
|
||||
'epsmax', 1e-6);
|
||||
|
||||
config.output = struct( ...
|
||||
'save_input_path', '', ...
|
||||
'save_result_path', '', ...
|
||||
'result_name', '', ...
|
||||
'plot_requests', {{}});
|
||||
@@ -0,0 +1,13 @@
|
||||
function config = load_config_json(file_path)
|
||||
%LOAD_CONFIG_JSON Load a config struct from a JSON file.
|
||||
|
||||
arguments
|
||||
file_path (1,:) char
|
||||
end
|
||||
|
||||
if ~exist(file_path, 'file')
|
||||
error('load_config_json:FileNotFound', 'Config file not found: %s', file_path);
|
||||
end
|
||||
|
||||
json_text = fileread(file_path);
|
||||
config = jsondecode(json_text);
|
||||
@@ -0,0 +1,18 @@
|
||||
function config = load_config_mat(file_path)
|
||||
%LOAD_CONFIG_MAT Load config struct from a MAT file.
|
||||
|
||||
arguments
|
||||
file_path (1,:) char
|
||||
end
|
||||
|
||||
if ~exist(file_path, 'file')
|
||||
error('load_config_mat:FileNotFound', 'Config file not found: %s', file_path);
|
||||
end
|
||||
|
||||
data = load(file_path, '-mat');
|
||||
if ~isfield(data, 'config')
|
||||
error('load_config_mat:MissingConfigVariable', ...
|
||||
'MAT file does not contain variable ''config'': %s', file_path);
|
||||
end
|
||||
|
||||
config = data.config;
|
||||
@@ -0,0 +1,21 @@
|
||||
function save_config_json(config, file_path)
|
||||
%SAVE_CONFIG_JSON Save a config struct to a JSON file.
|
||||
|
||||
arguments
|
||||
config (1,1) struct
|
||||
file_path (1,:) char
|
||||
end
|
||||
|
||||
folder_path = fileparts(file_path);
|
||||
if ~isempty(folder_path) && ~exist(folder_path, 'dir')
|
||||
mkdir(folder_path);
|
||||
end
|
||||
|
||||
json_text = jsonencode(config, PrettyPrint=true);
|
||||
fid = fopen(file_path, 'w');
|
||||
if fid == -1
|
||||
error('save_config_json:FileOpenFailed', 'Cannot open file: %s', file_path);
|
||||
end
|
||||
|
||||
cleanup_obj = onCleanup(@() fclose(fid));
|
||||
fprintf(fid, '%s', json_text);
|
||||
@@ -0,0 +1,14 @@
|
||||
function save_config_mat(config, file_path)
|
||||
%SAVE_CONFIG_MAT Save config struct to a MAT file.
|
||||
|
||||
arguments
|
||||
config (1,1) struct
|
||||
file_path (1,:) char
|
||||
end
|
||||
|
||||
folder_path = fileparts(file_path);
|
||||
if ~isempty(folder_path) && ~exist(folder_path, 'dir')
|
||||
mkdir(folder_path);
|
||||
end
|
||||
|
||||
save(file_path, 'config', '-mat');
|
||||
Reference in New Issue
Block a user