Selaa lähdekoodia

Coupling and image generation plots

master
Trevor Irons 7 vuotta sitten
vanhempi
commit
4ae1cdbc0a
2 muutettua tiedostoa jossa 23 lisäystä ja 19 poistoa
  1. 20
    17
      examples/Coupling.cpp
  2. 3
    2
      src/Coupling.cpp

+ 20
- 17
examples/Coupling.cpp Näytä tiedosto

26
 void MoveLoop( std::shared_ptr<PolygonalWireAntenna> Loop, 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
 int main(int argc, char** argv) {
28
 int main(int argc, char** argv) {
29
-
29
+    /*
30
     if ( argc < 2 ) {
30
     if ( argc < 2 ) {
31
         std::cout << "Calculates the coupling between two sNMR loops at the Larmor frequency. Usage\n"
31
         std::cout << "Calculates the coupling between two sNMR loops at the Larmor frequency. Usage\n"
32
                   << "\t./Coupling   EarthModel.yaml" << std::endl;
32
                   << "\t./Coupling   EarthModel.yaml" << std::endl;
34
     }
34
     }
35
     //Real offset = atof(argv[1]);
35
     //Real offset = atof(argv[1]);
36
     auto earth = LayeredEarthEM::DeSerialize( YAML::LoadFile(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 );
37
+    */
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->SetLayerConductivity( (VectorXcr(3) << Complex(0.,0), Complex(1./7.,0), Complex(1./100.)).finished() );
43
+		earth->SetLayerThickness( (VectorXr(1) << 10).finished() );
44
+        // Set mag field info
45
+        // From NOAA, Laramie WY, June 9 2016, aligned with mag. north
46
+        earth->SetMagneticFieldIncDecMag( 67, 0, 52750, NANOTESLA );
46
 //     auto sig = std::ofstream("SigmaModel.yaml");
47
 //     auto sig = std::ofstream("SigmaModel.yaml");
47
 //         sig << *earth << std::endl;
48
 //         sig << *earth << std::endl;
48
 //         sig.close();
49
 //         sig.close();
49
 
50
 
51
+    Real Larmor = earth->GetMagneticFieldMagnitude()*GAMMA/(2*PI);
52
+
50
     // Transmitter loops
53
     // Transmitter loops
51
-    auto Tx1 = CircularLoop(21, 15, 100, 75, Larmor);
52
-    auto Tx2 = CircularLoop(21, 15, 100, 75, Larmor); // initially coincident
54
+    auto Tx1 = CircularLoop(21, 15, 50, 50, Larmor);
55
+    auto Tx2 = CircularLoop(21, 15, 50, 50, Larmor); // initially coincident
53
 
56
 
54
     auto Kern = Coupling::NewSP();
57
     auto Kern = Coupling::NewSP();
55
         Kern->PushCoil( "Coil 1", Tx1 );
58
         Kern->PushCoil( "Coil 1", Tx1 );
56
         Kern->PushCoil( "Coil 2", Tx2 );
59
         Kern->PushCoil( "Coil 2", Tx2 );
57
         Kern->SetLayeredEarthEM( earth );
60
         Kern->SetLayeredEarthEM( earth );
58
 
61
 
59
-        Kern->SetIntegrationSize( (Vector3r() << 200,300,20).finished() );
62
+        Kern->SetIntegrationSize( (Vector3r() << 50,100,20).finished() );
60
         Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0.01).finished() );
63
         Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0.01).finished() );
61
-        Kern->SetTolerance( 1e-5 ); // 1e-12
64
+        Kern->SetTolerance( 1e-2 ); // 1e-12
62
 
65
 
63
-    std::vector<std::string> tx = {std::string("Coil 1")};
66
+    std::vector<std::string> tx = {std::string("Coil 1")};//,std::string("Coil 2")};
64
     std::vector<std::string> rx = {std::string("Coil 2")};
67
     std::vector<std::string> rx = {std::string("Coil 2")};
65
-    VectorXr Offsets = VectorXr::LinSpaced(6, 22.00, 23.0); // nbins, low, high
68
+    VectorXr Offsets = VectorXr::LinSpaced(6, 15.00, 23.0); // nbins, low, high
66
 
69
 
67
     auto outfile = std::ofstream("coupling.dat");
70
     auto outfile = std::ofstream("coupling.dat");
68
     for (int ii=0; ii< Offsets.size(); ++ii) {
71
     for (int ii=0; ii< Offsets.size(); ++ii) {
69
-        MoveLoop(Tx2, 21, 15, 100, 75 + Offsets(ii), Larmor);
72
+        MoveLoop(Tx2, 21, 15, 50, 50 + Offsets(ii), Larmor);
70
         #ifdef LEMMAUSEVTK
73
         #ifdef LEMMAUSEVTK
71
         Complex coupling = Kern->Calculate( tx, rx, true );
74
         Complex coupling = Kern->Calculate( tx, rx, true );
72
         #else
75
         #else

+ 3
- 2
src/Coupling.cpp Näytä tiedosto

252
     //      Method:  f
252
     //      Method:  f
253
     //--------------------------------------------------------------------------------------
253
     //--------------------------------------------------------------------------------------
254
     Complex Coupling::f( const Vector3r& r, const Real& volume, const Vector3cr& Ht, const Vector3cr& Hr ) {
254
     Complex Coupling::f( const Vector3r& r, const Real& volume, const Vector3cr& Ht, const Vector3cr& Hr ) {
255
-        //return volume*(Hr.norm() + Ht.norm());//.dot(Hr);
256
-        return volume * ( Ht.dot(Hr) );
255
+        //return volume * ( Ht.dot(Hr) );                              // coupling
256
+        //return volume * (1.-((Ht+Hr).norm()/(Hr.norm() + Ht.norm()))); // interference
257
+        return volume * std::acos( (Ht.dot(Hr) / (Ht.norm()*Hr.norm())) ); // angle
257
     }
258
     }
258
 
259
 
259
     //--------------------------------------------------------------------------------------
260
     //--------------------------------------------------------------------------------------

Loading…
Peruuta
Tallenna