Browse Source

added specialized 3 loop kernel calculator

master
Trevor Irons 8 years ago
parent
commit
8fd8ae4e4f
2 changed files with 140 additions and 0 deletions
  1. 4
    0
      examples/CMakeLists.txt
  2. 136
    0
      examples/KV0-3loops.cpp

+ 4
- 0
examples/CMakeLists.txt View File

@@ -1,6 +1,9 @@
1 1
 add_executable( KernelV0 KernelV0.cpp  )
2 2
 target_link_libraries(  KernelV0  "lemmacore" "fdem1d" "merlin")
3 3
 
4
+add_executable( KV0-3loops KV0-3loops.cpp  )
5
+target_link_libraries(  KV0-3loops  "lemmacore" "fdem1d" "merlin")
6
+
4 7
 add_executable( Coupling Coupling.cpp  )
5 8
 target_link_libraries(  Coupling  "lemmacore" "fdem1d" "merlin")
6 9
 
@@ -10,6 +13,7 @@ target_link_libraries(  Interference  "lemmacore" "fdem1d" "merlin")
10 13
 # Linking
11 14
 if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT ) 
12 15
 	target_link_libraries( KernelV0 ${VTK_LIBRARIES})
16
+	target_link_libraries( KV0-3loops ${VTK_LIBRARIES})
13 17
 	target_link_libraries( Coupling ${VTK_LIBRARIES})
14 18
 	target_link_libraries( Interference ${VTK_LIBRARIES})
15 19
 endif()

+ 136
- 0
examples/KV0-3loops.cpp View File

