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 |
|
---|
20 | global ISSM_DIR;
|
---|
21 |
|
---|
22 | displaystring(md.verbose,'\n%s\n','preprocessing dakota inputs');
|
---|
23 |
|
---|
24 | %first create temporary directory in which we will work
|
---|
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
|
---|
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 |
|
---|
43 | %expand variables and responses
|
---|
44 | variables=expandvariables(md,md.variables);
|
---|
45 | responses=expandresponses(md,md.responses);
|
---|
46 |
|
---|
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;
|
---|
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
|
---|
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);
|
---|
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
|
---|
67 | numresponses=numresponses+numel(responses.(field_name));
|
---|
68 | end
|
---|
69 | %}}}}
|
---|
70 |
|
---|
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']);
|
---|
74 |
|
---|
75 | %build a list of variables and responses descriptors. the list is not expanded. {{{1
|
---|
76 | variabledescriptors={};
|
---|
77 | variable_fieldnames=fieldnames(md.variables);
|
---|
78 | for i=1:length(variable_fieldnames),
|
---|
79 | field_name=variable_fieldnames{i};
|
---|
80 | variabledescriptors{end+1}=md.variables.(field_name).descriptor;
|
---|
81 | end
|
---|
82 |
|
---|
83 | responsedescriptors={};
|
---|
84 | response_fieldnames=fieldnames(md.responses);
|
---|
85 | for i=1:length(response_fieldnames),
|
---|
86 | field_name=response_fieldnames{i};
|
---|
87 | responsedescriptors{end+1}=md.responses.(field_name).descriptor;
|
---|
88 | end
|
---|
89 | %}}}
|
---|
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;
|
---|
96 | md.numvariabledescriptors=numel(md.variabledescriptors);
|
---|
97 | md.numresponsedescriptors=numel(md.responsedescriptors);
|
---|
98 |
|
---|
99 | %now, we have to provide all the info necessary for the solutions to compute the responses. For ex, if mass_flux
|
---|
100 | %is a response, we need a profile of points. For a misfit, we need the observed velocity, etc ...
|
---|
101 | md=process_qmu_response_data(md);
|
---|