FEMTIC
ObservedDataStationMT.h
Go to the documentation of this file.
1 //-------------------------------------------------------------------------------------------------------
2 // The MIT License (MIT)
3 //
4 // Copyright (c) 2021 Yoshiya Usui
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //-------------------------------------------------------------------------------------------------------
24 #ifndef DBLDEF_OBSERVED_DATA_MT
25 #define DBLDEF_OBSERVED_DATA_MT
26 
27 #include <vector>
28 #include <complex>
29 
31 #include "Forward3D.h"
32 #include "CommonParameters.h"
33 #include "MeshDataTetraElement.h"
34 
35 // Observed data of MT station
37  public:
39  XX = 0,
40  XY,
41  YX,
42  YY
43  };
44 
50  };
51 
53  EX_GAIN = 0,
57  };
58 
59  // Constructer
60  explicit ObservedDataStationMT();
61 
62  // Destructer
63  virtual ~ObservedDataStationMT();
64 
65  // Read data from input file
66  virtual void inputObservedData( std::ifstream& inFile );
67 
68  // Calulate electric field
69  void calculateElectricField( const Forward3D* const ptrForward3D, const int rhsVectorIDOfEx, const int rhsVectorIDOfEy );
70 
71  // Calulate Impedance tensor
72  void calculateImpedanceTensor( const double freq, const ObservedDataStationPoint* const ptrStationOfMagneticField, int& icount );
73 
74  // Initialize electric field
75  void initializeElectricField( const int iPol );
76 
77  // Initialize Impedance tensor and errors
79 
80  // Allocate memory for the calculated Impedance tensors and errors
81  virtual void allocateMemoryForCalculatedValues();
82 
83  // Output calculated Impedance tensors
84  virtual void outputCalculatedValues() const;
85 
86  // Calulate interpolator vector of electric field
87  void calcInterpolatorVectorOfElectricField( Forward3D* const ptrForward3D );
88 
89  // Calulate sensitivity matrix
90  virtual void calculateSensitivityMatrix( const double freq, const int nModel,
91  const ObservedDataStationPoint* const ptrStationOfMagneticField,
92  const std::complex<double>* const derivativesOfEMFieldExPol,
93  const std::complex<double>* const derivativesOfEMFieldEyPol,
94  double* const sensitivityMatrix, const bool forceSDToOne = false ) const;
95 
96  // Calculate data vector of this PE
97  virtual void calculateResidualVectorOfDataThisPE( const double freq, const int offset, double* vector ) const;
98 
99  // Calulate sum of square of misfit
100  virtual double calculateErrorSumOfSquaresThisPE() const;
101 
102  // Copy current distortion parameters to previous ones
103  void copyDistortionParamsCurToPre( const int iComp );
104 
105  // Get flag specifing whether distortion matrix are fixed or not
106  bool doesFixDistortionMatrix() const;
107 
108  // Get type of the electric field used to calculate response functions
109  int getTypeOfElectricField() const;
110 
111  // Set flag specifing whether distortion matrix are fixed or not
112  void setFixDistortionMatrix( const bool doesFix );
113 
114  // Set type of the electric field used to calculate response functions
115  void setTypeOfElectricField( const int type );
116 
117  // Set distortion parameters of previous iteration
118  void setDistortionParamsPre( const int iComp, const double val );
119 
120  // Set distortion parameters
121  void setDistortionParams( const int iComp, const double val );
122 
123  // Set ID of distortion parameters
124  void setIDOfDistortionParams( const int iComp, const int ID );
125 
126  // Set full updated value of distortion parameters
127  void setDistortionParamsUpdatedFull( const int iComp, const double val );
128 
129  // Update distortion parameters
130  void updateDistortionParams( const double dampingFactor );
131 
132  // Get distortion parameters of previous iteration
133  double getDistortionParamsPre( const int iComp ) const;
134 
135  // Get distortion parameters
136  double getDistortionParams( const int iComp ) const;
137 
138  // Get ID of distortion parameters
139  int getIDOfDistortionParams( const int iComp ) const;
140 
141  // Get full updated value of distortion parameters
142  double getDistortionParamsUpdatedFull( const int iComp ) const;
143 
144  protected:
146  // Previous distortion matrix difference
148 
149  // Distortion matrix difference
151 
152  // Distorsion matrix difference obtained by inversion which is the ones fully updated ( damping factor = 1 )
154 
155  // Component ID of distortion matrix difference. This ID is -1 if distortion matrix is fixed or this station has no data
157  };
158 
160  // Previous gains and rotations of distortion matrix
162 
163  // Gains and rotations of distortion matrix
164  double gainsAndRotations[4];
165 
166  // Gains and rotations of distortion matrix obtained by inversion which is the ones fully updated ( damping factor = 1 )
168 
169  // Component ID of gains and rotations of distortion matrix. This ID is -1 if distortion matrix is fixed or this station has no data
171  };
172 
173  std::complex<double>* m_ZxxObserved;
174  std::complex<double>* m_ZxyObserved;
175  std::complex<double>* m_ZyxObserved;
176  std::complex<double>* m_ZyyObserved;
177 
182 
183  std::complex<double>* m_ZxxCalculated;
184  std::complex<double>* m_ZxyCalculated;
185  std::complex<double>* m_ZyxCalculated;
186  std::complex<double>* m_ZyyCalculated;
187 
192 
197 
198  // Arrays of distortion matrix differences
200 
201  // Arrays of gains and rotations of distortion matrix
203 
204  private:
205  std::complex<double> m_ExCalculated[2];
206  std::complex<double> m_EyCalculated[2];
207 
210 
211  // Flag specifing fix distortion matrix or not
213 
214  // Type of the electric field used to calculated response functions
216 
217  // Copy constructer
219 
220  // Copy assignment operator
222 
223 };
224 
225 #endif
Definition: Forward3D.h:37
Definition: ObservedDataStationMT.h:36
ObservedDataStationMT()
Definition: ObservedDataStationMT.cpp:40
int getIDOfDistortionParams(const int iComp) const
Definition: ObservedDataStationMT.cpp:1887
bool m_fixDistortionMatrix
Definition: ObservedDataStationMT.h:212
virtual ~ObservedDataStationMT()
Definition: ObservedDataStationMT.cpp:103
std::complex< double > * m_ZyxObserved
Definition: ObservedDataStationMT.h:175
int m_typeOfElectricField
Definition: ObservedDataStationMT.h:215
int m_rhsVectorIDOfEx
Definition: ObservedDataStationMT.h:208
virtual void inputObservedData(std::ifstream &inFile)
Definition: ObservedDataStationMT.cpp:216
double getDistortionParamsUpdatedFull(const int iComp) const
Definition: ObservedDataStationMT.cpp:1913
CommonParameters::DoubleComplexValues * m_ZyyResidual
Definition: ObservedDataStationMT.h:191
void setDistortionParams(const int iComp, const double val)
Definition: ObservedDataStationMT.cpp:1642
CommonParameters::DoubleComplexValues * m_ZxyResidual
Definition: ObservedDataStationMT.h:189
ObservedDataStationMT & operator=(const ObservedDataStationMT &rhs)
int m_rhsVectorIDOfEy
Definition: ObservedDataStationMT.h:209
void calculateElectricField(const Forward3D *const ptrForward3D, const int rhsVectorIDOfEx, const int rhsVectorIDOfEy)
Definition: ObservedDataStationMT.cpp:348
std::complex< double > * m_ZyxCalculated
Definition: ObservedDataStationMT.h:185
DistortionMatrixDifferences * m_arrayDistortionMatrixDifferences
Definition: ObservedDataStationMT.h:199
std::complex< double > * m_ZxxObserved
Definition: ObservedDataStationMT.h:173
ImpedanceTensorComponent
Definition: ObservedDataStationMT.h:38
@ XX
Definition: ObservedDataStationMT.h:39
@ XY
Definition: ObservedDataStationMT.h:40
@ YY
Definition: ObservedDataStationMT.h:42
@ YX
Definition: ObservedDataStationMT.h:41
int getTypeOfElectricField() const
Definition: ObservedDataStationMT.cpp:1607
CommonParameters::DoubleComplexValues * m_ZyySD
Definition: ObservedDataStationMT.h:181
std::complex< double > * m_ZxyCalculated
Definition: ObservedDataStationMT.h:184
double getDistortionParams(const int iComp) const
Definition: ObservedDataStationMT.cpp:1860
void setDistortionParamsUpdatedFull(const int iComp, const double val)
Definition: ObservedDataStationMT.cpp:1712
CommonParameters::InitComplexValues * m_dataIDOfZyy
Definition: ObservedDataStationMT.h:196
CommonParameters::DoubleComplexValues * m_ZxxSD
Definition: ObservedDataStationMT.h:178
bool doesFixDistortionMatrix() const
Get flag specifing whether distortion matrix are fixed or not.
Definition: ObservedDataStationMT.cpp:1604
std::complex< double > * m_ZxyObserved
Definition: ObservedDataStationMT.h:174
std::complex< double > * m_ZxxCalculated
Definition: ObservedDataStationMT.h:183
virtual double calculateErrorSumOfSquaresThisPE() const
Definition: ObservedDataStationMT.cpp:1561
virtual void outputCalculatedValues() const
Definition: ObservedDataStationMT.cpp:727
std::complex< double > * m_ZyyCalculated
Definition: ObservedDataStationMT.h:186
virtual void allocateMemoryForCalculatedValues()
Definition: ObservedDataStationMT.cpp:615
void setTypeOfElectricField(const int type)
Definition: ObservedDataStationMT.cpp:1615
void initializeImpedanceTensorsAndErrors()
Definition: ObservedDataStationMT.cpp:595
CommonParameters::DoubleComplexValues * m_ZyxResidual
Definition: ObservedDataStationMT.h:190
CommonParameters::InitComplexValues * m_dataIDOfZyx
Definition: ObservedDataStationMT.h:195
ComponentIDOfDistortionMatrix
Definition: ObservedDataStationMT.h:45
@ COMPONENT_ID_CYY
Definition: ObservedDataStationMT.h:49
@ COMPONENT_ID_CXY
Definition: ObservedDataStationMT.h:47
@ COMPONENT_ID_CYX
Definition: ObservedDataStationMT.h:48
@ COMPONENT_ID_CXX
Definition: ObservedDataStationMT.h:46
void calculateImpedanceTensor(const double freq, const ObservedDataStationPoint *const ptrStationOfMagneticField, int &icount)
Definition: ObservedDataStationMT.cpp:431
CommonParameters::DoubleComplexValues * m_ZxxResidual
Definition: ObservedDataStationMT.h:188
std::complex< double > * m_ZyyObserved
Definition: ObservedDataStationMT.h:176
CommonParameters::DoubleComplexValues * m_ZyxSD
Definition: ObservedDataStationMT.h:180
void initializeElectricField(const int iPol)
Definition: ObservedDataStationMT.cpp:589
CommonParameters::DoubleComplexValues * m_ZxySD
Definition: ObservedDataStationMT.h:179
CommonParameters::InitComplexValues * m_dataIDOfZxy
Definition: ObservedDataStationMT.h:194
virtual void calculateSensitivityMatrix(const double freq, const int nModel, const ObservedDataStationPoint *const ptrStationOfMagneticField, const std::complex< double > *const derivativesOfEMFieldExPol, const std::complex< double > *const derivativesOfEMFieldEyPol, double *const sensitivityMatrix, const bool forceSDToOne=false) const
Definition: ObservedDataStationMT.cpp:828
std::complex< double > m_ExCalculated[2]
Definition: ObservedDataStationMT.h:205
void calcInterpolatorVectorOfElectricField(Forward3D *const ptrForward3D)
Definition: ObservedDataStationMT.cpp:760
CommonParameters::InitComplexValues * m_dataIDOfZxx
Definition: ObservedDataStationMT.h:193
void copyDistortionParamsCurToPre(const int iComp)
Definition: ObservedDataStationMT.cpp:1579
void setDistortionParamsPre(const int iComp, const double val)
Definition: ObservedDataStationMT.cpp:1618
void updateDistortionParams(const double dampingFactor)
Definition: ObservedDataStationMT.cpp:1766
ComponentIDOfGainsAndRotations
Definition: ObservedDataStationMT.h:52
@ EX_ROTATION
Definition: ObservedDataStationMT.h:55
@ EY_ROTATION
Definition: ObservedDataStationMT.h:56
@ EY_GAIN
Definition: ObservedDataStationMT.h:54
@ EX_GAIN
Definition: ObservedDataStationMT.h:53
std::complex< double > m_EyCalculated[2]
Definition: ObservedDataStationMT.h:206
ObservedDataStationMT(const ObservedDataStationMT &rhs)
void setFixDistortionMatrix(const bool doesFix)
Definition: ObservedDataStationMT.cpp:1610
virtual void calculateResidualVectorOfDataThisPE(const double freq, const int offset, double *vector) const
Definition: ObservedDataStationMT.cpp:1533
void setIDOfDistortionParams(const int iComp, const int ID)
Definition: ObservedDataStationMT.cpp:1666
GainsAndRotations * m_arrayGainsAndRotations
Definition: ObservedDataStationMT.h:202
double getDistortionParamsPre(const int iComp) const
Definition: ObservedDataStationMT.cpp:1833
Definition: ObservedDataStationPoint.h:33
Definition: CommonParameters.h:64
Definition: CommonParameters.h:69
Definition: ObservedDataStationMT.h:145
double distortionMatrixDifferenceUpdatedFull[4]
Definition: ObservedDataStationMT.h:153
double distortionMatrixDifference[4]
Definition: ObservedDataStationMT.h:150
int IDsOfDistortionMatrixDifference[4]
Definition: ObservedDataStationMT.h:156
double distortionMatrixDifferencePre[4]
Definition: ObservedDataStationMT.h:147
Definition: ObservedDataStationMT.h:159
double gainsAndRotationsUpdatedFull[4]
Definition: ObservedDataStationMT.h:167
int IDsOfGainsAndRotations[4]
Definition: ObservedDataStationMT.h:170
double gainsAndRotationsPre[4]
Definition: ObservedDataStationMT.h:161
double gainsAndRotations[4]
Definition: ObservedDataStationMT.h:164