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

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

Not the right place

File size: 3.7 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
14% overwrite: overwrite qmudir
15% outfiles: (John?)
16% rstfile: backup file name
17% rundakota: (John?)
18% runmpi: (John?)
19
20global ISSM_DIR;
21
[2330]22displaystring(md.verbose,'\n%s\n','preprocessing dakota inputs');
[963]23
24%first create temporary directory in which we will work
25if exist(options.qmudir,'dir')
26 if ~isfield(options,'overwrite')
[3054]27 %if exist(options.qmudir)==7,
28 % options.overwrite=input(['Overwrite existing ''' options.qmudir ''' directory? Y/N [N]: '], 's');
29 %else
[2206]30 options.overwrite='y';
[3054]31 %end
[2206]32
[963]33 end
34 if strncmpi(options.overwrite,'y',1)
[1029]35 system(['rm -rf ' options.qmudir '/*']);
[963]36% else
37% error('Existing ''%s'' directory not overwritten.',qmudir);
38 end
39end
40mkdir(options.qmudir)
41cd(options.qmudir)
42
43%when running in library mode, the in file needs to be called md.name.qmu.in
44options.qmufile=[md.name ];
45
46%retrieve variables and resposnes for this particular analysis.
47variables=md.variables(options.ivar);
48responses=md.responses(options.iresp);
49
50%create m and in files for dakota
[2161]51dakota_in_data(md.qmu_method(options.imethod),variables,md.responses,md.qmu_params(options.iparams),options.qmufile,md);
[963]52
53%in library mode, we only need the dakota in file
54system(['rm -rf ' md.name '.m']);
55
56%figure out number of variables and responses, it's not straightforwared
57numvariables=0;
58variable_fieldnames=fieldnames(variables);
59for i=1:length(variable_fieldnames),
60 field_name=variable_fieldnames{i};
61 fieldvariables=variables.(field_name);
62 numvariables=numvariables+numel(variables.(field_name));
63end
64
65numresponses=0;
66response_fieldnames=fieldnames(responses);
67for i=1:length(response_fieldnames),
68 field_name=response_fieldnames{i};
69 fieldresponses=responses.(field_name);
70 numresponses=numresponses+numel(responses.(field_name));
71end
72
73%ok, now, for this particular qmu analysis, iresp and ivar specifiy the variables and responses.
74%The Qmu module will need a list of variable descriptors and response descriptors.
75%For ease of use, we gather this list here.
76
77count=0;
78variable_fieldnames=fieldnames(variables);
79variabledescriptors={};
80for i=1:length(variable_fieldnames),
81 field_name=variable_fieldnames{i};
82 fieldvariables=variables.(field_name);
83 for j=1:length(fieldvariables),
84 descriptor=fieldvariables(j).descriptor;
85 variabledescriptors{end+1}=descriptor;
86 count=count+1;
87 end
88end
89
90count=0;
91response_fieldnames=fieldnames(responses);
92responsedescriptors={};
93for i=1:length(response_fieldnames),
94 field_name=response_fieldnames{i};
95 fieldresponses=responses.(field_name);
96 for j=1:length(fieldresponses),
97 descriptor=fieldresponses(j).descriptor;
98 responsedescriptors{end+1}=descriptor;
99 count=count+1;
100 end
101end
102
103%register the fields that will be needed by the Qmu model.
104md.numberofvariables=numvariables;
105md.numberofresponses=numresponses;
106md.variabledescriptors=variabledescriptors;
107md.responsedescriptors=responsedescriptors;
108
[2110]109%now, we have to provide all the info necessary for the solutions to compute the responses. For ex, if mass_flux
[4761]110%is a response, we need a profile of points. For a misfit, we need the observed velocity, etc ...
[2110]111md=process_qmu_response_data(md);
Note: See TracBrowser for help on using the repository browser.