ATLAS Offline Software
Loading...
Searching...
No Matches
NswAsBuilt::ElementModelScaleSag Class Reference

An element model implementing the deformations used for the NSW MM as-built parameters. More...

#include <ElementModelScaleSag.h>

Inheritance diagram for NswAsBuilt::ElementModelScaleSag:
Collaboration diagram for NswAsBuilt::ElementModelScaleSag:

Public Types

enum  parameter_t {
  X =0 , Y =1 , Z =2 , THX =3 ,
  THY =4 , THZ =5 , EGX =6 , EGY =7 ,
  EGZ =8 , SAGX =9 , SAGY =10 , DEGX =11 ,
  DEGY =12 , PGX =13 , PGY =14 , DSAGX =15 ,
  DSAGY =16
}
using ipar_t = unsigned int
using VectorSet = Eigen::Matrix<double, 3, Eigen::Dynamic, Eigen::ColMajor|Eigen::AutoAlign, 3, 5>
using VectorSetRef = Eigen::Ref<VectorSet>

Public Member Functions

 ElementModelScaleSag (double lenX, double lenY, Amg::Vector3D defo0)
 ElementModelScaleSag ()=delete
virtual int nParameters () const override
virtual void transform (const ParameterVector &parvec, VectorSetRef local) const override
 Transform a set of vectors expressed in local frame, stored in a matrix.
virtual void cacheTransform (ParameterVector &parvec) const override
 Cache the rigid component of this deformation model.
virtual ipar_t getParameterIndex (const std::string &parname) const override
virtual std::string getParameterName (ipar_t ipar) const override

Private Member Functions

void applyDeformation (const ParameterVector &parvec, Eigen::Ref< Amg::Vector3D > local) const
void applyDeformation2 (const ParameterVector &parvec, VectorSetRef local) const
Amg::Vector3D DSagX (double sagx, const Amg::Vector3D &d0) const
Amg::Vector3D DSagY (double sagy, const Amg::Vector3D &d0) const
Amg::Vector3D DDSagX (double dsagx, const Amg::Vector3D &d0) const
Amg::Vector3D DDSagY (double dsagy, const Amg::Vector3D &d0) const
Amg::Vector3D DDegX (double degx, const Amg::Vector3D &d0) const
Amg::Vector3D DDegY (double degy, const Amg::Vector3D &d0) const
Amg::Vector3D DPgX (double pgx, const Amg::Vector3D &d0) const
Amg::Vector3D DPgY (double pgy, const Amg::Vector3D &d0) const

Static Private Member Functions

static Amg::Vector3D DEg (double egx, double egy, double egz, const Amg::Vector3D &d0)

Private Attributes

double m_lenX {0.}
double m_lenY {0.}
Amg::Vector3D m_defo0 {Amg::Vector3D::Zero()}

Detailed Description

An element model implementing the deformations used for the NSW MM as-built parameters.

The first 6 parameters represent the rigid component of the transform (a 3D translation and 3 Euler angles to be applied in the order ZYX)

The following parameters are providing deformations, as follows:

  • EGX, EGY, EGZ: elongations, expressed in permil units
  • SAGX and SAGY: bending along the X and Y directions, expressed in millimeter. SAGY(X) leaves unchanged the points at X(Y) = +- 0.5*lenX(Y), and they move the center point by SAGY(X), respectively
  • DEGX, DEGY: gradients en elongation along X and Y. The elongation along Y(X) at points X(Y) = +- 0.5*lenX(Y) is EGY(X)+-DEGY(X), respectively. Expressed in permil units.
  • PGX, PGY: Paralellogram (shear) transforms, expressed in millimeters. PGX(Y) is the displacement along X(Y) of point at Y(X)=0.5*lenY(X). Central point is not moved
  • DSAGX, DSAGY: gradients of sag along X and Y. sag along Y(X) at Y(X)=0 is unchanged by this transform, and is increased by DSAGY(X) at Y(X)=0.5*lenY

Definition at line 35 of file ElementModelScaleSag.h.

