MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
beam_piston_theory_flutter.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/structural/beam_piston_theory_flutter/beam_piston_theory_flutter.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 (Structural1DBeamPistonTheoryFlutterAnalysis,
39  MAST::BeamPistonTheoryFlutterAnalysis)
40 
41 /*
42 BOOST_AUTO_TEST_CASE (BeamPistonTheoryFlutterSolution) {
43 
44 
45  const Real
46  tol = 1.e-2;
47 
48  std::vector<Real>
49  eig;
50 
51  this->solve(false, &eig);
52 
53  // check the solution
54  // iterate over each node, and compare the nodal solution with the
55  // expected anlaytical value
56  Real
57  th_y = (*_thy)(),
58  th_z = (*_thz)(),
59  Izz = pow(th_z,1)*pow(th_y,3)/12.,
60  A = th_z*th_y,
61  rho = (*_rho)(),
62  Eval = (*_E)(),
63  pi = acos(-1.),
64  analytical = 0.;
65 
66 
67  // analytical solution to the natural frequency of simply supported problem
68  // is
69  // lambda = omega^2 = (n pi/L)^4 EI/(rho A)
70  //
71  unsigned int
72  nconv = std::min(_sys->get_n_converged_eigenvalues(),
73  _sys->get_n_requested_eigenvalues());
74 
75  for (unsigned int i=0; i<nconv; i++) {
76 
77  analytical = Eval*Izz/(rho*A) * pow((i+1)*pi/_length, 4);
78 
79  // compare the eigenvalues
80  BOOST_CHECK(MAST::compare_value(analytical, eig[i], tol));
81  }
82 }
83 */
84 
85 
86 BOOST_AUTO_TEST_CASE (BeamPistonTheoryFlutterSolutionSensitivity) {
87 
88  const Real
89  delta = 1.e-5,
90  tol = 1.e-3;
91 
92  Real
93  V0 = 0.,
94  dV = 0.,
95  dV_fd = 0.;
96 
97  this->init(libMesh::EDGE2, false);
98 
99  std::vector<Real>
100  eig_vec,
101  deig_vec;
102 
103  V0 = this->solve(false);
104 
105  // now iterate over all the parameters and calculate the analytical
106  // sensitivity and compare with the numerical sensitivity
107 
108  Real
109  p0 = 0.,
110  dp = 0.;
111 
113  // now evaluate the direct sensitivity
115 
116  for (unsigned int i=0; i<this->_params_for_sensitivity.size(); i++ ) {
117 
118  MAST::Parameter& f = *this->_params_for_sensitivity[i];
119 
120  // calculate the analytical sensitivity
121  // analysis is required at the baseline before sensitivity solution
122  // and the solution has changed after the previous perturbed solution
123  this->solve(false, 1.e-4, 100);
124  dV = this->sensitivity_solve(f);
125 
126  // now calculate the finite difference sensitivity
127 
128  // identify the perturbation in the parameter
129  p0 = f();
130  (fabs(p0) > 0)? dp=delta*p0 : dp=delta;
131  f() += dp;
132 
133  // solve at the perturbed parameter value
134  dV_fd = this->solve(false);
135 
136  dV_fd -= V0;
137  dV_fd /= dp;
138 
139  // reset the parameter value
140  f() = p0;
141 
142  // now compare the eigenvalue sensitivity
143  BOOST_TEST_MESSAGE(" ** dV_F/dp (total) wrt : " << f.name() << " **");
144  BOOST_CHECK(MAST::compare_value( dV_fd, dV, tol));
145  }
146 }
147 
148 BOOST_AUTO_TEST_SUITE_END()
149 
150 
151 
const std::string & name() const
returns the name of this function
Definition: function_base.h:60
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)
BOOST_FIXTURE_TEST_SUITE(Structural1DBeamPistonTheoryFlutterAnalysis, MAST::BeamPistonTheoryFlutterAnalysis) BOOST_AUTO_TEST_CASE(BeamPistonTheoryFlutterSolutionSensitivity)