-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from TNO/7-validation-of-input
7 validation of input
- Loading branch information
Showing
11 changed files
with
287 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
resources/project/R6m7AxFfSX7StHtVJ9WG44h96GM/xMbsyEyRLQ9USX_pduFdZqREeckd.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Info> | ||
<Category UUID="FileClassCategory"> | ||
<Label UUID="design"/> | ||
</Category> | ||
</Info> |
2 changes: 2 additions & 0 deletions
2
resources/project/R6m7AxFfSX7StHtVJ9WG44h96GM/xMbsyEyRLQ9USX_pduFdZqREeckp.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Info location="validate_input.m" type="File"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
function Gxx = Gxx_combined(a,b,c,d,theta,x,y) | ||
% Gxx_combined combines Green's functions for different reservoir compartments. | ||
% | ||
% This function combines Green's functions for different reservoir compartments. | ||
% The reservoir is modeled through a combination of a rectangles and triangles. | ||
% | ||
% Parameters: | ||
% a - Vertical distance to inner reservoir corners, from center (y = 0) | ||
% b - Vertical distance to outer reservoir corners, from center (y = 0) | ||
% c - Length of the left side of the reservoir | ||
% d - Length of the right side of the reservoir | ||
% theta - Angle of the fault [radians] | ||
% x - x-coordinate of evaluation point(s) | ||
% y - y-coordinate of evaluation point(s) | ||
% | ||
% Returns: | ||
% Gxx - Combined Green's function value | ||
% | ||
% Notes: | ||
% - If c = 0, the reservoir is on the right side only. | ||
% - If d = 0, the reservoir is on the left side only. | ||
% - A small number is added to x and y to avoid singularities and division by zero. | ||
% | ||
% Example: | ||
% Gxx = Gxx_combined(10, 20, 5, 5, pi/4, 2, 3); | ||
|
||
% Combines Green's functions for the different reservoir compartments. | ||
% The reservoir is modeled through a combination of a rectangle and triangle | ||
% The function can be used for reservoirs on two sides of the fault or | ||
% one side | ||
% c = 0 --> right side only | ||
% d = 0 --> left side only | ||
|
||
num_offset = 1e-9; % small number to add to x and y to avoid singularities and division by 0) [-] | ||
if x == 0 || x == d | ||
x = x + num_offset*abs(d); | ||
x = x + num_offset; | ||
end | ||
if x == -c | ||
x = x - num_offset*abs(c); | ||
x = x - num_offset; | ||
end | ||
if y == a || y == b | ||
y = y + num_offset*abs(b-a); | ||
end | ||
if y == -a || y == -b | ||
y = y - num_offset*abs(b-a); | ||
end | ||
|
||
% Compute integrals of individual components | ||
f = b/tan(theta); % offset in x | ||
e = a/tan(theta); | ||
|
||
if and(~(c==0), ~d==0) | ||
Gxx_left_rectangle = Gxx_rectangle(-c,-f,-b,a,x,y); | ||
Gxx_left_triangle = Gxx_triangle(-e,f,-a,b,-x,-y); | ||
Gxx_right_triangle = Gxx_triangle(-e,f,-a,b,x,y); | ||
Gxx_right_rectangle = Gxx_rectangle(f, d,-a,b,x,y); | ||
elseif c==0 && ~d==0 | ||
% right side only | ||
Gxx_left_rectangle = 0; | ||
Gxx_left_triangle = 0; | ||
Gxx_right_triangle = Gxx_triangle(-e,f,-a,b,x,y); | ||
Gxx_right_rectangle = Gxx_rectangle(f, d,-a,b,x,y); | ||
elseif ~c==0 && d==0 | ||
% left side only | ||
Gxx_left_rectangle = Gxx_rectangle(-c,-f,-b,a,x,y); | ||
Gxx_left_triangle = Gxx_triangle(-e,f,-a,b,-x,-y); | ||
Gxx_right_triangle = 0; | ||
Gxx_right_rectangle = 0; | ||
end | ||
|
||
Gxx = Gxx_left_rectangle + Gxx_left_triangle + Gxx_right_rectangle + Gxx_right_triangle; | ||
|
||
end | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
function validate_input(analysis) | ||
% function to validate input which has not yet been validated in the | ||
% class properties, and perform sanity checks on the chosen input | ||
% parameters | ||
|
||
% check that the correct input is entered for the save_stress option | ||
if ischar(analysis.save_stress{1}) | ||
if ~ismember(analysis.save_stress{1},{'all','none','first_last','first','last'}); | ||
error(['For save stress selection enter step numbers or ',... | ||
'all, none, first_last, first, last' ]); | ||
end | ||
end | ||
|
||
% check sensibility of the chosen Young's modulus | ||
if log10(analysis.input_parameters.young.value) < 3 || log10(analysis.input_parameters.young.value) > 5 | ||
warning('NB default input unit Youngs modulus is MPa, please double check your input'); | ||
end | ||
|
||
% check sensibility of the chosen vertical stress gradient | ||
if analysis.input_parameters.sv_grad.value < 18 || analysis.input_parameters.sv_grad.value > 28 | ||
warning(['Vertical stress gradient in in MPa/km, and lies typically ',... | ||
'in the range of 19 - 24 MPa/km. Given input was ', ... | ||
num2str(analysis.input_parameters.sv_grad.value),' please check']); | ||
end | ||
|
||
% check sensibility of the chosen pressure gradient | ||
if analysis.input_parameters.p_grad.value < 9 || analysis.input_parameters.p_grad.value > 15 | ||
warning(['Pore stress gradient in in MPa/km, and lies typically ',... | ||
'in the range of 10 - 12 MPa/km. Given input was ', ... | ||
num2str(analysis.input_parameters.p_grad.value),' please check']); | ||
end | ||
|
||
% check sensibility of the chosen temperature gradient | ||
if analysis.input_parameters.T_grad.value < 26 || analysis.input_parameters.T_grad.value > 40 | ||
warning(['Pore stress gradient in in deg/km, and lies typically ',... | ||
'in the range of 26 - 35 deg/km far away from plate boundaries.',... | ||
'Given input was ', ... | ||
num2str(analysis.input_parameters.T_grad.value),' please check']); | ||
end | ||
|
||
% check sensibility of the chosen depth | ||
if analysis.input_parameters.depth_mid.value < -5000 | ||
warning(['Depth of subsurface activities is typically < 5000 m deep ',... | ||
'Given input was ', ... | ||
num2str(analysis.input_parameters.depth_mid.value),' please check']); | ||
end | ||
|
||
% check for error in throw | ||
if analysis.input_parameters.throw.value > abs(analysis.input_parameters.depth_mid.value) | ||
error(['Throw of ', num2str(analysis.input_parameters.throw.value),... | ||
' exceeds reservoir depth']); | ||
end | ||
|
||
% check for error in throw | ||
if analysis.input_parameters.thick.value > abs(analysis.input_parameters.depth_mid.value) | ||
error(['Thickness of ', num2str(analysis.input_parameters.thick.value),... | ||
' exceeds reservoir depth']); | ||
end | ||
% add a time = 0 row to table if that is missing | ||
if ~(analysis.load_table.time_steps(1) == 0) | ||
old_table = analysis.load_table; | ||
first_row = analysis.load_table(1,:); | ||
first_row{1,:} = 0; | ||
analysis.load_table = [first_row; old_table]; | ||
disp('Added time step 0 row to load table'); | ||
end | ||
|
||
depth_dependent_properties = analysis.input_parameters.get_depth_dependent_properties(); | ||
allowed_depth_dependent_properties = {'dip','dip_azi','young','poisson',... | ||
'biot','therm_exp','sH_dir','shsv','sHsh','f_s','f_d','d_c','cohesion'}; | ||
if ~isempty(depth_dependent_properties) | ||
faulty_input = ~ismember(depth_dependent_properties, allowed_depth_dependent_properties); | ||
if any(faulty_input) | ||
i_first_faulty = find(faulty_input, 1, 'first'); | ||
error(['Depth dependent property set where not allowed ',... | ||
'e.g. ', depth_dependent_properties{i_first_faulty}, ... | ||
'. Depth dependent properties are dip,dip_azi, young, poisson,',... | ||
'biot,therm_exp,sH_dir,shsv,sHsh,f_s, f_d,d_c,cohesion']); | ||
end | ||
% set stochastic mode for depth dependent properties off | ||
for i = 1 : length(depth_dependent_properties) | ||
input_value_length = length(analysis.input_parameters.(depth_dependent_properties{i}).value_with_depth); | ||
if (length(analysis.y) ~= length(input_value_length)) & (~input_value_length == 1 ) | ||
error(['Length of depth dependent property ', depth_dependent_properties{i},... | ||
' does not seem to match length of y, please check input']); | ||
elseif input_value_length == 1 | ||
warning(['Depth dependency set for ', depth_dependent_properties{i},... | ||
' but length of value with depth is 1']); | ||
end | ||
analysis.input_parameters.(depth_dependent_properties{i}).stochastic = 0; | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.