@@ -0,0 +1,136 @@
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      11/11/2016 02:44:37 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2016, University of Utah
17
+ * @copyright Copyright (c) 2016, Lemma Software, LLC
18
+ */
19
+
20
+#include <Merlin>
21
+using namespace Lemma;
22
+
23
+std::shared_ptr<PolygonalWireAntenna> CircularLoop ( int nd, Real radius, Real Offsetx, Real Offsety ) ;
24
+
25
+int main(int argc, char** argv) {
26
+
27
+    if (argc < 3) {
28
+        std::cout << "./KVo-3loops  <offset>  <tolerance>" << std::endl;
29
+        exit(0);
30
+    }
31
+
32
+    Real offset = atof(argv[1]);
33
+        std::cout << offset << std::endl;
34
+    Real tol = atof(argv[2]);
35
+
36
+	auto earth = LayeredEarthEM::NewSP();
37
+		earth->SetNumberOfLayers(3);
38
+		earth->SetLayerConductivity( (VectorXcr(3) << Complex(0.,0), Complex(1./50.,0), Complex(1./100.)).finished() );
39
+		earth->SetLayerThickness( (VectorXr(1) << 10).finished() );
40
+        // Set mag field info
41
+        // From NOAA, Laramie WY, June 9 2016, aligned with mag. north
42
+        earth->SetMagneticFieldIncDecMag( 67, 0, 52750, NANOTESLA );
43
+
44
+    // Transmitter loops
45
+    auto Tx1 = CircularLoop(21, 15, 100+offset/2., 100 - offset/2.);
46
+    auto Tx2 = CircularLoop(21, 15, 100+offset/2., 100 + offset/2.); // 100, 115, 124.8, 130
47
+    auto Tx3 = CircularLoop(21, 15, 100-offset/2., 100); // 100, 115, 124.8, 130
48
+    //auto Tx1 = CircularLoop(60, 15, 0, 0); // was 60
49
+
50
+    auto Kern = KernelV0::NewSP();
51
+        Kern->PushCoil( "Coil 1", Tx1 );
52
+        Kern->PushCoil( "Coil 2", Tx2 );
53
+        Kern->PushCoil( "Coil 3", Tx3 );
54
+        Kern->SetLayeredEarthEM( earth );
55
+
56
+        Kern->SetIntegrationSize( (Vector3r() << 200,200,200).finished() );
57
+        Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0).finished() );
58
+        Kern->SetTolerance( tol ); // 1e-12
59
+
60
+        Kern->SetPulseDuration(0.020);
61
+        VectorXr I(36);
62
+
63
+        // off from VC by 1.075926340216996
64
+        // Pulses from Wyoming Red Buttes exp 0
65
+        I << 397.4208916184016, 352.364477036168, 313.0112765842783, 278.37896394065376, 247.81424224324982,
66
+             220.77925043190442, 196.76493264105017, 175.31662279234038, 156.0044839325404, 138.73983004230124,
67
+             123.42064612625474, 109.82713394836259, 97.76534468972267, 87.06061858367781, 77.56000002944572, 69.1280780096311,
68
+             61.64250263640252, 54.99473044877554, 49.091182970515476, 43.84634004556388, 39.184136917167976, 35.03619319797924,
69
+             31.347205894128976, 28.06346770557137, 25.139117042424758, 22.53420773366429, 20.214205433283347,
70
+             18.144318026099942, 16.299965972298878, 14.652633628829891, 13.184271405688083, 11.870540177313893,
71
+             10.697057141915716, 9.64778948429609, 8.709338689612677, 7.871268012862094;
72
+        //Kern->SetPulseCurrent( VectorXr::LinSpaced( 1, 10, 200 )  ); // nbins, low, high
73
+        Kern->SetPulseCurrent( I ); // nbins, low, high
74
+
75
+        //Kern->SetDepthLayerInterfaces( VectorXr::LinSpaced( 30, 3, 45.5 ) ); // nlay, low, high
76
+        VectorXr interfaces = VectorXr::LinSpaced( 41, .5, 45.5 ); // nlay, low, high
77
+        Real thick = .5;
78
+        for (int ilay=1; ilay<interfaces.size(); ++ilay) {
79
+            interfaces(ilay) = interfaces(ilay-1) + thick;
80
+            thick *= 1.05;
81
+        }
82
+        Kern->SetDepthLayerInterfaces( interfaces ); // nlay, low, high
83
+
84
+    // We could, I suppose, take the earth model in here? For non-linear that
85
+    // may be more natural to work with?
86
+    std::vector<std::string> tx = {std::string("Coil 1"), std::string("Coil 2"), std::string("Coil 3") };
87
+    std::vector<std::string> rx = {std::string("Coil 1"), std::string("Coil 2"), std::string("Coil 3") };
88
+    //std::vector<std::string> rx = {std::string("Coil 1")};
89
+    Kern->CalculateK0( tx, rx, true );
90
+
91
+    std::ofstream dout = std::ofstream(std::string("k0-3Tx-RxCh1-")+ std::string(argv[1])+ std::string(".dat"));
92
+    dout << "# Transmitters: ";
93
+    for (auto lp : tx) {
94
+        dout << lp << "\t";
95
+    }
96
+    dout << "\n# Receivers: ";
97
+    for (auto lp : rx) {
98
+        dout << lp << "\t";
99
+    }
100
+    dout << "\n# Tolerance: " << tol << std::endl;
101
+    dout << "# Offset: " << offset << std::endl;
102
+    dout << "# Radius: " << 15 << std::endl;
103
+    //std::ofstream dout = std::ofstream(std::string("k-coincident.dat"));
104
+        dout << interfaces.transpose() << std::endl;
105
+        dout << I.transpose() << std::endl;
106
+        dout << "#real\n";
107
+        dout << Kern->GetKernel().real() << std::endl;
108
+        dout << "#imag\n";
109
+        dout << Kern->GetKernel().imag() << std::endl;
110
+        dout.close();
111
+
112
+    std::ofstream out = std::ofstream(std::string("k0-3Tx-RxCh1-")+std::string(argv[1])+std::string(".yaml"));
113
+    //std::ofstream out = std::ofstream(std::string("k-coincident.yaml"));
114
+    out << *Kern;
115
+    out.close();
116
+}
117
+
118
+std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius, Real Offsetx, Real Offsety ) {
119
+
120
+    auto Tx1 = Lemma::PolygonalWireAntenna::NewSP();
121
+         Tx1->SetNumberOfPoints(nd);
122
+
123
+    VectorXr range = VectorXr::LinSpaced(nd, 0, 2*PI);
124
+    int ii;
125
+    for (ii=0; ii<nd; ++ii) {
126
+        Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+Radius*std::sin(range(ii)),  -1e-3));
127
+    }
128
+    //Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*1, Offsety,  -1e-3));
129
+
130
+    Tx1->SetCurrent(1.);
131
+    Tx1->SetNumberOfTurns(1);
132
+    Tx1->SetNumberOfFrequencies(1);
133
+    Tx1->SetFrequency(0,2246);
134
+
135
+    return Tx1;
136
+}

Loading…
Cancel
Save