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

Last change on this file since 9560 was 9560, checked in by Mathieu Morlighem, 14 years ago

removed md.numberofvariables

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