瀏覽代碼

log spacing, but seems to reverse kernel in plots? Strange.

master
T-bone 8 年之前
父節點
當前提交
974598a73d
共有 3 個檔案被更改,包括 26 行新增10 行删除
  1. 12
    4
      examples/KernelV0.cpp
  2. 0
    3
      include/KernelV0.h
  3. 14
    3
      src/KernelV0.cpp

+ 12
- 4
examples/KernelV0.cpp 查看文件

@@ -41,12 +41,10 @@ int main() {
41 41
         Kern->PushCoil( "Coil 1", Tx1 );
42 42
         Kern->PushCoil( "Coil 2", Tx2 );
43 43
         Kern->SetLayeredEarthEM( earth );
44
-        // std::cout << *Kern << std::endl;
45 44
 
46 45
         Kern->SetIntegrationSize( (Vector3r() << 200,200,200).finished() );
47 46
         Kern->SetIntegrationOrigin( (Vector3r() << 0,0,0).finished() );
48
-        Kern->SetTolerance( 1e-10 );
49
-        //Kern->SetTolerance( .55 ) ; // 1%
47
+        Kern->SetTolerance( 1e-12 );
50 48
 
51 49
         Kern->SetPulseDuration(0.020);
52 50
         VectorXr I(36);
@@ -59,7 +57,14 @@ int main() {
59 57
              10.697057141915716, 9.64778948429609, 8.709338689612677, 7.871268012862094;
60 58
         //Kern->SetPulseCurrent( VectorXr::LinSpaced( 1, 10, 200 )  ); // nbins, low, high
61 59
         Kern->SetPulseCurrent( I ); // nbins, low, high
62
-        Kern->SetDepthLayerInterfaces( VectorXr::LinSpaced( 30, 3, 45.5 ) );
60
+
61
+        //Kern->SetDepthLayerInterfaces( VectorXr::LinSpaced( 30, 3, 45.5 ) ); // nlay, low, high
62
+        //10**np.linspace(np.log10(10),np.log10(19),10)
63
+        VectorXr interfaces = VectorXr::LinSpaced(31, std::log10(2), std::log10(50)); // 30 log spaced
64
+        for (int i=0; i<interfaces.size(); ++i) {
65
+            interfaces(i) = std::pow(10, interfaces(i));
66
+        }
67
+        Kern->SetDepthLayerInterfaces( interfaces ); // nlay, low, high
63 68
 
64 69
     // We could, I suppose, take the earth model in here? For non-linear that
65 70
     // may be more natural to work with?
@@ -67,6 +72,9 @@ int main() {
67 72
     std::vector<std::string> rx = {std::string("Coil 1")};
68 73
     Kern->CalculateK0( tx, rx, true );
69 74
 
75
+    ofstream out = ofstream("k.yaml");
76
+    out << *Kern;
77
+    out.close();
70 78
 }
71 79
 
72 80
 std::shared_ptr<Lemma::PolygonalWireAntenna> CircularLoop ( int nd, Real Radius, Real Offsetx, Real Offsety ) {

+ 0
- 3
include/KernelV0.h 查看文件

@@ -270,11 +270,8 @@ namespace Lemma {
270 270
         Real                                      tol=1e-11;
271 271
         Real                                      Temperature=283.;
272 272
         Real                                      Taup = .020;  // Sec
273
-        Real                                      Ip;           // Amps pulse current, deprecated PulseI
274 273
         Real                                      Larmor;
275 274
 
276
-        Complex                                   SUM;          // Depreceated, use Kern instead
277
-
278 275
         Vector3r                                  Size;
279 276
         Vector3r                                  Origin;
280 277
 

+ 14
- 3
src/KernelV0.cpp 查看文件

@@ -80,10 +80,22 @@ namespace Lemma {
80 80
         for ( auto txm : TxRx) {
81 81
             node[txm.first] = txm.second->Serialize();
82 82
         }
83
-
84 83
         // LayeredEarthEM
85 84
         node["SigmaModel"] = SigmaModel->Serialize();
86 85
 
86
+        node["Larmor"] = Larmor;
87
+        node["Temperature"] = Temperature;
88
+        node["tol"] = tol;
89
+        node["minLevel"] = minLevel;
90
+        node["maxLevel"] = maxLevel;
91
+        node["Taup"] = Taup;
92
+
93
+        node["PulseI"] = PulseI;
94
+        node["Interfaces"] = Interfaces;
95
+
96
+        for ( int ilay=0; ilay<Interfaces.size()-1; ++ilay ) {
97
+            node["Kern-" + to_string(ilay) ] = static_cast<VectorXcr>(Kern.row(ilay));
98
+        }
87 99
         return node;
88 100
     }		// -----  end of method KernelV0::Serialize  -----
89 101
 
@@ -142,7 +154,7 @@ namespace Lemma {
142 154
         std::cout << "Calculating K0 kernel\n";
143 155
         Kern = MatrixXcr::Zero( Interfaces.size()-1, PulseI.size() );
144 156
         for (ilay=0; ilay<Interfaces.size()-1; ++ilay) {
145
-            std::cout << "Layer " << ilay << std::endl; //<< " q " << iq << std::endl;
157
+            std::cout << "Layer " << ilay << "\tfrom " << Interfaces(ilay) <<" to "<< Interfaces(ilay+1) << std::endl; //<< " q " << iq << std::endl;
146 158
             Size(2) = Interfaces(ilay+1) - Interfaces(ilay);
147 159
             Origin(2) = Interfaces(ilay);
148 160
             IntegrateOnOctreeGrid( vtkOutput );
@@ -162,7 +174,6 @@ namespace Lemma {
162 174
 
163 175
         Vector3r cpos = Origin + Size/2.;
164 176
 
165
-        SUM = 0;
166 177
         VOLSUM = 0;
167 178
         nleaves = 0;
168 179
         if (!vtkOutput) {

Loading…
取消
儲存