Browse Source

More TEM 1D progress

add-code-of-conduct-1
Trevor Irons 5 years ago
parent
commit
af10e123d5

+ 0
- 1
Modules/FDEM1D/include/costransintegrationkernel.h View File

@@ -22,7 +22,6 @@ namespace Lemma {
22 22
     // ===================================================================
23 23
     //  Class:  CosTransIntegrationKernel
24 24
     /**
25
-      @class
26 25
       \ingroup  FDEM1D
27 26
       \brief    Integration kernel for testing cosine transform.
28 27
       \details  Evaluates cosine at the argument, using lagged convolution.

+ 9
- 0
Modules/TEM1D/examples/CMakeLists.txt View File

@@ -0,0 +1,9 @@
1
+add_executable( TEMSurvey TEMSurvey.cpp  )
2
+target_link_libraries( TEMSurvey  "lemmacore" "fdem1d" "tem1d")
3
+set_property(TARGET TEMSurvey PROPERTY CXX_STANDARD 14)
4
+
5
+INSTALL_TARGETS( "/share/TEM1D/"
6
+	TEMSurvey
7
+)
8
+
9
+#install (DIRECTORY inp  DESTINATION "${CMAKE_INSTALL_PREFIX}/share/TEM1D/" )

+ 181
- 0
Modules/TEM1D/examples/TEMSurvey.cpp View File

@@ -0,0 +1,181 @@
1
+/* This file is part of Lemma, a geophysical modelling and inversion API.
2
+ * More information is available at http://lemmasoftware.org
3
+ */
4
+
5
+/* This Source Code Form is subject to the terms of the Mozilla Public
6
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
7
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
+ */
9
+
10
+/**
11
+ * @file
12
+ * @date      10/16/2018 01:58:22 PM
13
+ * @author    Trevor Irons (ti)
14
+ * @email     Trevor.Irons@utah.edu
15
+ * @copyright Copyright (c) 2018, University of Utah
16
+ * @copyright Copyright (c) 2018, Lemma Software, LLC
17
+ */
18
+
19
+#include <TEM1D>
20
+using namespace Lemma;
21
+
22
+int main() {
23
+    // Each pulse sequence functions as an autonomous transmitter. A record may contain multiple transmitters (moments).
24
+    // There is some small overhead for wire loop locations, but generality is retained doing this, as well as monitoring of
25
+    // slight changes in geometry for both pulses.
26
+    auto TxHM = TEMTransmitter::NewSP();
27
+        TxHM->SetRepFrequency( 20, KHZ );
28
+        VectorXr Times (18);
29
+        VectorXr Amps (18);
30
+        Times << 0.0, 0.03051, 0.10267, 0.19408, 0.19889, 0.21332, 0.74249, 1.3775, 1.83452, 2.52245, \
31
+                3.191132, 3.9031135, 4.0, 4.00484486, 4.123904, 4.200182, 4.20732, 4.212946;
32
+        Amps << 0.0, 14.71872, 62.34372, 114.84372, 117.84372, 118.96872, 118.96872, 118.96872, 118.96872,\
33
+                118.59372, 119.34372, 120.0, 120.0, 117.94176, 47.60364, 0.8905848, 0.1203888, 0.0;
34
+        TxHM->SetWaveform( Times, Amps, MILLISEC );
35
+        // Define wire loop
36
+        TxHM->SetNumberOfPoints(8);
37
+        TxHM->SetPoint(0, Vector3r( -16.10,    2.13,  -34));
38
+        TxHM->SetPoint(1, Vector3r(  -7.51,   10.72,  -34));
39
+        TxHM->SetPoint(2, Vector3r(   7.51,   10.72,  -34));
40
+        TxHM->SetPoint(3, Vector3r(  14.92,    3.31,  -34));
41
+        TxHM->SetPoint(4, Vector3r(  14.92,   -3.31,  -34));
42
+        TxHM->SetPoint(5, Vector3r(   7.51,  -10.72,  -34));
43
+        TxHM->SetPoint(6, Vector3r(  -7.51,  -10.72,  -34));
44
+        TxHM->SetPoint(7, Vector3r( -16.10,   -2.13,  -34));
45
+        TxHM->SetNumberOfTurns(8);
46
+
47
+    // Each Transmitter needs its own `Receiver(s)', the only difference may be the time gates, but that's OK.
48
+    //     It's a minor amount of overhead for greatly improved genearality. As sometimes different gates are
49
+    //     masked.
50
+    auto RxHM = TEMInductiveReceiver::NewSP();
51
+        RxHM->SetComponent( ZCOMPONENT );      // What about Overloaded to take (X), (X,Y), or (X,Y,Z) or what about tilt?
52
+        RxHM->SetMoment( 1 );                  // Normalized
53
+        RxHM->SetReferenceTime( 4., MILLISEC );
54
+        RxHM->SetRxLocation( (Vector3r() << -16.80, 0, -36.00).finished() );
55
+
56
+        // Gate Centres  ms
57
+        VectorXr centres (37);
58
+        centres << 7.15000000e-04,   2.21500000e-03,   4.21500000e-03,   6.21500000e-03,
59
+                   8.21500000e-03,   1.02150000e-02,   1.22150000e-02,   1.47150000e-02,
60
+                   1.82150000e-02,   2.27150000e-02,   2.82150000e-02,   3.52150000e-02,
61
+                   4.42150000e-02,   5.57150000e-02,   7.02150000e-02,   8.82150000e-02,
62
+                   1.10715000e-01,   1.38715000e-01,   1.74215000e-01,   2.19715000e-01,
63
+                   2.76715000e-01,   3.48715000e-01,   4.39715000e-01,   5.53715000e-01,
64
+                   6.97715000e-01,   8.79215000e-01,   1.10771500e+00,   1.39621500e+00,
65
+                   1.76021500e+00,   2.21871500e+00,   2.79671500e+00,   3.52571500e+00,
66
+                   4.44471500e+00,   5.60321500e+00,   7.06321500e+00,   8.90421500e+00,
67
+                   1.10667200e+01;
68
+        //centres.array() += 4.;
69
+
70
+        // Gate Widths  ms
71
+        VectorXr widths (37);
72
+        widths <<   4.30000000e-04,   1.43000000e-03,   3.43000000e-03,   5.43000000e-03,
73
+                    7.43000000e-03,   9.43000000e-03,   1.14300000e-02,   1.34300000e-02,
74
+                    1.64300000e-02,   2.04300000e-02,   2.54300000e-02,   3.14300000e-02,
75
+                    3.94300000e-02,   4.94300000e-02,   6.24300000e-02,   7.84300000e-02,
76
+                    9.84300000e-02,   1.23430000e-01,   1.54430000e-01,   1.94430000e-01,
77
+                    2.45430000e-01,   3.08430000e-01,   3.89430000e-01,   4.90430000e-01,
78
+                    6.17430000e-01,   7.78430000e-01,   9.80430000e-01,   1.23543000e+00,
79
+                    1.55743000e+00,   1.96343000e+00,   2.47443000e+00,   3.11943000e+00,
80
+                    3.93243000e+00,   4.95743000e+00,   6.24943000e+00,   7.87743000e+00,
81
+                    9.93143000e+00;
82
+
83
+        RxHM->SetWindows(centres, widths, MILLISEC);
84
+
85
+    auto TxLM = TEMTransmitter::NewSP();
86
+        TxLM->SetRepFrequency( 20, KHZ );
87
+        VectorXr TimesLM (18);
88
+        VectorXr AmpsLM (18);
89
+
90
+        TimesLM << -8.00000E-004, -7.86965E-004, -7.66493E-004, -7.23688E-004,
91
+                   -6.39938E-004, -5.16174E-004, -3.93340E-004, -2.63993E-004,
92
+                   -1.43952E-004, -7.15990E-006, -2.50712E-006,  0.00000E+000,
93
+                    2.19597E-007,  1.47193E-006,  3.34398E-006,  4.68669E-006,
94
+                    5.96484E-006,  7.04934E-006;
95
+        TimesLM.array() = TimesLM.array() + 8e-4;  // Valgrind Hack += yields error. Correct for SkyTEM convention
96
+
97
+
98
+        AmpsLM <<  0.00000E+000,  3.67188E-002,  6.17188E-002,  1.17969E-001,
99
+                   2.14844E-001,  3.28906E-001,	 4.75781E-001,  6.30469E-001,
100
+                   7.82031E-001,  9.92969E-001,	 1.00000E+000,  1.00000E+000,
101
+                   9.63459E-001,  6.01030E-001,  2.29652E-001,  8.64702E-002,
102
+                   2.53196E-002,  0.00000E+000;
103
+        AmpsLM.array() = AmpsLM.array() * 8.;   // Also correct for SkyTEM convention in .geo file
104
+
105
+        TxLM->SetWaveform( TimesLM, AmpsLM, SEC );
106
+        // Define wire loop
107
+        TxLM->SetNumberOfPoints(8);
108
+        TxLM->SetPoint(0, Vector3r( -16.10,    2.13,  -34));
109
+        TxLM->SetPoint(1, Vector3r(  -7.51,   10.72,  -34));
110
+        TxLM->SetPoint(2, Vector3r(   7.51,   10.72,  -34));
111
+        TxLM->SetPoint(3, Vector3r(  14.92,    3.31,  -34));
112
+        TxLM->SetPoint(4, Vector3r(  14.92,   -3.31,  -34));
113
+        TxLM->SetPoint(5, Vector3r(   7.51,  -10.72,  -34));
114
+        TxLM->SetPoint(6, Vector3r(  -7.51,  -10.72,  -34));
115
+        TxLM->SetPoint(7, Vector3r( -16.10,   -2.13,  -34));
116
+        TxLM->SetNumberOfTurns(8);
117
+
118
+
119
+    auto RxLM = TEMInductiveReceiver::NewSP();
120
+        RxLM->SetComponent( ZCOMPONENT );      // What about Overloaded to take (X), (X,Y), or (X,Y,Z) or what about tilt?
121
+        RxLM->SetMoment( 1 );                  // Normalized
122
+        RxLM->SetReferenceTime( 8e-4, SEC );
123
+        RxLM->SetRxLocation( (Vector3r() << -16.80, 0, -36.00).finished() );
124
+
125
+        // Gate Centres  ms
126
+        VectorXr centresLM (26);
127
+            centresLM << 7.150000E-07, 2.215000E-06, 4.215000E-06, 6.215000E-06, 8.215000E-06,
128
+                         1.021500E-05, 1.221500E-05, 1.471500E-05, 1.821500E-05, 2.271500E-05,
129
+                         2.821500E-05, 3.521500E-05, 4.421500E-05, 5.571500E-05, 7.021500E-05,
130
+                         8.821500E-05, 1.107150E-04, 1.387150E-04, 1.742150E-04, 2.197150E-04,
131
+                         2.767150E-04, 3.487150E-04, 4.397150E-04, 5.537150E-04, 6.977150E-04,
132
+                         8.792150E-04;
133
+
134
+        VectorXr widthsLM (26);
135
+            widthsLM << 5.700000E-07, 1.570000E-06, 1.570000E-06, 1.570000E-06, 1.570000E-06,
136
+                        1.570000E-06, 1.570000E-06, 2.570000E-06, 3.570000E-06, 4.570000E-06,
137
+                        5.570000E-06, 7.570000E-06, 9.570000E-06, 1.257000E-05, 1.557000E-05,
138
+                        1.957000E-05, 2.457000E-05, 3.057000E-05, 3.957000E-05, 5.057000E-05,
139
+                        6.257000E-05, 8.057000E-05, 1.005700E-04, 1.265700E-04, 1.605700E-04,
140
+                        2.015700E-04;
141
+
142
+        RxLM->SetWindows(centresLM, widthsLM, SEC);
143
+
144
+//     // Specifies survey, this is the Glue Class, the top of the structure, etc.
145
+//     TEMSurvey* Survey = TEMSurvey::New();
146
+//         Survey->SetNumberOfLines(1);  // Flight lines or
147
+//                                       // Internally each line is a class? But that's sort of hidden to the
148
+//                                       // end user. Having each line seperate is nice for constrained inversion, where
149
+//                                       // each line is a nice thing to deal with.
150
+//         Survey->GetLine(0)->SetNumberOfRecords(1);    // Each Record then contains everything needed for modelling response curve(s)
151
+//         Survey->GetLine(0)->GetRecord(0)->SetNumberOfPulseSequences( 1 );
152
+//         Survey->GetLine(0)->GetRecord(0)->SetTransmitterReceiverPair( 0, TxHM, RxHM );
153
+//         //Survey->GetLine(0)->GetRecord(0)->SetTransmitterReceiverPair( 1, TxHM, RxHM );
154
+//
155
+//
156
+//     LayeredEarthEM* Earth = LayeredEarthEM::New();
157
+//         Earth->SetNumberOfLayers(31);
158
+//         Earth->SetLayerThickness( (VectorXr(29) <<  5.00E+00,  5.40E+00,
159
+//              5.80E+00, 6.30E+00, 6.80E+00, 7.30E+00, 7.80E+00, 8.50E+00,
160
+//              9.10E+00, 9.80E+00, 1.06E+01, 1.14E+01, 1.23E+01, 1.33E+01,
161
+//              1.43E+01, 1.54E+01, 1.66E+01, 1.79E+01, 1.93E+01, 2.08E+01,
162
+//              2.25E+01, 2.42E+01, 2.61E+01, 2.81E+01, 3.03E+01, 3.27E+01,
163
+//              3.52E+01, 3.80E+01, 4.10E+01).finished() );
164
+//
165
+//         VectorXcr rho = ( (VectorXcr(31) << 0, 1.54E+01, 4.21E+01,
166
+//             9.25E+01, 1.26E+02, 1.17E+02, 7.57E+01, 3.21E+01, 1.40E+01, 1.96E+01,
167
+//             2.67E+01, 2.56E+01, 2.00E+01, 1.86E+01, 2.31E+01, 2.97E+01, 3.50E+01,
168
+//             3.79E+01, 3.75E+01, 3.32E+01, 2.52E+01, 1.57E+01, 8.38E+00, 5.38E+00,
169
+//             5.49E+00, 6.34E+00, 7.07E+00, 7.81E+00, 8.67E+00, 9.59E+00, 1.05E+01
170
+//         ).finished() ); // 200 Ohm-m half space
171
+//
172
+//         Earth->SetLayerConductivity( 1./rho.array() );
173
+//         // ALL SET UP
174
+//         std::cout << *Survey << std::endl;
175
+//
176
+//         // OK do your thinc
177
+//         //DataTEM* data =
178
+//         Survey->ForwardModel( Earth );
179
+
180
+}
181
+

+ 1
- 0
Modules/TEM1D/include/TEM1D View File

@@ -2,6 +2,7 @@
2 2
 
3 3
 #include "TEMTransmitter.h"
4 4
 #include "TEMReceiver.h"
5
+#include "TEMInductiveReceiver.h"
5 6
 
6 7
 /* vim: set tabstop=4 expandtab: */
7 8
 /* vim: set filetype=cpp: */

+ 24
- 33
Modules/TEM1D/include/TEMInductiveReceiver.h View File

@@ -38,27 +38,21 @@ namespace Lemma {
38 38
 
39 39
         // ====================  LIFECYCLE     =======================
40 40
 
41
+        /** Default protected constructor, use NewSP */
42
+        explicit TEMInductiveReceiver (const ctor_key& key);
43
+
44
+        /** Default protected constructor, use DeSerialize */
45
+        TEMInductiveReceiver (const YAML::Node& node, const ctor_key& key);
46
+
47
+        /** Default protected destructor */
48
+        ~TEMInductiveReceiver ();
49
+
41 50
         /**
42 51
          * @copybrief LemmaObject::New()
43 52
          * @copydetails LemmaObject::New()
44 53
          */
45
-        static TEMInductiveReceiver* New();
46
-
47
-        /**
48
-         *  @copybrief   LemmaObject::Delete()
49
-         *  @copydetails LemmaObject::Delete()
50
-         */
51
-        void Delete();
52
-
53
-        // ====================  OPERATORS     =======================
54
-
55
-        // ====================  OPERATIONS    =======================
56
-
57
-        // ====================  ACCESS        =======================
58
-
59
-        // ====================  INQUIRY       =======================
54
+        static std::shared_ptr<TEMInductiveReceiver> NewSP();
60 55
 
61
-#ifdef HAVE_YAMLCPP
62 56
         /**
63 57
          *  Uses YAML to serialize this object.
64 58
          *  @return a YAML::Node
@@ -68,34 +62,31 @@ namespace Lemma {
68 62
         /**
69 63
          *   Constructs an object from a YAML::Node.
70 64
          */
71
-        static TEMInductiveReceiver* DeSerialize(const YAML::Node& node);
72
-#endif
65
+        static std::shared_ptr<TEMInductiveReceiver> DeSerialize(const YAML::Node& node);
73 66
 
74
-        protected:
67
+        // ====================  OPERATORS     =======================
75 68
 
76
-        // ====================  LIFECYCLE     =======================
69
+        // ====================  OPERATIONS    =======================
70
+
71
+        // ====================  ACCESS        =======================
77 72
 
78
-        /** Default protected constructor, use New */
79
-        TEMInductiveReceiver (const std::string& name);
73
+        // ====================  INQUIRY       =======================
80 74
 
81
-#ifdef HAVE_YAMLCPP
82
-        /** Default protected constructor, use New */
83
-        TEMInductiveReceiver (const YAML::Node& node);
84
-#endif
75
+        /** Returns the name of the underlying class, similiar to Python's type */
76
+        virtual std::string GetName() const {
77
+            return this->CName;
78
+        }
85 79
 
86
-        /** Default protected destructor, use Delete */
87
-        ~TEMInductiveReceiver ();
80
+        protected:
88 81
 
89
-        /**
90
-         *  @copybrief   LemmaObject::Release()
91
-         *  @copydetails LemmaObject::Release()
92
-         */
93
-        void Release();
82
+        // ====================  LIFECYCLE     =======================
94 83
 
95 84
         private:
96 85
 
97 86
         // ====================  DATA MEMBERS  =========================
98 87
 
88
+        static constexpr auto CName = "PolygonalWireAntenna";
89
+
99 90
     }; // -----  end of class  TEMInductiveReceiver  -----
100 91
 
101 92
 

+ 1
- 0
Modules/TEM1D/src/CMakeLists.txt View File

@@ -3,6 +3,7 @@ set (TEM1DSOURCE
3 3
 	${TEM1DSOURCE}
4 4
 
5 5
 	${CMAKE_CURRENT_SOURCE_DIR}/TEMReceiver.cpp
6
+	${CMAKE_CURRENT_SOURCE_DIR}/TEMInductiveReceiver.cpp
6 7
 	${CMAKE_CURRENT_SOURCE_DIR}/TEMTransmitter.cpp
7 8
 	
8 9
 	PARENT_SCOPE

+ 12
- 46
Modules/TEM1D/src/TEMInductiveReceiver.cpp View File

@@ -21,20 +21,12 @@
21 21
 
22 22
 namespace Lemma {
23 23
 
24
-
25
-
26 24
     // ====================  FRIEND METHODS  =====================
27
-#ifdef HAVE_YAMLCPP
25
+
28 26
     std::ostream &operator << (std::ostream &stream, const TEMInductiveReceiver &ob) {
29
-        stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
30
-        return stream;
31
-    }
32
-#else
33
-    std::ostream &operator<<(std::ostream &stream, const TEMInductiveReceiver& ob) {
34
-        stream << *(TEMReceiver*)(&ob);
27
+        stream << ob.Serialize()  << "\n";
35 28
         return stream;
36 29
     }
37
-#endif
38 30
 
39 31
     // ====================  LIFECYCLE     =======================
40 32
 
@@ -43,30 +35,26 @@ namespace Lemma {
43 35
     //      Method:  TEMInductiveReceiver
44 36
     // Description:  constructor (protected)
45 37
     //--------------------------------------------------------------------------------------
46
-    TEMInductiveReceiver::TEMInductiveReceiver (const std::string& name) : TEMReceiver(name) {
38
+    TEMInductiveReceiver::TEMInductiveReceiver (const ctor_key& key) : TEMReceiver(key) {
47 39
 
48 40
     }  // -----  end of method TEMInductiveReceiver::TEMInductiveReceiver  (constructor)  -----
49 41
 
50
-#ifdef HAVE_YAMLCPP
51 42
     //--------------------------------------------------------------------------------------
52 43
     //       Class:  TEMInductiveReceiver
53 44
     //      Method:  TEMInductiveReceiver
54 45
     // Description:  constructor (protected)
55 46
     //--------------------------------------------------------------------------------------
56
-    TEMInductiveReceiver::TEMInductiveReceiver (const YAML::Node& node) : TEMReceiver(node) {
47
+    TEMInductiveReceiver::TEMInductiveReceiver (const YAML::Node& node, const ctor_key& key) : TEMReceiver(node, key) {
57 48
 
58 49
     }  // -----  end of method TEMInductiveReceiver::TEMInductiveReceiver  (constructor)  -----
59
-#endif
60 50
 
61 51
     //--------------------------------------------------------------------------------------
62 52
     //       Class:  TEMInductiveReceiver
63 53
     //      Method:  New()
64 54
     // Description:  public constructor
65 55
     //--------------------------------------------------------------------------------------
66
-    TEMInductiveReceiver* TEMInductiveReceiver::New() {
67
-        TEMInductiveReceiver*  Obj = new TEMInductiveReceiver("TEMInductiveReceiver");
68
-        Obj->AttachTo(Obj);
69
-        return Obj;
56
+    std::shared_ptr<TEMInductiveReceiver> TEMInductiveReceiver::NewSP() {
57
+        return std::make_shared<TEMInductiveReceiver>( ctor_key() );
70 58
     }
71 59
 
72 60
     //--------------------------------------------------------------------------------------
@@ -80,32 +68,12 @@ namespace Lemma {
80 68
 
81 69
     //--------------------------------------------------------------------------------------
82 70
     //       Class:  TEMInductiveReceiver
83
-    //      Method:  Delete
84
-    // Description:  public destructor
85
-    //--------------------------------------------------------------------------------------
86
-    void TEMInductiveReceiver::Delete() {
87
-        this->DetachFrom(this);
88
-    }
89
-
90
-    //--------------------------------------------------------------------------------------
91
-    //       Class:  TEMInductiveReceiver
92
-    //      Method:  Release
93
-    // Description:  destructor (protected)
94
-    //--------------------------------------------------------------------------------------
95
-    void TEMInductiveReceiver::Release() {
96
-        delete this;
97
-    }
98
-
99
-
100
-#ifdef HAVE_YAMLCPP
101
-    //--------------------------------------------------------------------------------------
102
-    //       Class:  TEMInductiveReceiver
103 71
     //      Method:  Serialize
104 72
     //--------------------------------------------------------------------------------------
105 73
     YAML::Node  TEMInductiveReceiver::Serialize (  ) const {
106 74
         YAML::Node node;
107 75
         node = TEMReceiver::Serialize();
108
-        node.SetTag( this->Name ); // Set Tag after doing parents
76
+        node.SetTag( this->GetName() ); // Set Tag after doing parents
109 77
         return node;
110 78
     }		// -----  end of method TEMInductiveReceiver::Serialize  -----
111 79
 
@@ -114,14 +82,12 @@ namespace Lemma {
114 82
     //       Class:  TEMInductiveReceiver
115 83
     //      Method:  DeSerialize
116 84
     //--------------------------------------------------------------------------------------
117
-    TEMInductiveReceiver* TEMInductiveReceiver::DeSerialize ( const YAML::Node& node  ) {
118
-        TEMInductiveReceiver* Object = new TEMInductiveReceiver(node);
119
-        Object->AttachTo(Object);
120
-        DESERIALIZECHECK( node, Object )
121
-        return Object ;
85
+    std::shared_ptr<TEMInductiveReceiver> TEMInductiveReceiver::DeSerialize ( const YAML::Node& node  ) {
86
+        if (node.Tag() != CName) {
87
+            throw  DeSerializeTypeMismatch( CName, node.Tag());
88
+        }
89
+        return std::make_shared<TEMInductiveReceiver>(node, ctor_key());
122 90
     }		// -----  end of method TEMInductiveReceiver::DeSerialize  -----
123
-#endif
124
-
125 91
 
126 92
 }		// -----  end of Lemma  name  -----
127 93
 

Loading…
Cancel
Save