Member Typedef Documentation

◆ ipar_t

using NswAsBuilt::ElementModel::ipar_t = unsigned int
inherited

Definition at line 35 of file ElementModel.h.

◆ VectorSet

using NswAsBuilt::ElementModel::VectorSet = Eigen::Matrix<double, 3, Eigen::Dynamic, Eigen::ColMajor|Eigen::AutoAlign, 3, 5>
inherited

Definition at line 36 of file ElementModel.h.

◆ VectorSetRef

using NswAsBuilt::ElementModel::VectorSetRef = Eigen::Ref<VectorSet>
inherited

Definition at line 37 of file ElementModel.h.

Member Enumeration Documentation

◆ parameter_t

Enumerator
THX 
THY 
THZ 
EGX 
EGY 
EGZ 
SAGX 
SAGY 
DEGX 
DEGY 
PGX 
PGY 
DSAGX 
DSAGY 

Definition at line 37 of file ElementModelScaleSag.h.

37 {
38 X=0,
39 Y=1,
40 Z=2,
41 THX=3,
42 THY=4,
43 THZ=5,
44 EGX=6,
45 EGY=7,
46 EGZ=8,
47 SAGX=9,
48 SAGY=10,
49 DEGX=11,
50 DEGY=12,
51 PGX=13,
52 PGY=14,
53 DSAGX=15,
54 DSAGY=16
55 };

Constructor & Destructor Documentation

◆ ElementModelScaleSag() [1/2]

ElementModelScaleSag::ElementModelScaleSag ( double lenX,
double lenY,
Amg::Vector3D defo0 )

◆ ElementModelScaleSag() [2/2]

NswAsBuilt::ElementModelScaleSag::ElementModelScaleSag ( )
delete

Member Function Documentation

◆ applyDeformation()

void ElementModelScaleSag::applyDeformation ( const ParameterVector & parvec,
Eigen::Ref< Amg::Vector3D > local ) const
private

Definition at line 195 of file ElementModelScaleSag.cxx.

196{
197 // Applies the deformation to the set of local vectors given as argument
198 // This old-style implementation is the reference implementation
200 local = local
201 + DEg(parvec[EGX], parvec[EGY], parvec[EGZ], d0)
202 + DSagX(parvec[SAGX], d0)
203 + DSagY(parvec[SAGY], d0)
204 + DDSagX(parvec[DSAGX], d0)
205 + DDSagY(parvec[DSAGY], d0)
206 + DDegX(parvec[DEGX], d0)
207 + DDegY(parvec[DEGY], d0)
208 + DPgX(parvec[PGX], d0)
209 + DPgY(parvec[PGY], d0)
210 ;
211}
Amg::Vector3D DDSagX(double dsagx, const Amg::Vector3D &d0) const
Amg::Vector3D DPgX(double pgx, const Amg::Vector3D &d0) const
Amg::Vector3D DPgY(double pgy, const Amg::Vector3D &d0) const
static Amg::Vector3D DEg(double egx, double egy, double egz, const Amg::Vector3D &d0)
Amg::Vector3D DDegY(double degy, const Amg::Vector3D &d0) const
Amg::Vector3D DDSagY(double dsagy, const Amg::Vector3D &d0) const
Amg::Vector3D DSagY(double sagy, const Amg::Vector3D &d0) const
Amg::Vector3D DSagX(double sagx, const Amg::Vector3D &d0) const
Amg::Vector3D DDegX(double degx, const Amg::Vector3D &d0) const
Eigen::Matrix< double, 3, 1 > Vector3D

◆ applyDeformation2()

void ElementModelScaleSag::applyDeformation2 ( const ParameterVector & parvec,
VectorSetRef local ) const
private

Definition at line 215 of file ElementModelScaleSag.cxx.

