MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
beam_buckling_analysis.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_buckling_prestress/beam_column_buckling.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 (Structural1DBeamBucklingAnalysis,
39  MAST::BeamColumnBucklingAnalysis)
40 
41 BOOST_AUTO_TEST_CASE (BeamBucklingSolution) {
42 
43  this->init(libMesh::EDGE2, false);
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  sigma = (*_stress)(),
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)^2 EI/(-sigma A),
70  // where sigma is compressive
71  //
72  unsigned int
73  nconv = std::min(_sys->get_n_converged_eigenvalues(),
74  _sys->get_n_requested_eigenvalues());
75 
76  for (unsigned int i=0; i<nconv; i++) {
77 
78  analytical = Eval*Izz/(-sigma*A) * pow((i+1)*pi/_length, 2);
79 
80  // compare the eigenvalues
81  BOOST_CHECK(MAST::compare_value(analytical, eig[i], tol));
82  }
83 }
84 
85 
86 
87 //BOOST_AUTO_TEST_CASE (BeamBucklingSolutionSensitivity) {
88 //
89 // const Real
90 // delta = 1.e-5,
91 // tol = 1.e-3;
92 //
93 // std::vector<Real>
94 // eig_vec,
95 // deig_vec;
96 //
97 // this->solve(false, &eig_vec);
98 //
99 // unsigned int
100 // nconv = std::min(_sys->get_n_converged_eigenvalues(),
101 // _sys->get_n_requested_eigenvalues());
102 //
103 //
104 // // verify the sensitivity solution of this system
105 // RealVectorX
106 // eig = RealVectorX::Zero(nconv),
107 // deig = RealVectorX::Zero(nconv),
108 // deig_fd = RealVectorX::Zero(nconv);
109 //
110 // for (unsigned int i=0; i<nconv; i++) eig(i) = eig_vec[i];
111 //
112 //
113 // // now iterate over all the parameters and calculate the analytical
114 // // sensitivity and compare with the numerical sensitivity
115 //
116 // Real
117 // p0 = 0.,
118 // dp = 0.;
119 //
120 // /////////////////////////////////////////////////////////
121 // // now evaluate the direct sensitivity
122 // /////////////////////////////////////////////////////////
123 //
124 // for (unsigned int i=0; i<this->_params_for_sensitivity.size(); i++ ) {
125 //
126 // MAST::Parameter& f = *this->_params_for_sensitivity[i];
127 //
128 // // calculate the analytical sensitivity
129 // // analysis is required at the baseline before sensitivity solution
130 // // and the solution has changed after the previous perturbed solution
131 // this->solve(false, &eig_vec);
132 // std::vector<Real> deig_vec(nconv);
133 // this->sensitivity_solve(f, deig_vec);
134 // for (unsigned int i=0; i<nconv; i++) deig(i) = deig_vec[i];
135 //
136 // // now calculate the finite difference sensitivity
137 //
138 // // identify the perturbation in the parameter
139 // p0 = f();
140 // (fabs(p0) > 0)? dp=delta*p0 : dp=delta;
141 // f() += dp;
142 //
143 // // solve at the perturbed parameter value
144 // this->solve(false, &eig_vec);
145 // for (unsigned int i=0; i<nconv; i++) deig_fd(i) = eig_vec[i];
146 //
147 // deig_fd -= eig;
148 // deig_fd /= dp;
149 //
150 // // reset the parameter value
151 // f() = p0;
152 //
153 // // now compare the eigenvalue sensitivity
154 // BOOST_TEST_MESSAGE(" ** dlambda/dp (total) wrt : " << f.name() << " **");
155 // BOOST_CHECK(MAST::compare_vector( deig_fd, deig, tol));
156 // }
157 //}
158 
159 BOOST_AUTO_TEST_SUITE_END()
160 
161 
162 
libMesh::Real Real
BOOST_FIXTURE_TEST_SUITE(Structural1DBeamBucklingAnalysis, MAST::BeamColumnBucklingAnalysis) BOOST_AUTO_TEST_CASE(BeamBucklingSolution)
BOOST_AUTO_TEST_CASE(InternalForceJacobianZeroFreq)
bool compare_value(const Real v0, const Real v, const Real tol)
#define pi