Skip to content

Commit dd4ba59

Browse files
vohramanavdmcdougall
authored andcommitted
initiated a new chaper for sensitivity analysis
1 parent fc3e05d commit dd4ba59

File tree

8 files changed

+499
-4
lines changed

8 files changed

+499
-4
lines changed
129 KB
Binary file not shown.

manual/users/sensitivity_mc.C

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include <cmath>
2+
#include <fstream>
3+
#include <iomanip> // for setprecision
4+
5+
#include <queso/GslVector.h>
6+
#include <queso/GslMatrix.h>
7+
#include <sensitivity_mc.h>
8+
9+
template<class P_V, class P_M, class Q_V, class Q_M>
10+
Qoi_mc<P_V, P_M, Q_V, Q_M>::Qoi_mc(const char * prefix,
11+
const QUESO::VectorSet<P_V, P_M> & domainSet,
12+
const QUESO::VectorSet<Q_V, Q_M> & imageSet)
13+
: QUESO::BaseVectorFunction<P_V, P_M, Q_V, Q_M>(prefix, domainSet, imageSet),
14+
x_loc(3)
15+
{
16+
}
17+
18+
template<class P_V, class P_M, class Q_V, class Q_M>
19+
Qoi_mc<P_V, P_M, Q_V, Q_M>::~Qoi_mc()
20+
{
21+
// Deconstruct here
22+
}
23+
24+
template<class P_V, class P_M, class Q_V, class Q_M>
25+
void
26+
Qoi_mc<P_V, P_M, Q_V, Q_M>::compute(const P_V & domainVector,
27+
const P_V * domainDirection,
28+
Q_V & imageVector, QUESO::DistArray<P_V *> * gradVectors,
29+
QUESO::DistArray<P_M *> * hessianMatrices,
30+
QUESO::DistArray<P_V *> * hessianEffects) const
31+
{
32+
if (domainVector.sizeLocal() != 2) {
33+
queso_error_msg("domainVector does not have size 2");
34+
}
35+
if (imageVector.sizeLocal() != 1) {
36+
queso_error_msg("imageVector does not have size 1");
37+
}
38+
39+
qoi_samples.open ("c_qoi_samplesAi.txt", std::fstream::in | std::fstream::out | std::fstream::app);
40+
41+
// ----Generate Qoi using samples from a text files -------------
42+
count++;
43+
samples.open ("./files_sense/c_samples_Ai.txt", std::fstream::in | std::fstream::out | std::fstream::app);
44+
45+
int cou = 1;
46+
47+
while (samples >> mf >> cf){
48+
if (cou == count){
49+
m = mf;
50+
c = cf;
51+
break;
52+
}
53+
cou++;
54+
}
55+
56+
// ------- Generate Qoi using pseudo-random MC samples ------------
57+
// std::cout << "m = " << domainVector[0] << std::endl;
58+
// m = domainVector[0]; // Sample of the RV 'line slope'
59+
// c = domainVector[1]; // Sample of the RV 'y-intercept'
60+
double y_obs = 0.0;
61+
y_obs = m*x_loc + c;
62+
63+
qoi_samples << std::setprecision(4) << y_obs << "\t\t" << m << "\t\t" << c << std::endl;
64+
65+
imageVector[0] = y_obs;
66+
qoi_samples.close();
67+
samples.close();
68+
}
69+
70+
template class Qoi_mc<QUESO::GslVector, QUESO::GslMatrix, QUESO::GslVector,
71+
QUESO::GslMatrix>;

manual/users/sensitivity_mc.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ifndef QUESO_EXAMPLE_SENSITIVITY_MC_H
2+
#define QUESO_EXAMPLE_SENSITIVITY_MC_H
3+
4+
#include <queso/VectorFunction.h>
5+
#include <queso/DistArray.h>
6+
#include <fstream>
7+
8+
template<class P_V = QUESO::GslVector, class P_M = QUESO::GslMatrix,
9+
class Q_V = QUESO::GslVector, class Q_M = QUESO::GslMatrix>
10+
class Qoi_mc : public QUESO::BaseVectorFunction<P_V, P_M, Q_V, Q_M>
11+
{
12+
public:
13+
Qoi_mc(const char * prefix, const QUESO::VectorSet<P_V, P_M> & domainSet,
14+
const QUESO::VectorSet<Q_V, Q_M> & imageSet);
15+
virtual ~Qoi_mc();
16+
virtual void compute(const P_V & domainVector, const P_V * domainDirection,
17+
Q_V & imageVector, QUESO::DistArray<P_V *> * gradVectors,
18+
QUESO::DistArray<P_M *> * hessianMatrices,
19+
QUESO::DistArray<P_V *> * hessianEffects) const;
20+
21+
private:
22+
double x_loc;
23+
mutable double m,c,mf,cf,count;
24+
mutable std::fstream qoi_samples;
25+
mutable std::fstream samples;
26+
27+
};
28+
29+
#endif
30+