216{
217 // Applies the deformation to the set of local vectors given as argument
218 // This implementation uses Eigen-style algebra (does the same as the method applyDeformation above, but benefits from Eigen's optimizations)
219
220 // Temporaries allocated on the stack
221 // d0 = local - defo0
222 VectorSet d0 = local.colwise() - m_defo0;
223
224 // r = {d0.x/(0.5*lenX), d0.y/(0.5*lenY), (d0.z)}
225 // r.x is (-1,+1) at X=(-0.5*lenX, 0.5*lenX), similarly for Y
226 VectorSet r = d0.array().colwise() * Eigen::Array3d{1.0/(0.5*m_lenX), 1.0/(0.5*m_lenY), 1.0};
227
228 // p2.{x,y,z} = 1 - r.{x,y,z}^2
229 // p2.x = 1 at r.x = 0 and p2.x = 0 at r.x = +-0.5*lenX, similarly for Y
230 VectorSet p2 = -1.0*(r.array().square().colwise() - Eigen::Array3d::Ones());
231
232 double egx = parvec[EGX];
233 double egy = parvec[EGY];
234 double egz = parvec[EGZ];
235 double sagx = parvec[SAGX];
236 double sagy = parvec[SAGY];
237 double dsagx = parvec[DSAGX];
238 double dsagy = parvec[DSAGY];
239 double degx = parvec[DEGX];
240 double degy = parvec[DEGY];
241 double pgx = parvec[PGX];
242 double pgy = parvec[PGY];
243
244 // EGX, EGY, EGZ:
245 // d0.{x,y,z} * {egx, egy, egz}
246 local.array() += d0.array().colwise() * Eigen::Array3d{egx*DivBy1k, egy*DivBy1k, egz*DivBy1k};
247
248 // SAGX, SAGY:
249 // p2.{y,x} * {sagx, sagy}
250 local.topRows<2>().array() += p2.topRows<2>().array().colwise().reverse().colwise() * Eigen::Array2d{sagx, sagy};
251
252 // DSAGX, DSAGY:
253 // p2.{y,x} * {dsagx*r.x, dsagy*r.y}
254 local.topRows<2>().array() += (p2.topRows<2>().array().colwise().reverse() * r.topRows<2>().array()).colwise() * Eigen::Array2d{dsagx, dsagy};
255
256 // DEGX, DEGY:
257 // d0.{x,y} * {degx*r.y, degy*r.x}
258 local.topRows<2>().array() += (d0.topRows<2>().array() * r.topRows<2>().array().colwise().reverse()).colwise() * Eigen::Array2d{degx*DivBy1k, degy*DivBy1k};
259
260 // PGX, PGY:
261 // r.{y,x} * {pgx, pgy}
262 local.topRows<2>().array() += r.topRows<2>().array().colwise().reverse().colwise() * Eigen::Array2d{pgx, pgy};
263}
Eigen::Matrix< double, 3, Eigen::Dynamic, Eigen::ColMajor|Eigen::AutoAlign, 3, 5 > VectorSet
int r
Definition globals.cxx:22

◆ cacheTransform()

void ElementModelScaleSag::cacheTransform ( ParameterVector & parvec) const
overridevirtual

Cache the rigid component of this deformation model.

Implements NswAsBuilt::ElementModel.

Definition at line 44 of file ElementModelScaleSag.cxx.

44 {
45 const auto& pars = parvec.parameters;
46 parvec.transformCache
47 = Eigen::Translation3d(pars[X], pars[Y], pars[Z])
48 * Eigen::AngleAxisd(pars[THZ], Eigen::Vector3d::UnitZ())
49 * Eigen::AngleAxisd(pars[THY], Eigen::Vector3d::UnitY())
50 * Eigen::AngleAxisd(pars[THX], Eigen::Vector3d::UnitX());
51 parvec.transformCacheValid = true;
52}

◆ DDegX()

Amg::Vector3D ElementModelScaleSag::DDegX ( double degx,
const Amg::Vector3D & d0 ) const
private

Definition at line 161 of file ElementModelScaleSag.cxx.

162{
163 double egx_eff = degx * d0[1]/(0.5*m_lenY);
164 double delta = egx_eff * d0[0]*DivBy1k;
165 return Amg::Vector3D(delta, 0., 0.);
166}

