MAST
pk_flutter_solution.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2019 Manav Bhatia
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 // C++ includes
21 #include <iomanip>
22 
23 
24 // MAST includes
28 
29 
30 void
32  const Real k_red,
33  const Real v_ref,
34  const Real bref,
35  const RealMatrixX& kmat,
36  const LAPACK_ZGGEV& eig_sol) {
37 
38  // make sure that it hasn't already been initialized
39  libmesh_assert(!_roots.size());
40 
41  _ref_val = v_ref;
42  _k_red = k_red;
43  _stiff_mat = kmat;
44 
45  // iterate over the roots and initialize the vector
46  _Amat = eig_sol.A();
47  _Bmat = eig_sol.B();
48 
49  const ComplexMatrixX
50  &VR = eig_sol.right_eigenvectors(),
51  &VL = eig_sol.left_eigenvectors();
52  const ComplexVectorX
53  &num = eig_sol.alphas(),
54  &den = eig_sol.betas();
55 
56  unsigned int
57  nvals = (unsigned int)_Bmat.rows();
58 
59  _roots.resize(nvals);
60 
61  // iterate over the roots and initialize the vector
62  for (unsigned int i=0; i<nvals; i++) {
63 
65  root->init(k_red,
66  v_ref,
67  bref,
68  num(i),
69  den(i),
70  kmat,
71  VR.col(i),
72  VL.col(i));
73 
74  _roots[i] = root;
75  }
76 }
77 
78 
79 
80 void
82 {
83  const unsigned int nvals = this->n_roots();
84  libmesh_assert_equal_to(nvals, sol.n_roots());
85 
86  // two roots with highest modal_participation dot product are sorted
87  // in the same serial order
88  for (unsigned int i=0; i<nvals-1; i++)
89  {
90  const MAST::FlutterRootBase& r = sol.get_root(i);
91  Real max_val = 0.;
92  Complex val = 0.;
93  unsigned int max_val_root = nvals-1;
94  for (unsigned int j=i; j<nvals; j++) {
95 
96  val = r.eig_vec_left.dot(_Bmat*_roots[j]->eig_vec_right);
97  //_roots[j]->modal_participation.dot(r.modal_participation);
98  // scale by the eigenvalue separation with the assumption that
99  // the roots will be closer to each other than any other
100  // root at two consecutive eigenvalues. In other words,
101  // we are penalizing the dot product with the eigenvalue
102  // distance
103  val /= abs(r.root-_roots[j]->root);
104  if (abs(val) > max_val) {
105  max_val = abs(val);
106  max_val_root = j;
107  }
108  }
109 
110  // now we should have the one with highest dot product
111  std::swap(_roots[i], _roots[max_val_root]);
112  }
113 }
114 
115 
116 
117 
118 
119 
120 
121 void
122 MAST::PKFlutterSolution::print(std::ostream &output)
123 {
124  // make sure that some roots exist for this solution
125  libmesh_assert(this->n_roots() > 0);
126 
127  const unsigned int nvals = this->n_roots();
128  unsigned int n_participation_vals =
129  (unsigned int)this->get_root(0).modal_participation.size();
130  libmesh_assert(nvals);
131 
132  // first write the reference values of the root
133  output << " Flutter Root " << std::endl;
134 
135  // now write the root
136  output
137  << std::setw(5) << "#"
138  << std::setw(15) << "k_ref"
139  << std::setw(15) << "V_ref"
140  << std::setw(15) << "g"
141  << std::setw(15) << "omega"
142  << std::setw(15) << "Re"
143  << std::setw(15) << "Im"
144  << std::setw(3) << " | ";
145 
146  // output the headers for flutter mode participation
147  for (unsigned int i=0; i<n_participation_vals; i++)
148  output
149  << std::setw(2) << " "
150  << std::setw(5) << "Mode "
151  << std::setw(5) << i
152  << std::setw(2) << " ";
153 
154  // output the headers for flutter mode
155  for (unsigned int i=0; i<nvals; i++)
156  output
157  << std::setw(10) << "| "
158  << std::setw(5) << "Mode "
159  << std::setw(5) << i
160  << std::setw(10) << " |";
161  output << std::endl;
162 
163  for (unsigned int i=0; i<nvals; i++)
164  {
165  const MAST::FlutterRootBase& root = this->get_root(i);
166 
167  if (root.if_nonphysical_root)
168  {
169  std::stringstream oss;
170  oss << "**" << i;
171  output << std::setw(5) << oss.str();
172  }
173  else
174  output << std::setw(5) << i;
175 
176  // flutter root details
177  output
178  << std::setw(15) << root.kr
179  << std::setw(15) << root.V
180  << std::setw(15) << root.g
181  << std::setw(15) << root.omega
182  << std::setw(15) << std::real(root.root)
183  << std::setw(15) << std::imag(root.root)
184  << std::setw(3) << " | ";
185 
186  // now write the modal participation
187  for (unsigned int j=0; j<n_participation_vals; j++)
188  output
189  << std::setw(12) << root.modal_participation(j)
190  << std::setw(2) << " ";
191 
192  // now write the flutter mode
193  for (unsigned int j=0; j<nvals; j++)
194  {
195  output
196  << std::setw(2) << "| "
197  << std::setw(12) << std::real(root.eig_vec_right(j))
198  << std::setw(2) << " "
199  << std::setw(12) << std::imag(root.eig_vec_right(j))
200  << std::setw(2) << " |";
201  }
202  output << std::endl;
203  }
204 }
205 
206 
207 
const MAST::FlutterRootBase & get_root(const unsigned int i) const
ComplexVectorX eig_vec_left
virtual void sort(const MAST::FlutterSolutionBase &sol)
sort this root with respect to the given solution from a previous eigen solution. ...
std::vector< MAST::FlutterRootBase * > _roots
RealMatrixX _stiff_mat
structural stiffness matrix
const ComplexMatrixX & left_eigenvectors() const
Matrix< Complex, Dynamic, 1 > ComplexVectorX
Real _k_red
value of reduced frequency for this solution
const ComplexMatrixX & B() const
libMesh::Real Real
libMesh::Complex Complex
unsigned int n_roots() const
number of roots in this solution
const ComplexMatrixX & right_eigenvectors() const
Matrix< Real, Dynamic, Dynamic > RealMatrixX
Matrix< Complex, Dynamic, Dynamic > ComplexMatrixX
virtual void init(const Real k_red_val, const Real V_ref, const Real b_ref, const Complex num, const Complex den, const RealMatrixX &Kmat, const ComplexVectorX &evec_right, const ComplexVectorX &evec_left)
const ComplexVectorX & betas() const
virtual void print(std::ostream &output)
prints the data and modes from this solution
Real _ref_val
Reference value of the sweeping parameter for which this solution was obtained.
ComplexMatrixX _Amat
Matrix used for scaling of eigenvectors, and sorting of roots.
const ComplexMatrixX & A() const
virtual void init(const MAST::PKFlutterSolver &solver, const Real k_red, const Real v_ref, const Real bref, const RealMatrixX &kmat, const MAST::LAPACK_ZGGEV &eig_sol)
initializes the flutter solution from an eigensolution
const ComplexVectorX & alphas() const
RealVectorX modal_participation
ComplexVectorX eig_vec_right
right and left eigenvevtors