MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
beam_flutter_sensitivity.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 
21 // BOOST includes
22 #include <boost/test/unit_test.hpp>
23 
24 
25 // MAST includes
26 #include "examples/fsi/beam_flutter_solution/beam_euler_fsi_flutter_solution.h"
27 #include "tests/base/test_comparisons.h"
29 #include "elasticity/structural_discipline.h"
31 #include "base/parameter.h"
35 #include "base/nonlinear_system.h"
36 
37 
38 BOOST_FIXTURE_TEST_SUITE (BeamFSISmallDisturbanceEulerFlutterAnalysis,
39  MAST::BeamEulerFSIFlutterAnalysis)
40 
41 
42 
43 BOOST_AUTO_TEST_CASE (BeamFSISmallDisturbanceEulerFlutterSensitivityAnalysis) {
44 
45  const Real
46  delta = 1.e-5,
47  tol = 1.e-3;
48 
49  Real
50  V0 = 0.,
51  dV = 0.,
52  dV_fd = 0.;
53 
54 
55  std::vector<Real>
56  eig_vec,
57  deig_vec;
58 
59  V0 = this->solve(false);
60 
61  // now iterate over all the parameters and calculate the analytical
62  // sensitivity and compare with the numerical sensitivity
63 
64  Real
65  p0 = 0.,
66  dp = 0.;
67 
69  // now evaluate the direct sensitivity
71 
72  for (unsigned int i=0; i<this->_params_for_sensitivity.size(); i++ ) {
73 
74  MAST::Parameter& f = *this->_params_for_sensitivity[i];
75 
76  // calculate the analytical sensitivity
77  // analysis is required at the baseline before sensitivity solution
78  // and the solution has changed after the previous perturbed solution
79  this->solve(false, 1.e-4, 100);
80  dV = this->sensitivity_solve(f);
81 
82  // now calculate the finite difference sensitivity
83 
84  // identify the perturbation in the parameter
85  p0 = f();
86  (fabs(p0) > 0)? dp=delta*p0 : dp=delta;
87  f() += dp;
88 
89  // solve at the perturbed parameter value
90  dV_fd = this->solve(false);
91 
92  dV_fd -= V0;
93  dV_fd /= dp;
94 
95  // reset the parameter value
96  f() = p0;
97 
98  // now compare the eigenvalue sensitivity
99  BOOST_TEST_MESSAGE(" ** dV_F/dp (total) wrt : " << f.name() << " **");
100  BOOST_CHECK(MAST::compare_value( dV_fd, dV, tol));
101  }
102 }
103 
104 BOOST_AUTO_TEST_SUITE_END()
105 
106 
107 
const std::string & name() const
returns the name of this function
Definition: function_base.h:60
BOOST_FIXTURE_TEST_SUITE(BeamFSISmallDisturbanceEulerFlutterAnalysis, MAST::BeamEulerFSIFlutterAnalysis) BOOST_AUTO_TEST_CASE(BeamFSISmallDisturbanceEulerFlutterSensitivityAnalysis)
This is a scalar function whose value can be changed and one that can be used as a design variable in...
Definition: parameter.h:35
libMesh::Real Real
BOOST_AUTO_TEST_CASE(InternalForceJacobianZeroFreq)
bool compare_value(const Real v0, const Real v, const Real tol)