|
@@ -106,19 +106,34 @@ namespace Lemma {
|
106
|
106
|
bool vtkOutput ) {
|
107
|
107
|
|
108
|
108
|
// All EM calculations will share same field points
|
109
|
|
- auto points = FieldPoints::NewSP();
|
110
|
|
- points->SetNumberOfPoints(8);
|
|
109
|
+ cpoints = FieldPoints::NewSP();
|
|
110
|
+ cpoints->SetNumberOfPoints(8);
|
111
|
111
|
for (auto tx : Tx) {
|
112
|
112
|
// Set up EMEarth
|
113
|
|
- EMEarths.push_back( EMEarth1D::NewSP() );
|
114
|
|
- EMEarths.back()->AttachWireAntenna(TxRx[tx]);
|
115
|
|
- EMEarths.back()->AttachLayeredEarthEM(SigmaModel);
|
116
|
|
- EMEarths.back()->AttachFieldPoints( points );
|
117
|
|
- EMEarths.back()->SetFieldsToCalculate(H);
|
|
113
|
+ EMEarths[tx] = EMEarth1D::NewSP();
|
|
114
|
+ EMEarths[tx]->AttachWireAntenna(TxRx[tx]);
|
|
115
|
+ EMEarths[tx]->AttachLayeredEarthEM(SigmaModel);
|
|
116
|
+ EMEarths[tx]->AttachFieldPoints( cpoints );
|
|
117
|
+ EMEarths[tx]->SetFieldsToCalculate(H);
|
118
|
118
|
// TODO query for method, altough with flat antennae, this is fastest
|
119
|
|
- EMEarths.back()->SetHankelTransformMethod(ANDERSON801);
|
|
119
|
+ EMEarths[tx]->SetHankelTransformMethod(ANDERSON801);
|
|
120
|
+ EMEarths[tx]->SetTxRxMode(TX);
|
120
|
121
|
}
|
121
|
|
- IntegrateOnOctreeGrid( 1e-5, vtkOutput );
|
|
122
|
+ for (auto rx : Rx) {
|
|
123
|
+ if (EMEarths.count(rx)) {
|
|
124
|
+ EMEarths[rx]->SetTxRxMode(TXRX);
|
|
125
|
+ } else {
|
|
126
|
+ EMEarths[rx] = EMEarth1D::NewSP();
|
|
127
|
+ EMEarths[rx]->AttachWireAntenna(TxRx[rx]);
|
|
128
|
+ EMEarths[rx]->AttachLayeredEarthEM(SigmaModel);
|
|
129
|
+ EMEarths[rx]->AttachFieldPoints( cpoints );
|
|
130
|
+ EMEarths[rx]->SetFieldsToCalculate(H);
|
|
131
|
+ // TODO query for method, altough with flat antennae, this is fastest
|
|
132
|
+ EMEarths[rx]->SetHankelTransformMethod(ANDERSON801);
|
|
133
|
+ EMEarths[rx]->SetTxRxMode(RX);
|
|
134
|
+ }
|
|
135
|
+ }
|
|
136
|
+ IntegrateOnOctreeGrid( 1e-7, vtkOutput );
|
122
|
137
|
|
123
|
138
|
}
|
124
|
139
|
|
|
@@ -130,9 +145,9 @@ namespace Lemma {
|
130
|
145
|
|
131
|
146
|
this->tol = tolerance;
|
132
|
147
|
//Vector3r Size;
|
133
|
|
- Size << 200,200,200;
|
|
148
|
+ Size << 200,200,20;
|
134
|
149
|
//Vector3r Origin;
|
135
|
|
- Origin << 0,0,1.0;
|
|
150
|
+ Origin << 0,0,5.0;
|
136
|
151
|
Vector3r cpos; // centre position
|
137
|
152
|
//cpos << 100,100,50;
|
138
|
153
|
cpos = (Size-Origin).array() / 2.;
|
|
@@ -185,7 +200,8 @@ namespace Lemma {
|
185
|
200
|
#endif
|
186
|
201
|
|
187
|
202
|
}
|
188
|
|
- std::cout << "\nVOLSUM=" << VOLSUM << "\tActual=" << Size(0)*Size(1)*Size(2) << "\tDifference=" << VOLSUM - (Size(0)*Size(1)*Size(2)) << std::endl;
|
|
203
|
+ std::cout << "\nVOLSUM=" << VOLSUM << "\tActual=" << Size(0)*Size(1)*Size(2)
|
|
204
|
+ << "\tDifference=" << VOLSUM - (Size(0)*Size(1)*Size(2)) << std::endl;
|
189
|
205
|
std::cout << "nleaves\t" << nleaves << std::endl;
|
190
|
206
|
std::cout << "KSUM\t" << SUM << std::endl;
|
191
|
207
|
|
|
@@ -195,13 +211,83 @@ namespace Lemma {
|
195
|
211
|
// Class: KernelV0
|
196
|
212
|
// Method: f
|
197
|
213
|
//--------------------------------------------------------------------------------------
|
198
|
|
- Complex KernelV0::f( const Vector3r& r, const Real& volume, const Vector3cr& Bt ) {
|
199
|
|
- //std::cout << volume*Bt.norm() << std::endl;
|
200
|
|
- //return Complex(volume*Bt.norm());
|
201
|
|
- return Complex(volume*Bt.norm());
|
202
|
|
- //return Complex(volume);
|
|
214
|
+ Complex KernelV0::f( const Vector3r& r, const Real& volume, const Vector3cr& Ht, const Vector3cr& Hr ) {
|
|
215
|
+ return Complex(volume*Ht.dot(Hr));
|
|
216
|
+ //return ComputeV0Cell(MU0*Ht, MU0*Hr, volume, 1.0);
|
|
217
|
+ }
|
|
218
|
+
|
|
219
|
+ //--------------------------------------------------------------------------------------
|
|
220
|
+ // Class: KernelV0
|
|
221
|
+ // Method: ComputeV0Cell
|
|
222
|
+ //--------------------------------------------------------------------------------------
|
|
223
|
+ Complex KernelV0::ComputeV0Cell(const Vector3cr& Bt,
|
|
224
|
+ const Vector3cr& Br, const Real& vol, const Real& phi) {
|
|
225
|
+
|
|
226
|
+ // Compute the elliptic fields
|
|
227
|
+ Vector3r B0hat = {1,0,0};
|
|
228
|
+ Vector3r B0 = 53000 * B0hat; // nT
|
|
229
|
+ EllipticB EBT = EllipticFieldRep(Bt, B0hat);
|
|
230
|
+ EllipticB EBR = EllipticFieldRep(Br, B0hat);
|
203
|
231
|
|
204
|
|
-// Vn(ir) = ComputeV0Cell(Bt, Br, volume, 1.0);
|
|
232
|
+ // Compute Mn0
|
|
233
|
+ Vector3r Mn0 = ComputeMn0(phi, B0);
|
|
234
|
+ Real Mn0Abs = Mn0.norm();
|
|
235
|
+
|
|
236
|
+ Real Taup = 0.020; // s
|
|
237
|
+ Real Ip = 10; // A
|
|
238
|
+
|
|
239
|
+ // Compute the tipping angle
|
|
240
|
+ Real sintheta = std::sin(0.5*GAMMA*Ip*Taup*std::abs(EBT.alpha-EBT.beta));
|
|
241
|
+
|
|
242
|
+ // Compute phase delay, TODO add transmiiter phase and delay time phase!
|
|
243
|
+ Real phase = EBR.zeta+EBT.zeta;
|
|
244
|
+
|
|
245
|
+ return ComputeV0Cell(EBT, EBR, sintheta, phase, Mn0Abs, vol);
|
|
246
|
+ }
|
|
247
|
+
|
|
248
|
+ //--------------------------------------------------------------------------------------
|
|
249
|
+ // Class: KernelV0
|
|
250
|
+ // Method: ComputeV0Cell
|
|
251
|
+ //--------------------------------------------------------------------------------------
|
|
252
|
+ Complex KernelV0::ComputeV0Cell(const EllipticB& EBT, const EllipticB& EBR,
|
|
253
|
+ const Real& sintheta, const Real& phase, const Real& Mn0Abs,
|
|
254
|
+ const Real& vol) {
|
|
255
|
+
|
|
256
|
+ Vector3r B0hat = {1,0,0};
|
|
257
|
+ Real Larmor = 2500.*2.*PI;
|
|
258
|
+
|
|
259
|
+ // earth response of receiver adjoint field
|
|
260
|
+ Complex ejztr = std::exp(Complex(0, EBR.zeta + EBT.zeta));
|
|
261
|
+
|
|
262
|
+ Complex PhaseTerm = EBR.bhat.dot(EBT.bhat) +
|
|
263
|
+ (B0hat.dot(EBR.bhat.cross(EBT.bhat) ));
|
|
264
|
+ return -vol*Complex(0,Larmor)*Mn0Abs*(EBR.alpha+EBR.beta)*ejztr*sintheta*PhaseTerm;
|
|
265
|
+ }
|
|
266
|
+
|
|
267
|
+ Vector3r KernelV0::ComputeMn0(const Real& Porosity, const Vector3r& B0) {
|
|
268
|
+ Real Temperature = 283; // in K
|
|
269
|
+ Real chi_n = NH2O*((GAMMA*GAMMA*HBAR*HBAR)/(4.*KB*Temperature));
|
|
270
|
+ return chi_n*Porosity*B0;
|
|
271
|
+ }
|
|
272
|
+
|
|
273
|
+ //--------------------------------------------------------------------------------------
|
|
274
|
+ // Class: KernelV0
|
|
275
|
+ // Method: ComputeV0Cell
|
|
276
|
+ //--------------------------------------------------------------------------------------
|
|
277
|
+ EllipticB KernelV0::EllipticFieldRep (const Vector3cr& B, const Vector3r& B0hat) {
|
|
278
|
+ EllipticB ElipB = EllipticB();
|
|
279
|
+ Vector3cr Bperp = B.array() - B0hat.dot(B)*B0hat.array();
|
|
280
|
+ Real BperpNorm = Bperp.norm();
|
|
281
|
+ Complex Bp2 = Bperp.transpose() * Bperp;
|
|
282
|
+ VectorXcr iB0 = Complex(0,1)*B0hat.cast<Complex>().array();
|
|
283
|
+ ElipB.eizt = std::sqrt(Bp2 / std::abs(Bp2));
|
|
284
|
+ ElipB.alpha = INVSQRT2*std::sqrt(BperpNorm*BperpNorm + std::abs(Bp2));
|
|
285
|
+ ElipB.beta = sgn(std::real(iB0.dot(Bperp.cross(Bperp.conjugate())))) *
|
|
286
|
+ (INVSQRT2)*std::sqrt(std::abs(BperpNorm*BperpNorm-std::abs(Bp2)));
|
|
287
|
+ ElipB.bhat = ((Real)1./ElipB.alpha)*(((Real)1./ElipB.eizt)*Bperp.array()).real().array();
|
|
288
|
+ ElipB.bhatp = B0hat.cross(ElipB.bhat);
|
|
289
|
+ ElipB.zeta = std::real(std::log(ElipB.eizt)/Complex(0,1));
|
|
290
|
+ return ElipB;
|
205
|
291
|
}
|
206
|
292
|
|
207
|
293
|
//--------------------------------------------------------------------------------------
|
|
@@ -233,26 +319,39 @@ namespace Lemma {
|
233
|
319
|
step[0], step[1], step[2] ).finished();
|
234
|
320
|
|
235
|
321
|
VectorXcr kvals(8); // individual kernel vals
|
236
|
|
- FieldPoints* cpoints = EMEarths[0]->GetFieldPoints();
|
237
|
|
- cpoints->ClearFields();
|
|
322
|
+ cpoints->ClearFields();
|
238
|
323
|
for (int ichild=0; ichild<8; ++ichild) {
|
239
|
324
|
Vector3r cp = pos; // Eigen complains about combining these
|
240
|
325
|
cp += posadd.row(ichild);
|
241
|
326
|
cpoints->SetLocation( ichild, cp );
|
242
|
327
|
}
|
243
|
328
|
|
244
|
|
- Vector3Xcr Bt;
|
|
329
|
+ Eigen::Matrix<Complex, 3, 8> Ht = Eigen::Matrix<Complex, 3, 8>::Zero();
|
|
330
|
+ Eigen::Matrix<Complex, 3, 8> Hr = Eigen::Matrix<Complex, 3, 8>::Zero();
|
245
|
331
|
//Eigen::Matrix< Complex, 8, 3 > Bt;
|
246
|
332
|
for ( auto EMCalc : EMEarths ) {
|
247
|
333
|
//EMCalc->GetFieldPoints()->ClearFields();
|
248
|
|
- EMCalc->CalculateWireAntennaFields();
|
249
|
|
- Bt = EMCalc->GetFieldPoints()->GetHfield(0);
|
|
334
|
+ EMCalc.second->CalculateWireAntennaFields();
|
|
335
|
+ switch (EMCalc.second->GetTxRxMode()) {
|
|
336
|
+ case TX:
|
|
337
|
+ Ht += EMCalc.second->GetFieldPoints()->GetHfield(0);
|
|
338
|
+ break;
|
|
339
|
+ case RX:
|
|
340
|
+ Hr += EMCalc.second->GetFieldPoints()->GetHfield(0);
|
|
341
|
+ break;
|
|
342
|
+ case TXRX:
|
|
343
|
+ Ht += EMCalc.second->GetFieldPoints()->GetHfield(0);
|
|
344
|
+ Hr += EMCalc.second->GetFieldPoints()->GetHfield(0);
|
|
345
|
+ break;
|
|
346
|
+ default:
|
|
347
|
+ break;
|
|
348
|
+ }
|
250
|
349
|
}
|
251
|
350
|
|
252
|
351
|
for (int ichild=0; ichild<8; ++ichild) {
|
253
|
352
|
Vector3r cp = pos; // Eigen complains about combining these
|
254
|
353
|
cp += posadd.row(ichild);
|
255
|
|
- kvals(ichild) = f(cp, vol, Bt.col(ichild));
|
|
354
|
+ kvals(ichild) = f(cp, vol, Ht.col(ichild), Hr.col(ichild));
|
256
|
355
|
}
|
257
|
356
|
|
258
|
357
|
Complex ksum = kvals.sum(); // Kernel sum
|
|
@@ -304,25 +403,38 @@ namespace Lemma {
|
304
|
403
|
step[0], step[1], step[2] ).finished();
|
305
|
404
|
|
306
|
405
|
VectorXcr kvals(8); // individual kernel vals
|
307
|
|
- FieldPoints* cpoints = EMEarths[0]->GetFieldPoints();
|
308
|
|
- cpoints->ClearFields();
|
|
406
|
+ cpoints->ClearFields();
|
309
|
407
|
for (int ichild=0; ichild<8; ++ichild) {
|
310
|
408
|
Vector3r cp = pos; // Eigen complains about combining these
|
311
|
409
|
cp += posadd.row(ichild);
|
312
|
410
|
cpoints->SetLocation( ichild, cp );
|
313
|
411
|
}
|
314
|
412
|
|
315
|
|
- Vector3Xcr Bt;
|
|
413
|
+ Eigen::Matrix<Complex, 3, 8> Ht = Eigen::Matrix<Complex, 3, 8>::Zero();
|
|
414
|
+ Eigen::Matrix<Complex, 3, 8> Hr = Eigen::Matrix<Complex, 3, 8>::Zero();
|
316
|
415
|
for ( auto EMCalc : EMEarths ) {
|
317
|
416
|
//EMCalc->GetFieldPoints()->ClearFields();
|
318
|
|
- EMCalc->CalculateWireAntennaFields();
|
319
|
|
- Bt = EMCalc->GetFieldPoints()->GetHfield(0);
|
|
417
|
+ EMCalc.second->CalculateWireAntennaFields();
|
|
418
|
+ switch (EMCalc.second->GetTxRxMode()) {
|
|
419
|
+ case TX:
|
|
420
|
+ Ht += EMCalc.second->GetFieldPoints()->GetHfield(0);
|
|
421
|
+ break;
|
|
422
|
+ case RX:
|
|
423
|
+ Hr += EMCalc.second->GetFieldPoints()->GetHfield(0);
|
|
424
|
+ break;
|
|
425
|
+ case TXRX:
|
|
426
|
+ Ht += EMCalc.second->GetFieldPoints()->GetHfield(0);
|
|
427
|
+ Hr += EMCalc.second->GetFieldPoints()->GetHfield(0);
|
|
428
|
+ break;
|
|
429
|
+ default:
|
|
430
|
+ break;
|
|
431
|
+ }
|
320
|
432
|
}
|
321
|
433
|
|
322
|
434
|
for (int ichild=0; ichild<8; ++ichild) {
|
323
|
435
|
Vector3r cp = pos; // Eigen complains about combining these
|
324
|
436
|
cp += posadd.row(ichild);
|
325
|
|
- kvals(ichild) = f(cp, vol, Bt.col(ichild));
|
|
437
|
+ kvals(ichild) = f(cp, vol, Ht.col(ichild), Hr.col(ichild));
|
326
|
438
|
}
|
327
|
439
|
|
328
|
440
|
Complex ksum = kvals.sum(); // Kernel sum
|
|
@@ -333,10 +445,12 @@ namespace Lemma {
|
333
|
445
|
curse->ToChild(ichild);
|
334
|
446
|
Vector3r cp = pos; // Eigen complains about combining these
|
335
|
447
|
cp += posadd.row(ichild);
|
336
|
|
- // Testing for position via alternative means
|
337
|
|
- //Real p[3];
|
338
|
|
- //GetPosition(curse, p);
|
339
|
|
- //std::cout << cp[0] << "\t" << p[0] << "\t" << cp[1] << "\t" << p[1] << "\t" << cp[2] << "\t" << p[2] << "\t" << vol<< std::endl;
|
|
448
|
+ /* Test for position via alternative means
|
|
449
|
+ Real p[3];
|
|
450
|
+ GetPosition(curse, p);
|
|
451
|
+ std::cout << cp[0] << "\t" << p[0] << "\t" << cp[1] << "\t" << p[1]
|
|
452
|
+ << "\t" << cp[2] << "\t" << p[2] << "\t" << vol<< std::endl;
|
|
453
|
+ */
|
340
|
454
|
bool isleaf = EvaluateKids2( size, level+1, cp, kvals(ichild), oct, curse );
|
341
|
455
|
if (isleaf) { // Include result in final integral
|
342
|
456
|
LeafDict[curse->GetLeafId()] = kvals(ichild); // VTK
|