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