◆ DDegY()

Amg::Vector3D ElementModelScaleSag::DDegY ( double degy,
const Amg::Vector3D & d0 ) const
private

Definition at line 170 of file ElementModelScaleSag.cxx.

171{
172 double egy_eff = degy * d0[0]/(0.5*m_lenX);
173 double delta = egy_eff * d0[1]*DivBy1k;
174 return Amg::Vector3D(0., delta, 0.);
175}

◆ DDSagX()

Amg::Vector3D ElementModelScaleSag::DDSagX ( double dsagx,
const Amg::Vector3D & d0 ) const
private

Definition at line 137 of file ElementModelScaleSag.cxx.

138{
139 // Calculate sag along X
140 double sagx = dsagx * d0[0]/(0.5*m_lenX);
141 double r = d0[1]/(0.5*m_lenY);
142 // delta is sagx at y=y0, 0 at y=y0+-0.5*_lenY
143 double delta = sagx * (1. - r*r);
144 return Amg::Vector3D(delta, 0., 0.);
145}

◆ DDSagY()

Amg::Vector3D ElementModelScaleSag::DDSagY ( double dsagy,
const Amg::Vector3D & d0 ) const
private

Definition at line 149 of file ElementModelScaleSag.cxx.

150{
151 // Calculate dsag along Y
152 double sagy = dsagy * d0[1]/(0.5*m_lenY);
153 double r = d0[0]/(0.5*m_lenX);
154 // delta is sagY at x=x0, 0 at x=x0+-0.5*_lenX
155 double delta = sagy * (1. - r*r);
156 return Amg::Vector3D(0., delta, 0.);
157}

◆ DEg()

Amg::Vector3D ElementModelScaleSag::DEg ( double egx,
double egy,
double egz,
const Amg::Vector3D & d0 )
staticprivate

Definition at line 107 of file ElementModelScaleSag.cxx.

108{
109 // Calculate thermal expansion
110 return d0.array() * Eigen::Array3d{egx*DivBy1k, egy*DivBy1k, egz*DivBy1k};
111}

◆ DPgX()

Amg::Vector3D ElementModelScaleSag::DPgX ( double pgx,
const Amg::Vector3D & d0 ) const
private

Definition at line 179 of file ElementModelScaleSag.cxx.

180{
181 double delta = pgx * d0[1]/(0.5*m_lenY);
182 return Amg::Vector3D(delta, 0., 0.);
183}

◆ DPgY()

Amg::Vector3D ElementModelScaleSag::DPgY ( double pgy,
const Amg::Vector3D & d0 ) const
private

Definition at line 187 of file ElementModelScaleSag.cxx.

188{
189 double delta = pgy * d0[0]/(0.5*m_lenX);
190 return Amg::Vector3D(0., delta, 0.);
191}

◆ DSagX()

Amg::Vector3D ElementModelScaleSag::DSagX ( double sagx,
const Amg::Vector3D & d0 ) const
private

Definition at line 115 of file ElementModelScaleSag.cxx.

116{
117 // Calculate sag along X
118 double r = d0[1]/(0.5*m_lenY);
119 // delta is sagx at y=y0, 0 at y=y0+-0.5*_lenY
120 double delta = sagx * (1. - r*r);
121 return Amg::Vector3D(delta, 0., 0.);
122}

◆ DSagY()

Amg::Vector3D ElementModelScaleSag::DSagY ( double sagy,
const Amg::Vector3D & d0 ) const
private

Definition at line 126 of file ElementModelScaleSag.cxx.

127{
128 // Calculate sag along Y
129 double r = d0[0]/(0.5*m_lenX);
130 // delta is sagY at x=x0, 0 at x=x0+-0.5*_lenX
131 double delta = sagy * (1. - r*r);
132 return Amg::Vector3D(0., delta, 0.);
133}

◆ getParameterIndex()

ElementModelScaleSag::ipar_t ElementModelScaleSag::getParameterIndex ( const std::string & parname) const
overridevirtual

Implements NswAsBuilt::ElementModel.

