[963] | 1 | function md=preqmu(md,options)
|
---|
| 2 | %QMU - apply Quantification of Margins and Uncertainties techniques
|
---|
| 3 | % to a solution sequence (like diagnostic.m, progonstic.m, etc ...),
|
---|
| 4 | % using the Dakota software from Sandia.
|
---|
| 5 | %
|
---|
| 6 | % options come from the solve.m routine. They can include Dakota options:
|
---|
| 7 | %
|
---|
| 8 | % qmudir: any directory where to run the qmu analysis
|
---|
| 9 | % qmufile: input file for Dakota
|
---|
| 10 | % ivar: selection number for variables input (if several are specified in variables)
|
---|
| 11 | % iresp: same thing for response functions
|
---|
| 12 | % imethod: same thing for methods
|
---|
| 13 | % iparams: same thing for params
|
---|
| 14 | % overwrite: overwrite qmudir
|
---|
| 15 | % outfiles: (John?)
|
---|
| 16 | % rstfile: backup file name
|
---|
| 17 | % rundakota: (John?)
|
---|
| 18 | % runmpi: (John?)
|
---|
| 19 |
|
---|
[6088] | 20 | global ISSM_TIER;
|
---|
[963] | 21 |
|
---|
[6309] | 22 | disp('preprocessing dakota inputs');
|
---|
[963] | 23 |
|
---|
| 24 | %first create temporary directory in which we will work
|
---|
[5029] | 25 | if strncmpi(options.overwrite,'y',1)
|
---|
| 26 | system(['rm -rf ' options.qmudir '/*']);
|
---|
| 27 | else
|
---|
| 28 | %does the directory exist? if so, then error out
|
---|
| 29 | if exist(options.qmudir)==7,
|
---|
| 30 | error('Existing ''%s'' directory, cannot overwrite. Specify ''overwrite'',''y'' option in solve arguments.',options.qmudir);
|
---|
| 31 | end
|
---|
[963] | 32 | end
|
---|
| 33 | mkdir(options.qmudir)
|
---|
| 34 | cd(options.qmudir)
|
---|
| 35 |
|
---|
| 36 | %when running in library mode, the in file needs to be called md.name.qmu.in
|
---|
| 37 | options.qmufile=[md.name ];
|
---|
| 38 |
|
---|
| 39 | %retrieve variables and resposnes for this particular analysis.
|
---|
| 40 | variables=md.variables(options.ivar);
|
---|
| 41 | responses=md.responses(options.iresp);
|
---|
| 42 |
|
---|
[5487] | 43 | %expand variables and responses
|
---|
[5215] | 44 | variables=expandvariables(md,md.variables);
|
---|
[5487] | 45 | responses=expandresponses(md,md.responses);
|
---|
[5215] | 46 |
|
---|
[5487] | 47 | %go through variables and responses, and check they don't have more than md.npart values. Also determine numvariables and numresponses{{{1
|
---|
| 48 | numvariables=0;
|
---|
[5215] | 49 | variable_fieldnames=fieldnames(variables);
|
---|
| 50 | for i=1:length(variable_fieldnames),
|
---|
| 51 | field_name=variable_fieldnames{i};
|
---|
| 52 | fieldvariables=variables.(field_name);
|
---|
| 53 | if numel(fieldvariables)>md.npart,
|
---|
| 54 | error('preqmu error message: one of the expanded variables has more values than the number of partitions (setup in md.npart)');
|
---|
| 55 | end
|
---|
[963] | 56 | numvariables=numvariables+numel(variables.(field_name));
|
---|
| 57 | end
|
---|
| 58 |
|
---|
| 59 | numresponses=0;
|
---|
| 60 | response_fieldnames=fieldnames(responses);
|
---|
| 61 | for i=1:length(response_fieldnames),
|
---|
| 62 | field_name=response_fieldnames{i};
|
---|
| 63 | fieldresponses=responses.(field_name);
|
---|
[5487] | 64 | if numel(fieldresponses)>md.npart,
|
---|
| 65 | error('preqmu error message: one of the expanded responses has more values than the number of partitions (setup in md.npart)');
|
---|
| 66 | end
|
---|
[963] | 67 | numresponses=numresponses+numel(responses.(field_name));
|
---|
| 68 | end
|
---|
[5487] | 69 | %}}}}
|
---|
[963] | 70 |
|
---|
[5487] | 71 | %create in file for dakota
|
---|
| 72 | dakota_in_data(md.qmu_method(options.imethod),variables,responses,md.qmu_params(options.iparams),options.qmufile);
|
---|
| 73 | system(['rm -rf ' md.name '.m']);
|
---|
[963] | 74 |
|
---|
[5487] | 75 | %build a list of variables and responses descriptors. the list is not expanded. {{{1
|
---|
[963] | 76 | variabledescriptors={};
|
---|
[5487] | 77 | variable_fieldnames=fieldnames(md.variables);
|
---|
[963] | 78 | for i=1:length(variable_fieldnames),
|
---|
| 79 | field_name=variable_fieldnames{i};
|
---|
[5487] | 80 | variabledescriptors{end+1}=md.variables.(field_name).descriptor;
|
---|
[963] | 81 | end
|
---|
| 82 |
|
---|
| 83 | responsedescriptors={};
|
---|
[5487] | 84 | response_fieldnames=fieldnames(md.responses);
|
---|
[963] | 85 | for i=1:length(response_fieldnames),
|
---|
| 86 | field_name=response_fieldnames{i};
|
---|
[5487] | 87 | responsedescriptors{end+1}=md.responses.(field_name).descriptor;
|
---|
[963] | 88 | end
|
---|
[5487] | 89 | %}}}
|
---|
[963] | 90 |
|
---|
| 91 | %register the fields that will be needed by the Qmu model.
|
---|
| 92 | md.numberofvariables=numvariables;
|
---|
| 93 | md.numberofresponses=numresponses;
|
---|
| 94 | md.variabledescriptors=variabledescriptors;
|
---|
| 95 | md.responsedescriptors=responsedescriptors;
|
---|
[5487] | 96 | md.numvariabledescriptors=numel(md.variabledescriptors);
|
---|
| 97 | md.numresponsedescriptors=numel(md.responsedescriptors);
|
---|
[963] | 98 |
|
---|
[2110] | 99 | %now, we have to provide all the info necessary for the solutions to compute the responses. For ex, if mass_flux
|
---|
[4761] | 100 | %is a response, we need a profile of points. For a misfit, we need the observed velocity, etc ...
|
---|
[2110] | 101 | md=process_qmu_response_data(md);
|
---|