Browse Source

Cleaned up debugging commands

lagkey
Trevor Irons 6 years ago
parent
commit
e1bf50e95f

+ 3
- 17
Modules/FDEM1D/src/EMEarth1D.cpp View File

779
 
779
 
780
         // Determine number of lagged convolutions to do
780
         // Determine number of lagged convolutions to do
781
         int nlag = 1; // (Key==0)  We need an extra for some reason for stability? Maybe in Spline?
781
         int nlag = 1; // (Key==0)  We need an extra for some reason for stability? Maybe in Spline?
782
-        Real lrho ( 1.01* rhomax );
782
+        Real lrho ( 1.0 * rhomax );
783
         while ( lrho > rhomin ) {
783
         while ( lrho > rhomin ) {
784
             nlag += 1;
784
             nlag += 1;
785
             lrho *= Hankel->GetABSER();
785
             lrho *= Hankel->GetABSER();
786
-            //std::cout << "lrho\t" << lrho << std::endl;
787
         }
786
         }
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;
794
-
795
-        //int nlag = rhomin
787
+
796
         auto tDipole = antenna->GetDipoleSource(0);
788
         auto tDipole = antenna->GetDipoleSource(0);
797
         tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth);
789
         tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth);
798
 
790
 
799
         // Instead we should pass the antenna into this so that Hankel hass all the rho arguments...
791
         // Instead we should pass the antenna into this so that Hankel hass all the rho arguments...
800
-        Hankel->ComputeLaggedRelated( 1.01* rhomax, nlag, tDipole->GetKernelManager() );
801
-
802
-        //std::cout << "After! " << Hankel->GetAnswer() << std::endl;
792
+        Hankel->ComputeLaggedRelated( 1.0*rhomax, nlag, tDipole->GetKernelManager() );
803
 
793
 
804
         // Sort the dipoles by rho
794
         // Sort the dipoles by rho
805
         for (int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
795
         for (int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
806
-        //for (int idip=0; idip<1; ++idip) {
807
             auto tDipole = antenna->GetDipoleSource(idip);
796
             auto tDipole = antenna->GetDipoleSource(idip);
808
             tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth);
797
             tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth);
809
             // Pass Hankel2 a message here so it knows which one to return in Zgauss!
798
             // Pass Hankel2 a message here so it knows which one to return in Zgauss!
810
             Real rho = (Receivers->GetLocation(irec).head<2>() - tDipole->GetLocation().head<2>()).norm();
799
             Real rho = (Receivers->GetLocation(irec).head<2>() - tDipole->GetLocation().head<2>()).norm();
811
-            //std::cout << " in Lagged " <<  rho << "\t" << rhomin << "\t" << rhomax << std::endl;
812
             Hankel->SetLaggedArg( rho );
800
             Hankel->SetLaggedArg( rho );
813
             tDipole->UpdateFields( ifreq,  Hankel, wavef );
801
             tDipole->UpdateFields( ifreq,  Hankel, wavef );
814
         }
802
         }
815
-        //std::cout << "Spline\n";
816
-        //std::cout << Receivers->GetHfield(0, irec) << std::endl;
817
     }
803
     }
818
 
804
 
819
     //////////////////////////////////////////////////////////
805
     //////////////////////////////////////////////////////////

+ 0
- 3
Modules/FDEM1D/src/FHTAnderson801.cpp View File

949
         DeleteSplines();
949
         DeleteSplines();
950
 
950
 
951
         // Now do cubic spline
951
         // Now do cubic spline
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 << std::endl;
955
         for (int ii=0; ii<Zans.cols(); ++ii) {
952
         for (int ii=0; ii<Zans.cols(); ++ii) {
956
             auto Spline = CubicSplineInterpolator::NewSP();
953
             auto Spline = CubicSplineInterpolator::NewSP();
957
             Spline->SetKnots( Arg, Zans.col(ii).real() );
954
             Spline->SetKnots( Arg, Zans.col(ii).real() );

+ 1
- 28
Modules/FDEM1D/src/FHTKey201.cpp View File

340
         //kernelVec = KernelManager->GetSTLVector();
340
         //kernelVec = KernelManager->GetSTLVector();
341
         int nrel = (int)(KernelManager->GetSTLVector().size());
341
         int nrel = (int)(KernelManager->GetSTLVector().size());
342
         Eigen::Matrix<Complex, 201, Eigen::Dynamic > Zwork;
342
         Eigen::Matrix<Complex, 201, Eigen::Dynamic > Zwork;
343
-        // TODO, if we want to allow lagged, then 1 below should be nlag
344
         Zans= Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic>::Zero(1, nrel);
343
         Zans= Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic>::Zero(1, nrel);
345
         Zwork.resize(201, nrel);
344
         Zwork.resize(201, nrel);
346
         VectorXr lambda = WT201.col(0).array()/rho;
345
         VectorXr lambda = WT201.col(0).array()/rho;
356
                 // Zwork* needed due to sign convention of filter weights
355
                 // Zwork* needed due to sign convention of filter weights
357
  			    Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
356
  			    Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
358
             }
357
             }
359
-
360
         }
358
         }
361
 
359
 
362
         // We diverge slightly from Key here, each kernel is evaluated seperately, whereby instead
360
         // We diverge slightly from Key here, each kernel is evaluated seperately, whereby instead
367
         for (int ir2=0; ir2<nrel; ++ir2) {
365
         for (int ir2=0; ir2<nrel; ++ir2) {
368
             Zans(0, ir2) = Zwork.col(ir2).dot(WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder() + 1))/rho;
366
             Zans(0, ir2) = Zwork.col(ir2).dot(WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder() + 1))/rho;
