Browse Source

Work towards full forward modelling support

master
T-bone 7 years ago
parent
commit
7949026144
3 changed files with 52 additions and 8 deletions
  1. 5
    2
      examples/ForwardFID.cpp
  2. 23
    2
      include/LayeredEarthMR.h
  3. 24
    4
      src/LayeredEarthMR.cpp

+ 5
- 2
examples/ForwardFID.cpp View File

26
         std::cout << "./ForwardFID Kernel.yaml TxString RxString  vtkoutput<true/false> \n";
26
         std::cout << "./ForwardFID Kernel.yaml TxString RxString  vtkoutput<true/false> \n";
27
     //    return(EXIT_FAILURE);
27
     //    return(EXIT_FAILURE);
28
     }
28
     }
29
+    auto Kernel = KernelV0::DeSerialize(YAML::LoadFile(argv[1]));
30
+    //    std::cout << *Kernel;
29
 
31
 
30
     auto Model = LayeredEarthMR::NewSP();
32
     auto Model = LayeredEarthMR::NewSP();
31
-        Model->SetNumberOfLayers(20);
33
+        Model->AlignWithKernel(Kernel);
32
         Model->SetT2StarBins(10, 500, 20);
34
         Model->SetT2StarBins(10, 500, 20);
33
         std::cout << *Model << std::endl;
35
         std::cout << *Model << std::endl;
34
 
36
 
37
+/*
35
     auto Forward = ForwardFID::NewSP();
38
     auto Forward = ForwardFID::NewSP();
36
         //Forward->SetWindowEdges( VectorXr::LinSpaced(10,0,1) );
39
         //Forward->SetWindowEdges( VectorXr::LinSpaced(10,0,1) );
37
         Forward->SetLogSpacedWindows(10,1000,30);
40
         Forward->SetLogSpacedWindows(10,1000,30);
38
         //auto FID =  Forward->ForwardModel(Model);
41
         //auto FID =  Forward->ForwardModel(Model);
39
     //std::cout << *Forward << std::endl;
42
     //std::cout << *Forward << std::endl;
40
-
43
+*/
41
     return EXIT_SUCCESS;
44
     return EXIT_SUCCESS;
42
 }
45
 }

+ 23
- 2
include/LayeredEarthMR.h View File

24
 #pragma once
24
 #pragma once
25
 #include "LayeredEarth.h"
25
 #include "LayeredEarth.h"
26
 #include "MerlinConfig.h"
26
 #include "MerlinConfig.h"
27
+#include "KernelV0.h"
27
 
28
 
28
 namespace Lemma {
29
 namespace Lemma {
29
 
30
 
83
          */
84
          */
84
         virtual YAML::Node Serialize() const;
85
         virtual YAML::Node Serialize() const;
85
 
86
 
86
-        /*
87
+        /**
87
          *  Factory method for generating concrete class.
88
          *  Factory method for generating concrete class.
88
          *  @return a std::shared_ptr of type LayeredEarthMR
89
          *  @return a std::shared_ptr of type LayeredEarthMR
89
          */
90
          */
102
         // ====================  ACCESS        =======================
103
         // ====================  ACCESS        =======================
103
 
104
 
104
 
105
 
105
-        void SetNumberOfLayers(const int& nlay);
106
 
106
 
107
+        /**
108
+         *  Sets the T2StarBins to solve for, these are log spaced
109
+         *  @param[in] first is the beginning of the bins
110
+         *  @param[in] last is the end of the bins
111
+         *  @param[in] nT2 is the number of bins
112
+         */
107
         void SetT2StarBins(const Real& first, const Real& last, const int& nT2);
113
         void SetT2StarBins(const Real& first, const Real& last, const int& nT2);
108
 
114
 
115
+        /**
116
+         *  Convenience method, that aligns model with a Kernel
117
+         *  @param[in] Kern input kernel to align with
118
+         */
119
+        void AlignWithKernel( std::shared_ptr<KernelV0> Kern );
120
+
109
         // ====================  INQUIRY       =======================
121
         // ====================  INQUIRY       =======================
110
         /**
122
         /**
111
          *  Returns the name of the underlying class, similiar to Python's type
123
          *  Returns the name of the underlying class, similiar to Python's type
129
         /** ASCII string representation of the class name */
141
         /** ASCII string representation of the class name */
130
         static constexpr auto CName = "LayeredEarthMR";
142
         static constexpr auto CName = "LayeredEarthMR";
131
 
143
 
144
+        /**
145
+         * Sets the number of layers
146
+         */
147
+        void SetNumberOfLayers(const int& nlay);
148
+
149
+        /** Initializes the model matrix */
150
+        void InitModelMat();
151
+
132
         VectorXr T2StarBins;
152
         VectorXr T2StarBins;
133
         VectorXr T2StarBinEdges;  // Convenience for pcolor
153
         VectorXr T2StarBinEdges;  // Convenience for pcolor
154
+        MatrixXr ModelMat;
134
 
155
 
135
     }; // -----  end of class  LayeredEarthMR  -----
156
     }; // -----  end of class  LayeredEarthMR  -----
