|
@@ -20,49 +20,65 @@
|
20
|
20
|
#include <Merlin>
|
21
|
21
|
using namespace Lemma;
|
22
|
22
|
|
23
|
|
-std::shared_ptr<PolygonalWireAntenna> CircularLoop ( int nd, Real radius, Real Offsetx, Real Offsety ) ;
|
24
|
|
-void MoveLoop( std::shared_ptr<PolygonalWireAntenna> Loop, int nd, Real Radius, Real Offsetx, Real Offsety );
|
|
23
|
+static constexpr Real GAMMA = 2.67518e8; // MKS units
|
25
|
24
|
|
26
|
|
-int main(int argc, char** argv) {
|
|
25
|
+std::shared_ptr<PolygonalWireAntenna> CircularLoop ( int nd, Real radius, Real Offsetx, Real Offsety, Real wL ) ;
|
|
26
|
+void MoveLoop( std::shared_ptr<PolygonalWireAntenna> Loop, int nd, Real Radius, Real Offsetx, Real Offsety, Real wL );
|
27
|
27
|
|
28
|
|
- Real offset = atof(argv[1]);
|
|
28
|
+int main(int argc, char** argv) {
|
29
|
29
|
|
30
|
|
- auto earth = LayeredEarthEM::NewSP();
|
31
|
|
- earth->SetNumberOfLayers(3);
|
32
|
|
- earth->SetLayerConductivity( (VectorXcr(3) << Complex(0.,0), Complex(1./50.,0), Complex(1./100.)).finished() );
|
33
|
|
- earth->SetLayerThickness( (VectorXr(1) << 10).finished() );
|
34
|
|
- // Set mag field info
|
35
|
|
- // From NOAA, Laramie WY, June 9 2016, aligned with mag. north
|
36
|
|
- earth->SetMagneticFieldIncDecMag( 67, 0, 52750, NANOTESLA );
|
|
30
|
+ if ( argc < 2 ) {
|
|
31
|
+ std::cout << "Calculates the coupling between two sNMR loops at the Larmor frequency. Usage\n"
|
|
32
|
+ << "\t./Coupling EarthModel.yaml" << std::endl;
|
|
33
|
+ exit(0);
|
|
34
|
+ }
|
|
35
|
+ //Real offset = atof(argv[1]);
|
|
36
|
+ auto earth = LayeredEarthEM::DeSerialize( YAML::LoadFile(argv[1]) );
|
|
37
|
+ Real Larmor = earth->GetMagneticFieldMagnitude()*GAMMA/(2*PI);
|
|
38
|
+// RedButtes model, also how you can generate your own files
|
|
39
|
+// auto earth = LayeredEarthEM::NewSP();
|
|
40
|
+// earth->SetNumberOfLayers(3);
|
|
41
|
+// earth->SetLayerConductivity( (VectorXcr(3) << Complex(0.,0), Complex(1./50.,0), Complex(1./100.)).finished() );
|
|
42
|
+// earth->SetLayerThickness( (VectorXr(1) << 10).finished() );
|
|
43
|
+// // Set mag field info
|
|
44
|
+// // From NOAA, Laramie WY, June 9 2016, aligned with mag. north
|
|
45
|
+// earth->SetMagneticFieldIncDecMag( 67, 0, 52750, NANOTESLA );
|
|
46
|
+// auto sig = std::ofstream("SigmaModel.yaml");
|
|
47
|
+// sig << *earth << std::endl;
|
|
48
|
+// sig.close();
|
37
|
49
|
|
38
|
50
|
// Transmitter loops
|
39
|
|
- auto Tx1 = CircularLoop(21, 15, 100, 100);
|
40
|
|
- auto Tx2 = CircularLoop(21, 15, 100, 100 + offset);
|
|
51
|
+ auto Tx1 = CircularLoop(21, 15, 100, 75, Larmor);
|
|
52
|
+ auto Tx2 = CircularLoop(21, 15, 100, 75, Larmor); // initially coincident
|
41
|
53
|
|
42
|
54
|
auto Kern = Coupling::NewSP();
|
43
|
55
|
Kern->PushCoil( "Coil 1", Tx1 );
|
44
|
56
|
Kern->PushCoil( "Coil 2", Tx2 );
|
45
|
57
|
Kern->SetLayeredEarthEM( earth );
|
46
|
58
|
|
47
|
|
- Kern->SetIntegrationSize( (Vector3r() << 200,200,50).finished() );
|
48
|
|
- Kern->SetIntegrationOrigin( (Vector3r() << 0,0,5).finished() );
|
49
|
|
- Kern->SetTolerance( 1e-7 ); // 1e-12
|
|
59
|
+ Kern->SetIntegrationSize( (Vector3r() << 200,300,20).finished() );
|
|
60
|
+ Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0.01).finished() );
|
|
61
|
+ Kern->SetTolerance( 1e-5 ); // 1e-12
|
50
|
62
|
|
51
|
63
|
std::vector<std::string> tx = {std::string("Coil 1")};
|
52
|
64
|
std::vector<std::string> rx = {std::string("Coil 2")};
|
53
|
|
- VectorXr Offsets = VectorXr::LinSpaced(60, 5.25, 60); // nbins, low, high
|
|
65
|
+ VectorXr Offsets = VectorXr::LinSpaced(6, 22.00, 23.0); // nbins, low, high
|
54
|
66
|
|
55
|
67
|
auto outfile = std::ofstream("coupling.dat");
|
56
|
68
|
for (int ii=0; ii< Offsets.size(); ++ii) {
|
57
|
|
- MoveLoop(Tx2, 21, 15, 100, 100 + Offsets(ii));
|
|
69
|
+ MoveLoop(Tx2, 21, 15, 100, 75 + Offsets(ii), Larmor);
|
|
70
|
+ #ifdef LEMMAUSEVTK
|
|
71
|
+ Complex coupling = Kern->Calculate( tx, rx, true );
|
|
72
|
+ #else
|
58
|
73
|
Complex coupling = Kern->Calculate( tx, rx, false );
|
|
74
|
+ #endif
|
59
|
75
|
std::cout << "coupling " << coupling << std::endl;
|
60
|
76
|
outfile << Offsets(ii) << "\t" << std::real(coupling) << "\t" << std::imag(coupling) << std::endl;
|
61
|
77
|
}
|
62
|
78
|
outfile.close();
|
63
|
79
|
}
|
64
|
80
|
|
65
|
|
-std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius, Real Offsetx, Real Offsety ) {
|
|
81
|
+std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius, Real Offsetx, Real Offsety, Real wL ) {
|
66
|
82
|
|
67
|
83
|
auto Tx1 = Lemma::PolygonalWireAntenna::NewSP();
|
68
|
84
|
Tx1->SetNumberOfPoints(nd);
|
|
@@ -72,17 +88,16 @@ std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius,
|
72
|
88
|
for (ii=0; ii<nd; ++ii) {
|
73
|
89
|
Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+Radius*std::sin(range(ii)), -1e-3));
|
74
|
90
|
}
|
75
|
|
- //Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*1, Offsety, -1e-3));
|
76
|
91
|
|
77
|
92
|
Tx1->SetCurrent(1.);
|
78
|
93
|
Tx1->SetNumberOfTurns(1);
|
79
|
94
|
Tx1->SetNumberOfFrequencies(1);
|
80
|
|
- Tx1->SetFrequency(0,2246);
|
|
95
|
+ Tx1->SetFrequency(0,wL);
|
81
|
96
|
|
82
|
97
|
return Tx1;
|
83
|
98
|
}
|
84
|
99
|
|
85
|
|
-void MoveLoop( std::shared_ptr<Lemma::PolygonalWireAntenna> Tx1, int nd, Real Radius, Real Offsetx, Real Offsety ) {
|
|
100
|
+void MoveLoop( std::shared_ptr<Lemma::PolygonalWireAntenna> Tx1, int nd, Real Radius, Real Offsetx, Real Offsety, Real wL ) {
|
86
|
101
|
|
87
|
102
|
Tx1->SetNumberOfPoints(nd);
|
88
|
103
|
|
|
@@ -91,11 +106,10 @@ void MoveLoop( std::shared_ptr<Lemma::PolygonalWireAntenna> Tx1, int nd, Real Ra
|
91
|
106
|
for (ii=0; ii<nd; ++ii) {
|
92
|
107
|
Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*std::cos(range(ii)), Offsety+Radius*std::sin(range(ii)), -1e-3));
|
93
|
108
|
}
|
94
|
|
- //Tx1->SetPoint(ii, Vector3r(Offsetx+Radius*1, Offsety, -1e-3));
|
95
|
109
|
|
96
|
110
|
Tx1->SetCurrent(1.);
|
97
|
111
|
Tx1->SetNumberOfTurns(1);
|
98
|
112
|
Tx1->SetNumberOfFrequencies(1);
|
99
|
|
- Tx1->SetFrequency(0,2246);
|
|
113
|
+ Tx1->SetFrequency(0,wL);
|
100
|
114
|
|
101
|
115
|
}
|