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

Last change on this file since 5487 was 5487, checked in by Eric.Larour, 15 years ago

We now have a different number of responses and responses descriptors. Same thing
for variables. Makes processing of Qmu inputs a lot simpler.
Had to adapt qmu/ to this new scenario. We now have DescriptorIndex
that tells us whether a variable is scaled, indexed, nodal or regular.
We need to expand responses as well as variables.

File size: 3.8 KB
Line 
1function 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
20global ISSM_DIR;
21
22displaystring(md.verbose,'\n%s\n','preprocessing dakota inputs');
23
24%first create temporary directory in which we will work
25if strncmpi(options.overwrite,'y',1)
26 system(['rm -rf ' options.qmudir '/*']);
27else
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
32end
33mkdir(options.qmudir)
34cd(options.qmudir)
35
36%when running in library mode, the in file needs to be called md.name.qmu.in
37options.qmufile=[md.name ];
38
39%retrieve variables and resposnes for this particular analysis.
40variables=md.variables(options.ivar);
41responses=md.responses(options.iresp);
42
43%expand variables and responses
44variables=expandvariables(md,md.variables);
45responses=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
48numvariables=0;
49variable_fieldnames=fieldnames(variables);
50for 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));
57end
58
59numresponses=0;
60response_fieldnames=fieldnames(responses);
61for 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));
68end
69%}}}}
70
71%create in file for dakota
72dakota_in_data(md.qmu_method(options.imethod),variables,responses,md.qmu_params(options.iparams),options.qmufile);
73system(['rm -rf ' md.name '.m']);
74
75%build a list of variables and responses descriptors. the list is not expanded. {{{1
76variabledescriptors={};
77variable_fieldnames=fieldnames(md.variables);
78for i=1:length(variable_fieldnames),
79 field_name=variable_fieldnames{i};
80 variabledescriptors{end+1}=md.variables.(field_name).descriptor;
81end
82
83responsedescriptors={};
84response_fieldnames=fieldnames(md.responses);
85for i=1:length(response_fieldnames),
86 field_name=response_fieldnames{i};
87 responsedescriptors{end+1}=md.responses.(field_name).descriptor;
88end
89%}}}
90
91%register the fields that will be needed by the Qmu model.
92md.numberofvariables=numvariables;
93md.numberofresponses=numresponses;
94md.variabledescriptors=variabledescriptors;
95md.responsedescriptors=responsedescriptors;
96md.numvariabledescriptors=numel(md.variabledescriptors);
97md.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 ...
101md=process_qmu_response_data(md);
Note: See TracBrowser for help on using the repository browser.