136
 }  // -----  end of namespace Lemma ----
157
 }  // -----  end of namespace Lemma ----

+ 24
- 4
src/LayeredEarthMR.cpp View File

77
         node["Merlin_VERSION"] = MERLIN_VERSION;
77
         node["Merlin_VERSION"] = MERLIN_VERSION;
78
         node["T2StarBins"] = T2StarBins;
78
         node["T2StarBins"] = T2StarBins;
79
         node["T2StarBinEdges"] = T2StarBinEdges;
79
         node["T2StarBinEdges"] = T2StarBinEdges;
80
+        node["ModelMat"] = ModelMat;
80
         return node;
81
         return node;
81
     }		// -----  end of method LayeredEarthMR::Serialize  -----
82
     }		// -----  end of method LayeredEarthMR::Serialize  -----
82
 
83
 
96
     //      Method:  SetNumberOfLayers
97
     //      Method:  SetNumberOfLayers
97
     //--------------------------------------------------------------------------------------
98
     //--------------------------------------------------------------------------------------
98
     void LayeredEarthMR::SetNumberOfLayers ( const int& nlay  ) {
99
     void LayeredEarthMR::SetNumberOfLayers ( const int& nlay  ) {
100
+        NumberOfLayers = nlay;
101
+        NumberOfInterfaces = nlay+1;
99
         return ;
102
         return ;
100
     }		// -----  end of method LayeredEarthMR::SetNumberOfLayers  -----
103
     }		// -----  end of method LayeredEarthMR::SetNumberOfLayers  -----
101
 
104
 
105
+    //--------------------------------------------------------------------------------------
106
+    //       Class:  LayeredEarthMR
107
+    //      Method:  AlignWithKernel
108
+    //--------------------------------------------------------------------------------------
109
+    void LayeredEarthMR::AlignWithKernel ( std::shared_ptr<KernelV0> Kern ) {
110
+        int nlay = Kern->GetInterfaces().size()-1;
111
+        SetNumberOfLayers( nlay );
112
+        LayerThickness = Kern->GetInterfaces().tail(nlay) - Kern->GetInterfaces().head(nlay) ;
113
+        SetMagneticFieldComponents( Kern->GetSigmaModel()->GetMagneticField(), TESLA);
114
+        return ;
115
+    }		// -----  end of method LayeredEarthMR::AlignWithKernel  -----
102
 
116
 
103
     //--------------------------------------------------------------------------------------
117
     //--------------------------------------------------------------------------------------
104
     //       Class:  LayeredEarthMR
118
     //       Class:  LayeredEarthMR
113
             T2StarBinEdges[i] = T2StarBinEdges[i-1]*quotient;
127
             T2StarBinEdges[i] = T2StarBinEdges[i-1]*quotient;
114
         }
128
         }
115
         T2StarBins = (T2StarBinEdges.head(nT2) + T2StarBinEdges.tail(nT2)) / 2;
129
         T2StarBins = (T2StarBinEdges.head(nT2) + T2StarBinEdges.tail(nT2)) / 2;
130
+        InitModelMat();
116
         return;
131
         return;
117
     }		// -----  end of method LayeredEarthMR::SetNumberOfT2StarBins  -----
132
     }		// -----  end of method LayeredEarthMR::SetNumberOfT2StarBins  -----
118
 
133
 
119
 
134
 
120
-} // ----  end of namespace Lemma  ----
121
-
122
-
123
-
135
+    //--------------------------------------------------------------------------------------
136
+    //       Class:  LayeredEarthMR
137
+    //      Method:  InitModelMat
138
+    //--------------------------------------------------------------------------------------
139
+    void LayeredEarthMR::InitModelMat (  ) {
140
+        ModelMat = MatrixXr::Zero( T2StarBins.size(), NumberOfLayers );
141
+        return ;
142
+    }		// -----  end of method LayeredEarthMR::InitModelMat  -----
124
 
143
 
144
+} // ----  end of namespace Lemma  ----
125
 
145
 
126
 /* vim: set tabstop=4 expandtab: */
146
 /* vim: set tabstop=4 expandtab: */
127
 /* vim: set filetype=cpp: */
147
 /* vim: set filetype=cpp: */

Loading…
Cancel
Save