369
         }
367
         }
370
-        std::cout << "rho\n" << rho << std::endl;
371
-        std::cout << "Zans\n" << Zans << std::endl;
372
-        exit(EXIT_SUCCESS);
373
         return ;
368
         return ;
374
     }		// -----  end of method FHTKey201::ComputeRelated  -----
369
     }		// -----  end of method FHTKey201::ComputeRelated  -----
375
 
370
 
379
     //--------------------------------------------------------------------------------------
374
     //--------------------------------------------------------------------------------------
380
     void FHTKey201::ComputeLaggedRelated ( const Real& rho, const int& nlag, std::shared_ptr<KernelEM1DManager> KernelManager ) {
375
     void FHTKey201::ComputeLaggedRelated ( const Real& rho, const int& nlag, std::shared_ptr<KernelEM1DManager> KernelManager ) {
381
 
376
 
382
-        //std::cout << "rho max\t " << rho << std::endl;
383
-        //Real rho = 214.963;
384
-
385
         int nrel = (int)(KernelManager->GetSTLVector().size());
377
         int nrel = (int)(KernelManager->GetSTLVector().size());
386
 
378
 
387
         Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic > Zwork;
379
         Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic > Zwork;
388
-        //Eigen::Matrix<Complex, 201+nrel, Eigen::Dynamic > Zwork;
389
         Zans= Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic>::Zero(nlag, nrel);
380
         Zans= Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic>::Zero(nlag, nrel);
390
         Zwork.resize(201+nlag, nrel);  // Zwork needs to be expanded to filter length + nlag
381
         Zwork.resize(201+nlag, nrel);  // Zwork needs to be expanded to filter length + nlag
391
 
382
 
398
         int NumFun = 0;
389
         int NumFun = 0;
399
         int idx = 0;
390
         int idx = 0;
400
 
391
 
401
-        //std::cout << lambda.transpose() << std::endl;
402
-
403
         VectorXr Arg(nlag);
392
         VectorXr Arg(nlag);
404
         Arg(nlag-1) = rho;
393
         Arg(nlag-1) = rho;
405
         for (int ilag=nlag-2; ilag>=0; --ilag) {
394
         for (int ilag=nlag-2; ilag>=0; --ilag) {
406
             Arg(ilag) = Arg(ilag+1) * GetABSER();
395
             Arg(ilag) = Arg(ilag+1) * GetABSER();
407
         }
396
         }
408
-        //std::cout << "Arg\t" << Arg << std::endl;
409
 
397
 
410
         // Get Kernel values
398
         // Get Kernel values
411
         for (int ir=0; ir<lambda.size(); ++ir) {
399
         for (int ir=0; ir<lambda.size(); ++ir) {
413
             ++NumFun;
401
             ++NumFun;
414
             KernelManager->ComputeReflectionCoeffs(lambda(ir), idx, rho);
402
             KernelManager->ComputeReflectionCoeffs(lambda(ir), idx, rho);
415
             for (int ir2=0; ir2<nrel; ++ir2) {
403
             for (int ir2=0; ir2<nrel; ++ir2) {
416
-                // Zwork* needed due to sign convention of filter weights
417
- 			    //Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
418
  			    Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
404
  			    Zwork(ir, ir2) = std::conj(KernelManager->GetSTLVector()[ir2]->RelBesselArg(lambda(ir)));
419
             }
405
             }
420
         }
406
         }
424
         // in the interests of making them as generic and reusable as possible. This approach requires slightly
410
         // in the interests of making them as generic and reusable as possible. This approach requires slightly
425
         // more multiplies, but the same number of kernel evaluations, which is the expensive part.
411
         // more multiplies, but the same number of kernel evaluations, which is the expensive part.
426
         // Inner product and scale
412
         // Inner product and scale
427
-        int ilagr = nlag-1;
413
+        int ilagr = nlag-1; // Zwork is in opposite order from Arg
428
         for (int ilag=0; ilag<nlag; ++ilag) {
414
         for (int ilag=0; ilag<nlag; ++ilag) {
429
             for (int ir2=0; ir2<nrel; ++ir2) {
415
             for (int ir2=0; ir2<nrel; ++ir2) {
430
-                //Zans(ilag, ir2) = Zwork.col(ir2).dot(WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder() + 1))/rho;
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);
416
                 Zans(ilagr, ir2) = Zwork.col(ir2).segment(ilag,201).dot( WT201.col(KernelManager->GetSTLVector()[ir2]->GetBesselOrder()+1) ) / Arg(ilagr);
436
             }
417
             }
437
             ilagr -= 1;
418
             ilagr -= 1;
438
         }
419
         }
439
-        //std::cout << "Zans" << Zans << std::endl;
440
-        //exit(EXIT_SUCCESS);
441
 
420
 
442
         // make sure vectors are empty
421
         // make sure vectors are empty
443
         splineVecReal.clear();
422
         splineVecReal.clear();
444
         splineVecImag.clear();
423
         splineVecImag.clear();
445
 
424
 
446
         // Now do cubic spline
425
         // Now do cubic spline
447
-        // TODO Check that knots are set in right order, Eigen has reverse()
448
-        //std::cout << "Arg\n" << Arg << 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);
453
         for (int ii=0; ii<Zans.cols(); ++ii) {
426
         for (int ii=0; ii<Zans.cols(); ++ii) {
454
             auto SplineR = CubicSplineInterpolator::NewSP();
427
             auto SplineR = CubicSplineInterpolator::NewSP();
455
             SplineR->SetKnots( Arg, Zans.col(ii).real() );
428
             SplineR->SetKnots( Arg, Zans.col(ii).real() );

Loading…
Cancel
Save