manual/users/uq.bib

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,3 +1112,122 @@ @Misc{wiki:ablation
11121112
OPTkeywords = {},
11131113
}
11141114

1115+
@article{Cukier:1973,
1116+
title={Study of the sensitivity of coupled reaction systems to uncertainties in rate coefficients. {I} Theory},
1117+
author={Cukier, R.I. and Fortuin, C.M. and Shuler, K.E. and Petschek, A.G. and Schaibly, J.H.},
1118+
journal={The Journal of chemical physics},
1119+
volume={59},
1120+
number={8},
1121+
pages={3873--3878},
1122+
year={1973},
1123+
publisher={AIP Publishing}
1124+
}
1125+
1126+
@article{Sobol:1990,
1127+
title={On sensitivity estimation for nonlinear mathematical models},
1128+
author={Sobol', I.M.},
1129+
journal={Matematicheskoe Modelirovanie},
1130+
volume={2},
1131+
number={1},
1132+
pages={112--118},
1133+
year={1990},
1134+
publisher={Russian Academy of Sciences, Branch of Mathematical Sciences}
1135+
}
1136+
1137+
@book{Saltelli:2008,
1138+
title={Global sensitivity analysis: the primer},
1139+
author={Saltelli, A. and Ratto, M. and Andres, T. and Campolongo, F. and Cariboni, J. and Gatelli, D. and Saisana, M. and Tarantola, S.},
1140+
year={2008},
1141+
publisher={John Wiley \& Sons}
1142+
}
1143+
1144+
@article{Xiu:2002,
1145+
title={The Wiener--Askey polynomial chaos for stochastic differential equations},
1146+
author={Xiu, D. and Karniadakis, G.E.},
1147+
journal={SIAM journal on scientific computing},
1148+
volume={24},
1149+
number={2},
1150+
pages={619--644},
1151+
year={2002},
1152+
publisher={SIAM}
1153+
}
1154+
1155+
@book{Ghanem:2003,
1156+
title={Stochastic finite elements: a spectral approach},
1157+
author={Ghanem, R.G. and Spanos, P.D.},
1158+
year={2003},
1159+
publisher={Courier Corporation}
1160+
}
1161+
1162+
@article{Gutmann:2001,
1163+
title={A radial basis function method for global optimization},
1164+
author={Gutmann, H-M},
1165+
journal={Journal of Global Optimization},
1166+
volume={19},
1167+
number={3},
1168+
pages={201--227},
1169+
year={2001},
1170+
publisher={Springer}
1171+
}
1172+
1173+
@article{Saltelli:2010,
1174+
title={Variance based sensitivity analysis of model output. Design and estimator for the total sensitivity index},
1175+
author={Saltelli, A. and Annoni, P. and Azzini, I. and Campolongo, F. and Ratto, M. and Tarantola, S.},
1176+
journal={Computer Physics Communications},
1177+
volume={181},
1178+
number={2},
1179+
pages={259--270},
1180+
year={2010},
1181+
publisher={Elsevier}
1182+
}
1183+
1184+
@article{Jansen:1999,
1185+
title={Analysis of variance designs for model output},
1186+
author={Jansen, M.J.W.},
1187+
journal={Computer Physics Communications},
1188+
volume={117},
1189+
number={1},
1190+
pages={35--43},
1191+
year={1999},
1192+
publisher={Elsevier}
1193+
}
1194+
1195+
@article{Homma:1996,
1196+
title={Importance measures in global sensitivity analysis of nonlinear models},
1197+
author={Homma, T. and Saltelli, A.},
1198+
journal={Reliability Engineering \& System Safety},
1199+
volume={52},
1200+
number={1},
1201+
pages={1--17},
1202+
year={1996},
1203+
publisher={Elsevier}
1204+
}
1205+
1206+
@article{Sobol:2007,
1207+
title={Global sensitivity indices for the investigation of nonlinear mathematical models},
1208+
author={Sobol', I.M.},
1209+
journal={Matematicheskoe Modelirovanie},
1210+
volume={19},
1211+
number={11},
1212+
pages={23--24},
1213+
year={2007},
1214+
publisher={Russian Academy of Sciences, Branch of Mathematical Sciences}
1215+
}
1216+
1217+
@article{Vohra:2014,
1218+
title={Development of a reduced model of formation reactions in Zr-Al nanolaminates},
1219+
author={Vohra, M. and Winokur, J. and Overdeep, K.R. and Marcello, P. and Weihs, T.P. and Knio, O.M.},
1220+
journal={Journal of Applied Physics},
1221+
volume={116},
1222+
number={23},
1223+
pages={233501},
1224+
year={2014},
1225+
publisher={AIP Publishing}
1226+
}
1227+
1228+
@article{Vohra:2016,
1229+
title={Design Analysis for Optimal Calibration of Diffusivity in Reactive Multilayers},
1230+
author={Vohra, M. and Huan, X. and Weihs, T.P. and Knio, O.M.},
1231+
journal={arXiv preprint arXiv:1610.02558},
1232+
year={2016}
1233+
}

manual/users/users.tex

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
\usepackage{rotating}
1111
\usepackage{color}
1212
\usepackage{url}
13+
\usepackage{bm}
14+
\usepackage{multirow}
15+
\usepackage{booktabs}
16+
\usepackage{algorithm}
17+
\usepackage{algpseudocode}
18+
\usepackage{amsmath,amssymb}
1319
\usepackage{fancyvrb}
1420
\usepackage{subfig}
1521
\usepackage{wrapfig}
@@ -20,8 +26,10 @@
2026
\usepackage{geometry}
2127
\geometry{top=1.00in, bottom=1.00in, left=1.00in, right=1.00in}
2228
\usepackage{enumerate}
23-
\usepackage[algoruled,vlined,linesnumbered,english]{algorithm2e}
29+
\usepackage[algoruled,vlined,linesnumbered,english,algo2e]{algorithm2e}
2430
\SetAlFnt{\footnotesize}
31+
\DeclareMathOperator{\E}{\mathbb{E}}
32+
\DeclareMathOperator{\V}{\mathbb{V}}
2533

2634
\usepackage{titlesec}
2735
\titleformat{\section}{\LARGE\sffamily}{\thesection}{1em}{}
@@ -76,6 +84,8 @@
7684
\newcommand{\post}{\text{posterior}}
7785
\newcommand{\prior}{\text{prior}}
7886
\newcommand{\D}{ {\bf D}}
87+
\newcommand{\be}{\begin{equation}}
88+
\newcommand{\ee}{\end{equation}}
7989
8090
\newcommand{\myverb}[1]{ \indent{ \begin{verbatim} #1 \end{verbatim} } }
8191
\newcommand{\QUESOversion}{0.51.0}
@@ -131,6 +141,10 @@
131141
%\newcommand{\new}[1]{\reversemarginpar{\color{red}\tiny\raggedright\textsf{\hspace{-30pt}\vspace{-25pt} NEW}} \begin{leftbar} #1 \end{leftbar}}
132142
\newcommand{\new}[1]{#1}
133143
144+
\makeatletter
145+
\def\BState{\State\hskip-\ALG@thistlm}
146+
\makeatother
147+
134148
\begin{document}
135149
136150
\setlength{\unitlength}{1.0in}
@@ -155,6 +169,8 @@
155169
156170
\include{users_4_remarks}
157171
172+
\include{users_gsa}
173+
158174
\include{users_5_examples}
159175
160176

manual/users/users_3_classes.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ \subsection{Multilevel Solver (and Options)}\label{sec:ML}
717717

718718
%\clearpage
719719
\subsection{Statistical Forward Problem (and Options)}
720+
\label{sub:SFP}
720721

721722
A SFP in QUESO also has two input entities, the input (parameter) RV and a QoI function, and one output entity, the QoI RV.
722723
The SIP is represented through the templated class \verb+StatisticalForwardProblem<P_V,P_M,Q_V,Q_M >+, which diagram is presented in Figure \ref{fig-sfp-class}. Again, the types \verb+P_V+ and \verb+Q_V+ of vectors and types \verb+P_M+ and \verb+Q_M+ of matrices, where \verb+P_+ stands for 'parameter' and \verb+Q_+ stands for 'quantities of interest'.

manual/users/users_5a_example_sip.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ \subsection{Example Code}\label{sec:sip-code}
133133

134134
\lstinputlisting[caption=File \texttt{example\_likelihood.h}., label={fig-like-h}, linerange={25-1000}]{../../examples/simpleStatisticalInverseProblem/src/example_likelihood.h}
135135

136-
\newpage
136+
%\newpage
137137

138138
\lstinputlisting[caption=File \texttt{example\_likelihood.C}., label={fig-like-c}, linerange={25-1000}]{../../examples/simpleStatisticalInverseProblem/src/example_likelihood.C}
139139

140-
\newpage
140+
%\newpage
141141

142142
\lstinputlisting[caption=File \texttt{example\_compute.h.}, label={code:sip-compute-h}, linerange={25-1000}]{../../examples/simpleStatisticalInverseProblem/src/example_compute.h}
143143

@@ -350,7 +350,7 @@ \subsubsection{Covariance and Correlation Matrices}
350350

351351
Listing \ref{matlab:cov_matrix} presents the Matlab steps for calculating the covariance and correlation matrices for the parameters $\theta_1$ and $\theta_2$.
352352

353-
\newpage
353+
%\newpage
354354

355355
\begin{lstlisting}[label=matlab:ip_cov_matrix,caption={Matlab code for finding covariance and correlation matrices.}]
356356
% inside Matlab

0 commit comments

Comments
 (0)