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 | %create m and in files for dakota
|
---|
44 | dakota_in_data(md.qmu_method(options.imethod),variables,md.responses,md.qmu_params(options.iparams),options.qmufile,md);
|
---|
45 |
|
---|
46 | %in library mode, we only need the dakota in file
|
---|
47 | system(['rm -rf ' md.name '.m']);
|
---|
48 |
|
---|
49 | %figure out number of variables and responses, it's not straightforwared
|
---|
50 | numvariables=0;
|
---|
51 | variable_fieldnames=fieldnames(variables);
|
---|
52 | for i=1:length(variable_fieldnames),
|
---|
53 | field_name=variable_fieldnames{i};
|
---|
54 | fieldvariables=variables.(field_name);
|
---|
55 | numvariables=numvariables+numel(variables.(field_name));
|
---|
56 | end
|
---|
57 |
|
---|
58 | numresponses=0;
|
---|
59 | response_fieldnames=fieldnames(responses);
|
---|
60 | for i=1:length(response_fieldnames),
|
---|
61 | field_name=response_fieldnames{i};
|
---|
62 | fieldresponses=responses.(field_name);
|
---|
63 | numresponses=numresponses+numel(responses.(field_name));
|
---|
64 | end
|
---|
65 |
|
---|
66 | %ok, now, for this particular qmu analysis, iresp and ivar specifiy the variables and responses.
|
---|
67 | %The Qmu module will need a list of variable descriptors and response descriptors.
|
---|
68 | %For ease of use, we gather this list here.
|
---|
69 |
|
---|
70 | count=0;
|
---|
71 | variable_fieldnames=fieldnames(variables);
|
---|
72 | variabledescriptors={};
|
---|
73 | for i=1:length(variable_fieldnames),
|
---|
74 | field_name=variable_fieldnames{i};
|
---|
75 | fieldvariables=variables.(field_name);
|
---|
76 | for j=1:length(fieldvariables),
|
---|
77 | descriptor=fieldvariables(j).descriptor;
|
---|
78 | variabledescriptors{end+1}=descriptor;
|
---|
79 | count=count+1;
|
---|
80 | end
|
---|
81 | end
|
---|
82 |
|
---|
83 | count=0;
|
---|
84 | response_fieldnames=fieldnames(responses);
|
---|
85 | responsedescriptors={};
|
---|
86 | for i=1:length(response_fieldnames),
|
---|
87 | field_name=response_fieldnames{i};
|
---|
88 | fieldresponses=responses.(field_name);
|
---|
89 | for j=1:length(fieldresponses),
|
---|
90 | descriptor=fieldresponses(j).descriptor;
|
---|
91 | responsedescriptors{end+1}=descriptor;
|
---|
92 | count=count+1;
|
---|
93 | end
|
---|
94 | end
|
---|
95 |
|
---|
96 | %register the fields that will be needed by the Qmu model.
|
---|
97 | md.numberofvariables=numvariables;
|
---|
98 | md.numberofresponses=numresponses;
|
---|
99 | md.variabledescriptors=variabledescriptors;
|
---|
100 | md.responsedescriptors=responsedescriptors;
|
---|
101 |
|
---|
102 | %now, we have to provide all the info necessary for the solutions to compute the responses. For ex, if mass_flux
|
---|
103 | %is a response, we need a profile of points. For a misfit, we need the observed velocity, etc ...
|
---|
104 | md=process_qmu_response_data(md);
|
---|