Переглянути джерело

Key201 working, but needs cleanup

lagkey
Trevor Irons 6 роки тому
джерело
коміт
1eebe3dfc3

+ 1
- 0
Modules/FDEM1D/include/HankelTransform.h Переглянути файл

@@ -42,6 +42,7 @@ namespace Lemma {
42 42
 
43 43
                 /// @todo this is actually a deprecated function. Only Chave
44 44
                 ///   uses this.
45
+                /// @deprecated
45 46
                 /// Performs numerical integration using Gaussian quadrature
46 47
                 /// ikk:   type of kernel depending on source and receiver couple
47 48
                 /// imode: a switch for TE(0) and TM(1) mode

+ 9
- 4
Modules/FDEM1D/src/EMEarth1D.cpp Переглянути файл

@@ -778,13 +778,19 @@ namespace Lemma {
778 778
         }
779 779
 
780 780
         // Determine number of lagged convolutions to do
781
-        // TODO, can Hankel2 adjust the lagg spacing safely?
782
-        int nlag = 1; // We need an extra for some reason for stability
781
+        int nlag = 1; // (Key==0)  We need an extra for some reason for stability? Maybe in Spline?
783 782
         Real lrho ( 1.01* rhomax );
784 783
         while ( lrho > rhomin ) {
785 784
             nlag += 1;
786 785
             lrho *= Hankel->GetABSER();
786
+            //std::cout << "lrho\t" << lrho << std::endl;
787 787
         }
788
+        // Key variant
789
+//        Real lamMin = Filter.base(1)/rMax;
790
+//        Real lamMax = Filter.base(end)/rMin;
791
+//        auto nLambda = ceil(log(lamMax/lamMin)/log(filterSpacing))+1;
792
+        //nlag = 3;
793
+        //std::cout << "nlag\t" << nlag << std::endl;
788 794
 
789 795
         //int nlag = rhomin
790 796
         auto tDipole = antenna->GetDipoleSource(0);
@@ -793,8 +799,7 @@ namespace Lemma {
793 799
         // Instead we should pass the antenna into this so that Hankel hass all the rho arguments...
794 800
         Hankel->ComputeLaggedRelated( 1.01* rhomax, nlag, tDipole->GetKernelManager() );
795 801
 
796
-        //std::cout << Hankel->GetAnswer() << std::endl;
797
-        //std::cout << Hankel->GetArg() << std::endl;
802
+        //std::cout << "After! " << Hankel->GetAnswer() << std::endl;
798 803
 
799 804
         // Sort the dipoles by rho
800 805
         for (int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {

+ 2
- 2
Modules/FDEM1D/src/FHTAnderson801.cpp Переглянути файл

@@ -950,8 +950,8 @@ namespace Lemma {
950 950
 
951 951
         // Now do cubic spline
952 952
         // TODO Check that knots are set in right order, Eigen has reverse()
953
-        //std::cout << "Arg\n" << Arg << std::endl;
954
-        //std::cout << "Zans\n" << Zans.col(0) << std::endl;
953
+        std::cout << "Arg\n" << Arg << std::endl;
954
+        std::cout << "Zans\n" << Zans << std::endl;
955 955
         for (int ii=0; ii<Zans.cols(); ++ii) {
956 956
             auto Spline = CubicSplineInterpolator::NewSP();
957 957
             Spline->SetKnots( Arg, Zans.col(ii).real() );

+ 38
- 12
Modules/FDEM1D/src/FHTKey201.cpp Переглянути файл

@@ -367,7 +367,9 @@ namespace Lemma {
367 367
         for (int ir2=0; ir2<nrel; ++ir2) {
368 368
             Zans(0, ir2) = Zwork.col(ir2).dot(WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder() + 1))/rho;
369 369
         }
370
-
370
+        std::cout << "rho\n" << rho << std::endl;
371
+        std::cout << "Zans\n" << Zans << std::endl;
372
+        exit(EXIT_SUCCESS);
371 373
         return ;
372 374
     }		// -----  end of method FHTKey201::ComputeRelated  -----
373 375
 
@@ -376,19 +378,34 @@ namespace Lemma {
376 378
     //      Method:  ComputeLaggedRelated
377 379
     //--------------------------------------------------------------------------------------
378 380
     void FHTKey201::ComputeLaggedRelated ( const Real& rho, const int& nlag, std::shared_ptr<KernelEM1DManager> KernelManager ) {
381
+
382
+        //std::cout << "rho max\t " << rho << std::endl;
383
+        //Real rho = 214.963;
384
+
379 385
         int nrel = (int)(KernelManager->GetSTLVector().size());
380
-        Eigen::Matrix<Complex, 201, Eigen::Dynamic > Zwork;
386
+
387
+        Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic > Zwork;
388
+        //Eigen::Matrix<Complex, 201+nrel, Eigen::Dynamic > Zwork;
381 389
         Zans= Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic>::Zero(nlag, nrel);
382
-        Zwork.resize(201, nrel);
383
-        VectorXr lambda = WT201.col(0).array()/rho;
390
+        Zwork.resize(201+nlag, nrel);  // Zwork needs to be expanded to filter length + nlag
391
+
392
+        // lambda needs to be expanded to include lagged results
393
+        VectorXr lambda = (VectorXr(201+nlag) << WT201.col(0).array()/rho, VectorXr::Zero(nlag)).finished();
394
+        for (int ilam =201; ilam< nlag+201; ++ilam) {
395
+            lambda(ilam) = lambda(ilam-1)/GetABSER();
396
+        }
397
+
384 398
         int NumFun = 0;
385 399
         int idx = 0;
386 400
 
401
+        //std::cout << lambda.transpose() << std::endl;
402
+
387 403
         VectorXr Arg(nlag);
388 404
         Arg(nlag-1) = rho;
389 405
         for (int ilag=nlag-2; ilag>=0; --ilag) {
390 406
             Arg(ilag) = Arg(ilag+1) * GetABSER();
391 407
         }
408
+        //std::cout << "Arg\t" << Arg << std::endl;
392 409
 
393 410
         // Get Kernel values
394 411
         for (int ir=0; ir<lambda.size(); ++ir) {
@@ -397,9 +414,9 @@ namespace Lemma {
397 414
             KernelManager->ComputeReflectionCoeffs(lambda(ir), idx, rho);
398 415
             for (int ir2=0; ir2<nrel; ++ir2) {
399 416
                 // Zwork* needed due to sign convention of filter weights
417
+ 			    //Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
400 418
  			    Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
401 419
             }
402
-
403 420
         }
404 421
 
405 422
         // We diverge slightly from Key here, each kernel is evaluated seperately, whereby instead
@@ -407,13 +424,20 @@ namespace Lemma {
407 424
         // in the interests of making them as generic and reusable as possible. This approach requires slightly
408 425
         // more multiplies, but the same number of kernel evaluations, which is the expensive part.
409 426
         // Inner product and scale
410
-
427
+        int ilagr = nlag-1;
411 428
         for (int ilag=0; ilag<nlag; ++ilag) {
412 429
             for (int ir2=0; ir2<nrel; ++ir2) {
413 430
                 //Zans(ilag, ir2) = Zwork.col(ir2).dot(WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder() + 1))/rho;
414
-                Zans(ilag, ir2) = Zwork.col(ir2).dot(WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder() + 1))/Arg(ilag);
431
+                //Zans(ilag, ir2) = Zwork.col(ir2).dot(WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder()+1))/Arg(ilag);
432
+                // Segment
433
+                //std::cout << Zwork.col(ir2).segment(ilag,201).transpose() << std::endl;;
434
+                //WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder()+1).segment(ilag,201);// / Arg(ilag);
435
+                Zans(ilagr, ir2) = Zwork.col(ir2).segment(ilag,201).dot( WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder()+1) ) / Arg(ilagr);
415 436
             }
437
+            ilagr -= 1;
416 438
         }
439
+        //std::cout << "Zans" << Zans << std::endl;
440
+        //exit(EXIT_SUCCESS);
417 441
 
418 442
         // make sure vectors are empty
419 443
         splineVecReal.clear();
@@ -422,17 +446,19 @@ namespace Lemma {
422 446
         // Now do cubic spline
423 447
         // TODO Check that knots are set in right order, Eigen has reverse()
424 448
         //std::cout << "Arg\n" << Arg << std::endl;
425
-        //std::cout << "Zans\n" << Zans.col(0) << std::endl;
449
+        //std::cout << "Arg.reverse()\n" << Arg.reverse() << std::endl;
450
+        //VectorXr Argr = Arg.reverse();
451
+        //std::cout << "Zans\n" << Zans << std::endl;
452
+        //exit(EXIT_SUCCESS);
426 453
         for (int ii=0; ii<Zans.cols(); ++ii) {
427
-            auto Spline = CubicSplineInterpolator::NewSP();
428
-            Spline->SetKnots( Arg, Zans.col(ii).real() );
429
-            splineVecReal.push_back(Spline);
454
+            auto SplineR = CubicSplineInterpolator::NewSP();
455
+            SplineR->SetKnots( Arg, Zans.col(ii).real() );
456
+            splineVecReal.push_back(SplineR);
430 457
 
431 458
             auto SplineI = CubicSplineInterpolator::NewSP();
432 459
             SplineI->SetKnots( Arg, Zans.col(ii).imag() );
433 460
             splineVecImag.push_back(SplineI);
434 461
         }
435
-
436 462
         return ;
437 463
     }		// -----  end of method FHTKey201::ComputeLaggedRelated  -----
438 464
 

Завантаження…
Відмінити
Зберегти