source: issm/trunk/src/m/qmu/preqmu.m

Last change on this file was 25836, checked in by Mathieu Morlighem, 4 years ago

merged trunk-jpl and trunk for revision 25834

File size: 5.2 KB
RevLine 
[963]1function md=preqmu(md,options)
2%QMU - apply Quantification of Margins and Uncertainties techniques
[16137]3% to a solution sequence (like stressbalance.m, progonstic.m, etc ...),
[963]4% using the Dakota software from Sandia.
5%
6% options come from the solve.m routine. They can include Dakota options:
7%
8% qmufile: input file for Dakota
9% ivar: selection number for variables input (if several are specified in variables)
10% iresp: same thing for response functions
11% imethod: same thing for methods
12% iparams: same thing for params
13
[6309]14disp('preprocessing dakota inputs');
[24686]15qmufile = getfieldvalue(options,'qmufile','qmu');
[17806]16ivar = getfieldvalue(options,'ivar',1);
17iresp = getfieldvalue(options,'iresp',1);
18imethod = getfieldvalue(options,'imethod',1);
19iparams = getfieldvalue(options,'iparams',1);
[963]20
[9625]21%when running in library mode, the in file needs to be called md.miscellaneous.name.qmu.in
[24686]22qmufile=[md.miscellaneous.name];
[963]23
24%retrieve variables and resposnes for this particular analysis.
[17806]25variables=md.qmu.variables(ivar);
26responses=md.qmu.responses(iresp);
[963]27
[5487]28%expand variables and responses
[9668]29variables=expandvariables(md,variables);
30responses=expandresponses(md,responses);
[5215]31
[25836]32%go through variables and responses, and check they don't have more than the number of partitions. Also determine numvariables and numresponses
[5487]33numvariables=0;
[5215]34variable_fieldnames=fieldnames(variables);
35for i=1:length(variable_fieldnames),
36 field_name=variable_fieldnames{i};
37 fieldvariables=variables.(field_name);
[6615]38 for j=1:numel(fieldvariables)
[25836]39 if strncmpi(fieldvariables(j).descriptor,'scaled_',7),
40 npart=qmupart2npart(fieldvariables(j).partition);
41 nt=fieldvariables(j).nsteps;
42 if nt==1,
43 if str2int(fieldvariables(j).descriptor,'last')>npart,
44 error('preqmu error message: one of the expanded variables has more values than the number of partitions ');
45 end
46 end
[6615]47 end
[5215]48 end
[963]49 numvariables=numvariables+numel(variables.(field_name));
50end
51
52numresponses=0;
53response_fieldnames=fieldnames(responses);
54for i=1:length(response_fieldnames),
55 field_name=response_fieldnames{i};
56 fieldresponses=responses.(field_name);
[6615]57 for j=1:numel(fieldresponses)
[25836]58 if strncmpi(fieldresponses(j).descriptor,'scaled_',7),
59 npart=partition_npart(fieldresponses(j).partition);
60 if str2int(fieldresponses(j).descriptor,'last')>npart,
61 error('preqmu error message: one of the expanded responses has more values than the number of partitions');
62 end
[6615]63 end
[5487]64 end
[963]65 numresponses=numresponses+numel(responses.(field_name));
66end
67
[5487]68%create in file for dakota
[25836]69dakota_in_data(md.qmu.method(imethod),variables,responses,md.qmu.params(iparams),qmufile,md.qmu.correlation_matrix);
[963]70
[24686]71%build a list of variables and responses descriptors. the list is not expanded.
[963]72variabledescriptors={};
[17806]73variable_fieldnames=fieldnames(md.qmu.variables(ivar));
[963]74for i=1:length(variable_fieldnames),
75 field_name=variable_fieldnames{i};
[17806]76 fieldvariables=md.qmu.variables(ivar).(field_name);
[6615]77 for j=1:numel(fieldvariables)
78 variabledescriptors{end+1}=fieldvariables(j).descriptor;
79 end
[963]80end
81
82responsedescriptors={};
[17806]83response_fieldnames=fieldnames(md.qmu.responses(iresp));
[963]84for i=1:length(response_fieldnames),
85 field_name=response_fieldnames{i};
[17806]86 fieldresponses=md.qmu.responses(iresp).(field_name);
[6615]87 for j=1:numel(fieldresponses)
88 responsedescriptors{end+1}=fieldresponses(j).descriptor;
89 end
[963]90end
91
[25836]92%build a MatArray of variable partitions:
93variablepartitions={};
94variablepartitions_npart=[];
95variablepartitions_nt=[];
96variable_fieldnames=fieldnames(md.qmu.variables(ivar));
97for i=1:length(variable_fieldnames),
98 field_name=variable_fieldnames{i};
99 fieldvariable=md.qmu.variables(ivar).(field_name);
100 if fieldvariable.isscaled() | fieldvariable.isdistributed();
101 variablepartitions{end+1}=fieldvariable.partition;
102 variablepartitions_npart(end+1)=qmupart2npart(fieldvariable.partition);
103 if isprop(fieldvariable,'nsteps'),
104 variablepartitions_nt(end+1)=fieldvariable.nsteps;
105 else
106 variablepartitions_nt(end+1)=1;
107 end
108 else
109 variablepartitions{end+1}=[];
110 variablepartitions_npart(end+1)=0;
111 variablepartitions_nt(end+1)=1;
112 end
113end
114
115%build a MatArray of response partitions:
116responsepartitions={};
117responsepartitions_npart=[];
118response_fieldnames=fieldnames(md.qmu.responses(iresp));
119for i=1:length(response_fieldnames),
120 field_name=response_fieldnames{i};
121 fieldresponse=md.qmu.responses(iresp).(field_name);
122 if fieldresponse.isscaled();
123 responsepartitions{end+1}=fieldresponse.partition;
124 responsepartitions_npart(end+1)=qmupart2npart(fieldresponse.partition);
125 else
126 responsepartitions{end+1}=[];
127 responsepartitions_npart(end+1)=0;
128 end
129end
130
131
[963]132%register the fields that will be needed by the Qmu model.
[9650]133md.qmu.numberofresponses=numresponses;
134md.qmu.variabledescriptors=variabledescriptors;
[25836]135md.qmu.variablepartitions=variablepartitions;
136md.qmu.variablepartitions_npart=variablepartitions_npart;
137md.qmu.variablepartitions_nt=variablepartitions_nt;
[9650]138md.qmu.responsedescriptors=responsedescriptors;
[25836]139md.qmu.responsepartitions=responsepartitions;
140md.qmu.responsepartitions_npart=responsepartitions_npart;
[963]141
[25836]142
[2110]143%now, we have to provide all the info necessary for the solutions to compute the responses. For ex, if mass_flux
[4761]144%is a response, we need a profile of points. For a misfit, we need the observed velocity, etc ...
[2110]145md=process_qmu_response_data(md);
[25836]146
Note: See TracBrowser for help on using the repository browser.