[963] | 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 |
|
---|
[2330] | 22 | displaystring(md.verbose,'\n%s\n','preprocessing dakota inputs');
|
---|
[963] | 23 |
|
---|
| 24 | %first create temporary directory in which we will work
|
---|
| 25 | if 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
|
---|
| 39 | end
|
---|
| 40 | mkdir(options.qmudir)
|
---|
| 41 | cd(options.qmudir)
|
---|
| 42 |
|
---|
| 43 | %when running in library mode, the in file needs to be called md.name.qmu.in
|
---|
| 44 | options.qmufile=[md.name ];
|
---|
| 45 |
|
---|
| 46 | %retrieve variables and resposnes for this particular analysis.
|
---|
| 47 | variables=md.variables(options.ivar);
|
---|
| 48 | responses=md.responses(options.iresp);
|
---|
| 49 |
|
---|
| 50 | %create m and in files for dakota
|
---|
[2161] | 51 | dakota_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
|
---|
| 54 | system(['rm -rf ' md.name '.m']);
|
---|
| 55 |
|
---|
| 56 | %figure out number of variables and responses, it's not straightforwared
|
---|
| 57 | numvariables=0;
|
---|
| 58 | variable_fieldnames=fieldnames(variables);
|
---|
| 59 | for i=1:length(variable_fieldnames),
|
---|
| 60 | field_name=variable_fieldnames{i};
|
---|
| 61 | fieldvariables=variables.(field_name);
|
---|
| 62 | numvariables=numvariables+numel(variables.(field_name));
|
---|
| 63 | end
|
---|
| 64 |
|
---|
| 65 | numresponses=0;
|
---|
| 66 | response_fieldnames=fieldnames(responses);
|
---|
| 67 | for i=1:length(response_fieldnames),
|
---|
| 68 | field_name=response_fieldnames{i};
|
---|
| 69 | fieldresponses=responses.(field_name);
|
---|
| 70 | numresponses=numresponses+numel(responses.(field_name));
|
---|
| 71 | end
|
---|
| 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 |
|
---|
| 77 | count=0;
|
---|
| 78 | variable_fieldnames=fieldnames(variables);
|
---|
| 79 | variabledescriptors={};
|
---|
| 80 | for 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
|
---|
| 88 | end
|
---|
| 89 |
|
---|
| 90 | count=0;
|
---|
| 91 | response_fieldnames=fieldnames(responses);
|
---|
| 92 | responsedescriptors={};
|
---|
| 93 | for 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
|
---|
| 101 | end
|
---|
| 102 |
|
---|
| 103 | %register the fields that will be needed by the Qmu model.
|
---|
| 104 | md.numberofvariables=numvariables;
|
---|
| 105 | md.numberofresponses=numresponses;
|
---|
| 106 | md.variabledescriptors=variabledescriptors;
|
---|
| 107 | md.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] | 111 | md=process_qmu_response_data(md);
|
---|