Definition at line 57 of file ElementModelScaleSag.cxx.

58{
59 if (parname == "x") return parameter_t::X;
60 if (parname == "y") return parameter_t::Y;
61 if (parname == "z") return parameter_t::Z;
62 if (parname == "thx") return parameter_t::THX;
63 if (parname == "thy") return parameter_t::THY;
64 if (parname == "thz") return parameter_t::THZ;
65 if (parname == "egx") return parameter_t::EGX;
66 if (parname == "egy") return parameter_t::EGY;
67 if (parname == "egz") return parameter_t::EGZ;
68 if (parname == "sagx") return parameter_t::SAGX;
69 if (parname == "sagy") return parameter_t::SAGY;
70 if (parname == "degx") return parameter_t::DEGX;
71 if (parname == "degy") return parameter_t::DEGY;
72 if (parname == "pgx") return parameter_t::PGX;
73 if (parname == "pgy") return parameter_t::PGY;
74 if (parname == "dsagx") return parameter_t::DSAGX;
75 if (parname == "dsagy") return parameter_t::DSAGY;
76 throw std::runtime_error("Invalid parameter name "+parname);
77}

◆ getParameterName()

std::string ElementModelScaleSag::getParameterName ( ipar_t ipar) const
overridevirtual

Implements NswAsBuilt::ElementModel.

Definition at line 81 of file ElementModelScaleSag.cxx.

82{
83 switch (ipar) {
84 case X: return "x";
85 case Y: return "y";
86 case Z: return "z";
87 case THX: return "thx";
88 case THY: return "thy";
89 case THZ: return "thz";
90 case EGX: return "egx";
91 case EGY: return "egy";
92 case EGZ: return "egz";
93 case SAGX: return "sagx";
94 case SAGY: return "sagy";
95 case DEGX: return "degx";
96 case DEGY: return "degy";
97 case PGX: return "pgx";
98 case PGY: return "pgy";
99 case DSAGX: return "dsagx";
100 case DSAGY: return "dsagy";
101 default: throw std::runtime_error("Invalid parameter");
102 }
103}

◆ nParameters()

virtual int NswAsBuilt::ElementModelScaleSag::nParameters ( ) const
inlineoverridevirtual

Implements NswAsBuilt::ElementModel.

Definition at line 61 of file ElementModelScaleSag.h.

61{ return 17; }

◆ transform()

void ElementModelScaleSag::transform ( const ParameterVector & parvec,
VectorSetRef local ) const
overridevirtual

Transform a set of vectors expressed in local frame, stored in a matrix.

Implements NswAsBuilt::ElementModel.

Definition at line 21 of file ElementModelScaleSag.cxx.

21 {
22
23 if (!parvec.transformCacheValid) {
24 throw std::runtime_error("Should call Element::cacheTransforms() first");
25 }
26
27 // Apply the deformation component
28 /*
29 * old-style (reference) implementation: not optimized
30 for (int i=0; i< local.cols(); ++i) {
31 applyDeformation(parvec, local.col(i));
32 }
33 */
34 // Eigen-style implementation: optimized
35 applyDeformation2(parvec, local);
36
37 // Apply the rigid component
38 local = (parvec.transformCache * local).eval(); // Needs eval to avoid aliasing (?)
39}
void applyDeformation2(const ParameterVector &parvec, VectorSetRef local) const

Member Data Documentation

◆ m_defo0

Amg::Vector3D NswAsBuilt::ElementModelScaleSag::m_defo0 {Amg::Vector3D::Zero()}
private

Definition at line 96 of file ElementModelScaleSag.h.

96{Amg::Vector3D::Zero()};

◆ m_lenX

double NswAsBuilt::ElementModelScaleSag::m_lenX {0.}
private

Definition at line 94 of file ElementModelScaleSag.h.

94{0.};

◆ m_lenY

double NswAsBuilt::ElementModelScaleSag::m_lenY {0.}
private

Definition at line 95 of file ElementModelScaleSag.h.

95{0.};

The documentation for this class was generated from the following files: