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

Last change on this file since 6615 was 6615, checked in by jschierm, 14 years ago

preqmu.m: Fixed capability to have multiple variables/responses in a field. Also fixed capability for multiple variable/response sets.

File size: 4.2 KB
RevLine 
[963]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
[6568]14% overwrite: overwrite qmudir before analysis
15% keep: keep qmudir after analysis
[963]16% outfiles: (John?)
17% rstfile: backup file name
18% rundakota: (John?)
19% runmpi: (John?)
20
[6088]21global ISSM_TIER;
[963]22
[6309]23disp('preprocessing dakota inputs');
[963]24
25%first create temporary directory in which we will work
[5029]26if strncmpi(options.overwrite,'y',1)
27 system(['rm -rf ' options.qmudir '/*']);
28else
29 %does the directory exist? if so, then error out
30 if exist(options.qmudir)==7,
31 error('Existing ''%s'' directory, cannot overwrite. Specify ''overwrite'',''y'' option in solve arguments.',options.qmudir);
32 end
[963]33end
34mkdir(options.qmudir)
35cd(options.qmudir)
36
37%when running in library mode, the in file needs to be called md.name.qmu.in
38options.qmufile=[md.name ];
39
40%retrieve variables and resposnes for this particular analysis.
41variables=md.variables(options.ivar);
42responses=md.responses(options.iresp);
43
[5487]44%expand variables and responses
[6615]45variables=expandvariables(md,variables);
46responses=expandresponses(md,responses);
[5215]47
[5487]48%go through variables and responses, and check they don't have more than md.npart values. Also determine numvariables and numresponses{{{1
49numvariables=0;
[5215]50variable_fieldnames=fieldnames(variables);
51for i=1:length(variable_fieldnames),
52 field_name=variable_fieldnames{i};
53 fieldvariables=variables.(field_name);
[6615]54 for j=1:numel(fieldvariables)
55 if strncmpi(fieldvariables(j).descriptor,'scaled_',7) && str2int(fieldvariables(j).descriptor,'last')>md.npart,
56 error('preqmu error message: one of the expanded variables has more values than the number of partitions (setup in md.npart)');
57 end
[5215]58 end
[963]59 numvariables=numvariables+numel(variables.(field_name));
60end
61
62numresponses=0;
63response_fieldnames=fieldnames(responses);
64for i=1:length(response_fieldnames),
65 field_name=response_fieldnames{i};
66 fieldresponses=responses.(field_name);
[6615]67 for j=1:numel(fieldresponses)
68 if strncmpi(fieldresponses(j).descriptor,'scaled_',7) && str2int(fieldresponses(j).descriptor,'last')>md.npart,
69 error('preqmu error message: one of the expanded responses has more values than the number of partitions (setup in md.npart)');
70 end
[5487]71 end
[963]72 numresponses=numresponses+numel(responses.(field_name));
73end
[5487]74%}}}}
[963]75
[5487]76%create in file for dakota
77dakota_in_data(md.qmu_method(options.imethod),variables,responses,md.qmu_params(options.iparams),options.qmufile);
78system(['rm -rf ' md.name '.m']);
[963]79
[5487]80%build a list of variables and responses descriptors. the list is not expanded. {{{1
[963]81variabledescriptors={};
[6615]82variable_fieldnames=fieldnames(md.variables(options.ivar));
[963]83for i=1:length(variable_fieldnames),
84 field_name=variable_fieldnames{i};
[6615]85 fieldvariables=md.variables(options.ivar).(field_name);
86 for j=1:numel(fieldvariables)
87 variabledescriptors{end+1}=fieldvariables(j).descriptor;
88 end
[963]89end
90
91responsedescriptors={};
[6615]92response_fieldnames=fieldnames(md.responses(options.iresp));
[963]93for i=1:length(response_fieldnames),
94 field_name=response_fieldnames{i};
[6615]95 fieldresponses=md.responses(options.iresp).(field_name);
96 for j=1:numel(fieldresponses)
97 responsedescriptors{end+1}=fieldresponses(j).descriptor;
98 end
[963]99end
[5487]100%}}}
[963]101
102%register the fields that will be needed by the Qmu model.
103md.numberofvariables=numvariables;
104md.numberofresponses=numresponses;
105md.variabledescriptors=variabledescriptors;
106md.responsedescriptors=responsedescriptors;
[5487]107md.numvariabledescriptors=numel(md.variabledescriptors);
108md.numresponsedescriptors=numel(md.responsedescriptors);
[963]109
[2110]110%now, we have to provide all the info necessary for the solutions to compute the responses. For ex, if mass_flux
[4761]111%is a response, we need a profile of points. For a misfit, we need the observed velocity, etc ...
[2110]112md=process_qmu_response_data(md);
Note: See TracBrowser for help on using the repository browser.