|
@@ -121,6 +121,7 @@ namespace Lemma {
|
121
|
121
|
// TODO query for method, altough with flat antennae, this is fastest
|
122
|
122
|
EMEarths[tx]->SetHankelTransformMethod(ANDERSON801);
|
123
|
123
|
EMEarths[tx]->SetTxRxMode(TX);
|
|
124
|
+ TxRx[tx]->SetCurrent(1.);
|
124
|
125
|
}
|
125
|
126
|
for (auto rx : Rx) {
|
126
|
127
|
if (EMEarths.count(rx)) {
|
|
@@ -134,33 +135,34 @@ namespace Lemma {
|
134
|
135
|
// TODO query for method, altough with flat antennae, this is fastest
|
135
|
136
|
EMEarths[rx]->SetHankelTransformMethod(ANDERSON801);
|
136
|
137
|
EMEarths[rx]->SetTxRxMode(RX);
|
|
138
|
+ TxRx[rx]->SetCurrent(1.);
|
137
|
139
|
}
|
138
|
140
|
}
|
139
|
141
|
|
140
|
142
|
std::cout << "Calculating K0 kernel\n";
|
141
|
|
- MatrixXcr Kern = MatrixXcr::Zero( Interfaces.size()-1, PulseI.size() );
|
142
|
|
- for (int ilay=0; ilay<Interfaces.size()-1; ++ilay) {
|
143
|
|
- for (int iq=0; iq< PulseI.size(); ++iq) {
|
144
|
|
- std::cout << "Layer " << ilay << " q " << iq << std::endl;
|
145
|
|
- Size(2) = Interfaces(ilay+1) - Interfaces(ilay);
|
146
|
|
- Origin(2) = Interfaces(ilay);
|
147
|
|
- Ip = PulseI(iq);
|
148
|
|
- Kern(ilay, iq) = IntegrateOnOctreeGrid( ilay, iq, vtkOutput );
|
149
|
|
- }
|
|
143
|
+ Kern = MatrixXcr::Zero( Interfaces.size()-1, PulseI.size() );
|
|
144
|
+ for (ilay=0; ilay<Interfaces.size()-1; ++ilay) {
|
|
145
|
+ std::cout << "Layer " << ilay << std::endl; //<< " q " << iq << std::endl;
|
|
146
|
+ Size(2) = Interfaces(ilay+1) - Interfaces(ilay);
|
|
147
|
+ Origin(2) = Interfaces(ilay);
|
|
148
|
+ //for (int iq=0; iq< PulseI.size(); ++iq) {
|
|
149
|
+ // Ip = PulseI(iq);
|
|
150
|
+ //Kern(ilay, iq) =
|
|
151
|
+ IntegrateOnOctreeGrid( 0, vtkOutput );
|
|
152
|
+ //}
|
150
|
153
|
}
|
151
|
154
|
std::cout << "\rFinished KERNEL\n";
|
152
|
155
|
std::cout << "real\n";
|
153
|
156
|
std::cout << Kern.real() << std::endl;
|
154
|
157
|
std::cout << "imag\n";
|
155
|
158
|
std::cout << Kern.imag() << std::endl;
|
156
|
|
- //IntegrateOnOctreeGrid( vtkOutput );
|
157
|
159
|
}
|
158
|
160
|
|
159
|
161
|
//--------------------------------------------------------------------------------------
|
160
|
162
|
// Class: KernelV0
|
161
|
163
|
// Method: IntegrateOnOctreeGrid
|
162
|
164
|
//--------------------------------------------------------------------------------------
|
163
|
|
- Complex KernelV0::IntegrateOnOctreeGrid( const int& ilay, const int& iq, bool vtkOutput) {
|
|
165
|
+ Complex KernelV0::IntegrateOnOctreeGrid( const int& iq, bool vtkOutput) {
|
164
|
166
|
|
165
|
167
|
Vector3r cpos = Origin + Size/2.;
|
166
|
168
|
|
|
@@ -168,7 +170,7 @@ namespace Lemma {
|
168
|
170
|
VOLSUM = 0;
|
169
|
171
|
nleaves = 0;
|
170
|
172
|
if (!vtkOutput) {
|
171
|
|
- EvaluateKids( Size, 0, cpos, 1e6 );
|
|
173
|
+ EvaluateKids( Size, 0, cpos, VectorXcr::Ones(PulseI.size()) );
|
172
|
174
|
} else {
|
173
|
175
|
#ifdef LEMMAUSEVTK
|
174
|
176
|
vtkHyperOctree* oct = vtkHyperOctree::New();
|
|
@@ -253,39 +255,60 @@ namespace Lemma {
|
253
|
255
|
// Class: KernelV0
|
254
|
256
|
// Method: f
|
255
|
257
|
//--------------------------------------------------------------------------------------
|
256
|
|
- Complex KernelV0::f( const Vector3r& r, const Real& volume, const Vector3cr& Ht, const Vector3cr& Hr ) {
|
257
|
|
- //return Complex(volume*Ht.dot(Hr));
|
258
|
|
- return ComputeV0Cell(MU0*Ht, MU0*Hr, volume, 1.0);
|
259
|
|
- }
|
260
|
|
-
|
261
|
|
- //--------------------------------------------------------------------------------------
|
262
|
|
- // Class: KernelV0
|
263
|
|
- // Method: ComputeV0Cell
|
264
|
|
- //--------------------------------------------------------------------------------------
|
265
|
|
- Complex KernelV0::ComputeV0Cell(const Vector3cr& Bt,
|
266
|
|
- const Vector3cr& Br, const Real& vol, const Real& phi) {
|
|
258
|
+ VectorXcr KernelV0::f( const Vector3r& r, const Real& volume, const Vector3cr& Ht, const Vector3cr& Hr ) {
|
267
|
259
|
|
268
|
260
|
// Compute the elliptic fields
|
269
|
261
|
Vector3r B0hat = SigmaModel->GetMagneticFieldUnitVector();
|
270
|
262
|
Vector3r B0 = SigmaModel->GetMagneticField();
|
271
|
263
|
|
272
|
264
|
// Elliptic representation
|
273
|
|
- EllipticB EBT = EllipticFieldRep(Bt, B0hat);
|
274
|
|
- EllipticB EBR = EllipticFieldRep(Br, B0hat);
|
|
265
|
+ EllipticB EBT = EllipticFieldRep(MU0*Ht, B0hat);
|
|
266
|
+ EllipticB EBR = EllipticFieldRep(MU0*Hr, B0hat);
|
275
|
267
|
|
276
|
268
|
// Compute Mn0
|
277
|
|
- Vector3r Mn0 = ComputeMn0(phi, B0);
|
|
269
|
+ Vector3r Mn0 = ComputeMn0(1.0, B0);
|
278
|
270
|
Real Mn0Abs = Mn0.norm();
|
279
|
271
|
|
280
|
|
- // Compute the tipping angle
|
281
|
|
- Real sintheta = std::sin(0.5*GAMMA*Ip*Taup*std::abs(EBT.alpha-EBT.beta));
|
282
|
|
-
|
283
|
|
- // Compute phase delay, TODO add transmiiter phase and delay time phase!
|
|
272
|
+ // Compute phase delay
|
|
273
|
+ // TODO add transmiiter phase and delay time phase!
|
284
|
274
|
Real phase = EBR.zeta+EBT.zeta;
|
285
|
275
|
|
286
|
|
- return ComputeV0Cell(EBT, EBR, sintheta, phase, Mn0Abs, vol);
|
|
276
|
+ // Calcuate vector of all responses
|
|
277
|
+ VectorXcr F = VectorXcr::Zero( PulseI.size() );
|
|
278
|
+ for (int iq=0; iq<PulseI.size(); ++iq) {
|
|
279
|
+ // Compute the tipping angle
|
|
280
|
+ Real sintheta = std::sin(0.5*GAMMA*PulseI(iq)*Taup*std::abs(EBT.alpha-EBT.beta));
|
|
281
|
+ F(iq) = ComputeV0Cell(EBT, EBR, sintheta, phase, Mn0Abs, volume);
|
|
282
|
+ }
|
|
283
|
+ return F;
|
287
|
284
|
}
|
288
|
285
|
|
|
286
|
+// //--------------------------------------------------------------------------------------
|
|
287
|
+// // Class: KernelV0
|
|
288
|
+// // Method: ComputeV0Cell
|
|
289
|
+// //--------------------------------------------------------------------------------------
|
|
290
|
+// Complex KernelV0::ComputeV0Cell(const Vector3cr& Bt,
|
|
291
|
+// const Vector3cr& Br, const Real& vol, const Real& phi) {
|
|
292
|
+//
|
|
293
|
+// // Compute the elliptic fields
|
|
294
|
+// Vector3r B0hat = SigmaModel->GetMagneticFieldUnitVector();
|
|
295
|
+// Vector3r B0 = SigmaModel->GetMagneticField();
|
|
296
|
+//
|
|
297
|
+// // Elliptic representation
|
|
298
|
+// EllipticB EBT = EllipticFieldRep(Bt, B0hat);
|
|
299
|
+// EllipticB EBR = EllipticFieldRep(Br, B0hat);
|
|
300
|
+//
|
|
301
|
+// // Compute Mn0
|
|
302
|
+// Vector3r Mn0 = ComputeMn0(phi, B0);
|
|
303
|
+// Real Mn0Abs = Mn0.norm();
|
|
304
|
+//
|
|
305
|
+// // Compute phase delay, TODO add transmiiter phase and delay time phase!
|
|
306
|
+// Real phase = EBR.zeta+EBT.zeta;
|
|
307
|
+//
|
|
308
|
+// Real sintheta = std::sin(0.5*GAMMA*Ip*Taup*std::abs(EBT.alpha-EBT.beta));
|
|
309
|
+// return 0; ComputeV0Cell(EBT, EBR, sintheta, phase, Mn0Abs, vol);
|
|
310
|
+// }
|
|
311
|
+
|
289
|
312
|
//--------------------------------------------------------------------------------------
|
290
|
313
|
// Class: KernelV0
|
291
|
314
|
// Method: ComputeV0Cell
|
|
@@ -293,14 +316,10 @@ namespace Lemma {
|
293
|
316
|
Complex KernelV0::ComputeV0Cell(const EllipticB& EBT, const EllipticB& EBR,
|
294
|
317
|
const Real& sintheta, const Real& phase, const Real& Mn0Abs,
|
295
|
318
|
const Real& vol) {
|
296
|
|
-
|
297
|
|
- Vector3r B0hat = {1,0,0};
|
298
|
|
-
|
299
|
319
|
// earth response of receiver adjoint field
|
|
320
|
+ Vector3r B0hat = SigmaModel->GetMagneticFieldUnitVector();
|
300
|
321
|
Complex ejztr = std::exp(Complex(0, EBR.zeta + EBT.zeta));
|
301
|
|
-
|
302
|
|
- Complex PhaseTerm = EBR.bhat.dot(EBT.bhat) +
|
303
|
|
- (B0hat.dot(EBR.bhat.cross(EBT.bhat) ));
|
|
322
|
+ Complex PhaseTerm = EBR.bhat.dot(EBT.bhat) + (B0hat.dot(EBR.bhat.cross(EBT.bhat) ));
|
304
|
323
|
return -vol*Complex(0,Larmor)*Mn0Abs*(EBR.alpha+EBR.beta)*ejztr*sintheta*PhaseTerm;
|
305
|
324
|
}
|
306
|
325
|
|
|
@@ -338,7 +357,7 @@ namespace Lemma {
|
338
|
357
|
// Method: EvaluateKids
|
339
|
358
|
//--------------------------------------------------------------------------------------
|
340
|
359
|
void KernelV0::EvaluateKids( const Vector3r& size, const int& level, const Vector3r& cpos,
|
341
|
|
- const Complex& parentVal ) {
|
|
360
|
+ const VectorXcr& parentVal ) {
|
342
|
361
|
|
343
|
362
|
std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
|
344
|
363
|
std::cout.flush();
|
|
@@ -359,7 +378,8 @@ namespace Lemma {
|
359
|
378
|
0, step[1], step[2],
|
360
|
379
|
step[0], step[1], step[2] ).finished();
|
361
|
380
|
|
362
|
|
- VectorXcr kvals(8); // individual kernel vals
|
|
381
|
+ //VectorXcr kvals(8); // individual kernel vals
|
|
382
|
+ MatrixXcr kvals(8, PulseI.size()); // individual kernel vals
|
363
|
383
|
cpoints->ClearFields();
|
364
|
384
|
for (int ichild=0; ichild<8; ++ichild) {
|
365
|
385
|
Vector3r cp = pos; // Eigen complains about combining these
|
|
@@ -392,21 +412,22 @@ namespace Lemma {
|
392
|
412
|
for (int ichild=0; ichild<8; ++ichild) {
|
393
|
413
|
Vector3r cp = pos; // Eigen complains about combining these
|
394
|
414
|
cp += posadd.row(ichild);
|
395
|
|
- kvals(ichild) = f(cp, vol, Ht.col(ichild), Hr.col(ichild));
|
|
415
|
+ kvals.row(ichild) = f(cp, vol, Ht.col(ichild), Hr.col(ichild));
|
396
|
416
|
}
|
397
|
417
|
|
398
|
|
- Complex ksum = kvals.sum(); // Kernel sum
|
|
418
|
+ VectorXcr ksum = kvals.colwise().sum(); // Kernel sum
|
399
|
419
|
// Evaluate whether or not furthur splitting is needed
|
400
|
|
- if ( std::abs(ksum - parentVal) > tol || level < minLevel && level < maxLevel ) {
|
|
420
|
+ if ( ((ksum - parentVal).array().abs() > tol).any() || level < minLevel && level < maxLevel ) {
|
|
421
|
+ // Not a leaf dive further in
|
401
|
422
|
for (int ichild=0; ichild<8; ++ichild) {
|
402
|
423
|
Vector3r cp = pos; // Eigen complains about combining these
|
403
|
424
|
cp += posadd.row(ichild);
|
404
|
|
- EvaluateKids( size, level+1, cp, kvals(ichild) );
|
|
425
|
+ EvaluateKids( size, level+1, cp, kvals.row(ichild) );
|
405
|
426
|
}
|
406
|
427
|
return; // not leaf
|
407
|
428
|
}
|
408
|
|
- // Save here instead?
|
409
|
|
- SUM += ksum;
|
|
429
|
+ // implicit else, is a leaf
|
|
430
|
+ Kern.row(ilay) += ksum;
|
410
|
431
|
VOLSUM += 8.*vol;
|
411
|
432
|
nleaves += 1;
|
412
|
433
|
return; // is leaf
|
|
@@ -471,7 +492,7 @@ namespace Lemma {
|
471
|
492
|
for (int ichild=0; ichild<8; ++ichild) {
|
472
|
493
|
Vector3r cp = pos; // Eigen complains about combining these
|
473
|
494
|
cp += posadd.row(ichild);
|
474
|
|
- kvals(ichild) = f(cp, vol, Ht.col(ichild), Hr.col(ichild));
|
|
495
|
+ kvals(ichild) = f(cp, vol, Ht.col(ichild), Hr.col(ichild))(0);
|
475
|
496
|
}
|
476
|
497
|
|
477
|
498
|
Complex ksum = kvals.sum(); // Kernel sum
|