[963] | 1 | function 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] | 14 | disp('preprocessing dakota inputs');
|
---|
[24686] | 15 | qmufile = getfieldvalue(options,'qmufile','qmu');
|
---|
[17806] | 16 | ivar = getfieldvalue(options,'ivar',1);
|
---|
| 17 | iresp = getfieldvalue(options,'iresp',1);
|
---|
| 18 | imethod = getfieldvalue(options,'imethod',1);
|
---|
| 19 | iparams = 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] | 22 | qmufile=[md.miscellaneous.name];
|
---|
[963] | 23 |
|
---|
| 24 | %retrieve variables and resposnes for this particular analysis.
|
---|
[17806] | 25 | variables=md.qmu.variables(ivar);
|
---|
| 26 | responses=md.qmu.responses(iresp);
|
---|
[963] | 27 |
|
---|
[5487] | 28 | %expand variables and responses
|
---|
[9668] | 29 | variables=expandvariables(md,variables);
|
---|
| 30 | responses=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] | 33 | numvariables=0;
|
---|
[5215] | 34 | variable_fieldnames=fieldnames(variables);
|
---|
| 35 | for 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));
|
---|
| 50 | end
|
---|
| 51 |
|
---|
| 52 | numresponses=0;
|
---|
| 53 | response_fieldnames=fieldnames(responses);
|
---|
| 54 | for 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));
|
---|
| 66 | end
|
---|
| 67 |
|
---|
[5487] | 68 | %create in file for dakota
|
---|
[25836] | 69 | dakota_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] | 72 | variabledescriptors={};
|
---|
[17806] | 73 | variable_fieldnames=fieldnames(md.qmu.variables(ivar));
|
---|
[963] | 74 | for 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] | 80 | end
|
---|
| 81 |
|
---|
| 82 | responsedescriptors={};
|
---|
[17806] | 83 | response_fieldnames=fieldnames(md.qmu.responses(iresp));
|
---|
[963] | 84 | for 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] | 90 | end
|
---|
| 91 |
|
---|
[25836] | 92 | %build a MatArray of variable partitions:
|
---|
| 93 | variablepartitions={};
|
---|
| 94 | variablepartitions_npart=[];
|
---|
| 95 | variablepartitions_nt=[];
|
---|
| 96 | variable_fieldnames=fieldnames(md.qmu.variables(ivar));
|
---|
| 97 | for 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
|
---|
| 113 | end
|
---|
| 114 |
|
---|
| 115 | %build a MatArray of response partitions:
|
---|
| 116 | responsepartitions={};
|
---|
| 117 | responsepartitions_npart=[];
|
---|
| 118 | response_fieldnames=fieldnames(md.qmu.responses(iresp));
|
---|
| 119 | for 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
|
---|
| 129 | end
|
---|
| 130 |
|
---|
| 131 |
|
---|
[963] | 132 | %register the fields that will be needed by the Qmu model.
|
---|
[9650] | 133 | md.qmu.numberofresponses=numresponses;
|
---|
| 134 | md.qmu.variabledescriptors=variabledescriptors;
|
---|
[25836] | 135 | md.qmu.variablepartitions=variablepartitions;
|
---|
| 136 | md.qmu.variablepartitions_npart=variablepartitions_npart;
|
---|
| 137 | md.qmu.variablepartitions_nt=variablepartitions_nt;
|
---|
[9650] | 138 | md.qmu.responsedescriptors=responsedescriptors;
|
---|
[25836] | 139 | md.qmu.responsepartitions=responsepartitions;
|
---|
| 140 | md.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] | 145 | md=process_qmu_response_data(md);
|
---|
[25836] | 146 |
|
---|