Browse Source

initial attempt to add free proportions of the near-field plot

Konstantin Ladutenko 3 years ago
parent
commit
597980d5ae

+ 10 - 6
guiapp/src/components/nearfield/GetNearFieldSettings.vue

@@ -15,9 +15,9 @@
         <div class="col-xs-grow col-sm">
           <div class="row justify-xs-center justify-sm-start items-center">
             <input-with-units
-                v-model:input-result="plotSideResolution"
+                v-model:input-result="plotXSideResolution"
                 v-model:is-showing-help="isShowingHelpForInputWithUnits"
-                :initial-expression="plotSideResolution.toString()"
+                :initial-expression="plotXSideResolution.toString()"
                 title="points"
                 units=""
             /></div>
@@ -66,6 +66,7 @@
 import {
   defineComponent,
   computed,
+  watch
   } from 'vue'
 import { useStore } from 'src/store'
 import InputWithUnits from 'components/InputWithUnits.vue'
@@ -100,16 +101,19 @@ export default defineComponent({
     //   set: val => $store.commit('simulationSetup/setNearFieldMaxComputeTime', val)
     // })
 
-    const plotSideResolution = computed({
-      get: () => $store.state.simulationSetup.gui.nearFieldSetup.plotSideResolution,
+    const plotXSideResolution = computed({
+      get: () => $store.state.simulationSetup.gui.nearFieldSetup.plotXSideResolution,
       // TODO: make InputWithUnits to handle integer input, so no need to use floor() in the next line.
-      set: val => $store.commit('simulationSetup/setNearFieldPlotSideResolution', Math.floor(val))
+      set: val => $store.commit('simulationSetup/setNearFieldPlotXSideResolution', Math.floor(val))
     })
 
+    watch(plotXSideResolution, ()=>{
+      $store.commit('simulationSetup/setNearFieldPlotYSideResolution', plotXSideResolution.value)
+    })
     return { crossSection, isShowingHelpForInputWithUnits, flexRowTitleStyle,
       relativePlotSize,
       // maxComputeTime,
-      plotSideResolution, nearFieldPlane}
+      plotXSideResolution, nearFieldPlane}
   },
 })
 </script>

+ 8 - 129
guiapp/src/components/nearfield/PlotNearField.vue

@@ -60,19 +60,21 @@ export default defineComponent({
     const nearFieldPlot = reactive(nearFieldPlotInit)
     const crossSection = computed(()=>$store.state.simulationSetup.current.nearFieldSetup.crossSection)
     const relativePlotSize = computed(()=>$store.state.simulationSetup.current.nearFieldSetup.relativePlotSize)
-    const plotSideResolution = computed(()=>$store.state.simulationSetup.current.nearFieldSetup.plotSideResolution)
+    const plotYSideResolution = computed(()=>$store.state.simulationSetup.current.nearFieldSetup.plotYSideResolution)
+    const plotXSideResolution = computed(()=>$store.state.simulationSetup.current.nearFieldSetup.plotXSideResolution)
     const layerWidths = computed(()=>$store.state.simulationSetup.current.layers.map(x=>x.layerWidth))
     const totalR = computed(()=>layerWidths.value.reduce((a, b) => a + b, 0))
     const x0 = computed(()=>totalR.value*relativePlotSize.value)
-    const dx = computed(()=>x0.value*2.0/(plotSideResolution.value-1))
+    const dx = computed(()=>x0.value*2.0/(plotXSideResolution.value-1))
     const units = computed(()=>$store.state.guiRuntime.units)
+
     const xy = computed(()=> {
       let x:number[] = []
       let y:number[] = []
-      for (let i = 0; i< plotSideResolution.value; ++i) {
-        for (let j = 0; j< plotSideResolution.value; ++j) {
-          x.push(toUnits(-x0.value + j * dx.value, units.value))
-          y.push(toUnits(-x0.value + i * dx.value, units.value))
+      for (let j = 0; j< plotYSideResolution.value; ++j) {
+        for (let i = 0; i< plotXSideResolution.value; ++i) {
+          x.push(toUnits(-x0.value + i * dx.value, units.value))
+          y.push(toUnits(-x0.value + j * dx.value, units.value))
         }
       }
       return {x:x, y:y}
@@ -133,129 +135,6 @@ export default defineComponent({
       if (nearFieldPlot.layout.xaxis) nearFieldPlot.layout.xaxis.title = xaxisTitle.value
     })
 
-    // const plotRange=ref('material data')
-    // const isPlotReN = ref(true)
-    // const isPlotImN = ref(true)
-    // const isPlotInterpolation = ref(true)
-    //
-    // const fromWL = computed(()=>$store.state.simulationSetup.gui.fromWL)
-    // const toWL = computed(()=>$store.state.simulationSetup.gui.toWL)
-    // const pointsWL = computed(()=>$store.state.simulationSetup.gui.pointsWL)
-    //
-    // // updatenearFieldPlot used to be a Vuex mutation with a single argument. As
-    // // long as it is in the component feel free as many arguments as needed.
-    // function updatenearFieldPlot( val:{activatedMaterials:material[], sourceUnits:string,
-    //     fromWL:number, toWL:number, pointsWL:number, plotRange: string,
-    //     isPlotReN: boolean, isPlotImN: boolean, isPlotInterpolation: boolean })
-    // {
-    //   nearFieldPlot.data.length = 0
-    //   for (const material of val.activatedMaterials) {
-    //     if (!material.isPlot) continue
-    //
-    //     if (!material.nSpline) continue
-    //     if (val.isPlotReN) {
-    //       const traceDataReN: Partial<Data> = {
-    //         x: material.nSpline.xs.map(x => toUnits(x, val.sourceUnits)),
-    //         y: material.nSpline.ys,
-    //         mode: 'markers',
-    //         marker:{size:5},
-    //         type: 'scatter',
-    //         name: 'Re(n) ' + material.name + ' data'
-    //       }
-    //       nearFieldPlot.data.push(traceDataReN)
-    //     }
-    //
-    //     if (!material.kSpline) continue
-    //     if (val.isPlotImN) {
-    //       const traceDataImN: Partial<Data> = {
-    //         x: material.kSpline.xs.map(x => toUnits(x, val.sourceUnits)),
-    //         y: material.kSpline.ys,
-    //         mode: 'markers',
-    //         marker:{size:5},
-    //         type: 'scatter',
-    //         name: 'Im(n) ' + material.name + ' data'
-    //       }
-    //       nearFieldPlot.data.push(traceDataImN)
-    //     }
-    //
-    //     if (val.isPlotInterpolation) {
-    //       let fromWL = val.fromWL
-    //       let toWL = val.toWL
-    //       let pointsWL = val.pointsWL-1
-    //       if (nearFieldPlot.layout.xaxis) nearFieldPlot.layout.xaxis.range = [fromWL, toWL]
-    //       if (val.plotRange == 'material data') {
-    //         fromWL = material.nSpline.xs[0]
-    //         toWL = material.nSpline.xs[material.nSpline.xs.length-1]
-    //         pointsWL = 1000
-    //         if (nearFieldPlot.layout.xaxis) nearFieldPlot.layout.xaxis.range = undefined
-    //       }
-    //       const stepWL = (toWL-fromWL)/pointsWL
-    //
-    //       const WLs:number[] =[]
-    //       const nSpline:number[] = []
-    //       const kSpline:number[] = []
-    //       for (let i=0; i<pointsWL; ++i) {
-    //         WLs.push(fromWL+i*stepWL)
-    //         nSpline.push(material.nSpline.at(fromWL+i*stepWL))
-    //         kSpline.push(material.kSpline.at(fromWL+i*stepWL))
-    //       }
-    //       WLs.push(toWL)
-    //       nSpline.push(material.nSpline.at(toWL))
-    //       kSpline.push(material.kSpline.at(toWL))
-    //
-    //       if (val.isPlotReN) {
-    //         if (!material.nSpline) continue
-    //         const traceDataReNi: Partial<Data> = {
-    //           x: WLs.map(x => toUnits(x, val.sourceUnits)),
-    //           y: nSpline,
-    //           type: 'scatter',
-    //           name: 'Re(n) ' + material.name + ' interpolate'
-    //         }
-    //         nearFieldPlot.data.push(traceDataReNi)
-    //       }
-    //
-    //       if (val.isPlotImN) {
-    //         if (!material.nSpline) continue
-    //         const traceDataImNi: Partial<Data> = {
-    //           x: WLs.map(x => toUnits(x, val.sourceUnits)),
-    //           y: kSpline,
-    //           type: 'scatter',
-    //           name: 'Im(n) ' + material.name + ' interpolate'
-    //         }
-    //         nearFieldPlot.data.push(traceDataImNi)
-    //       }
-    //
-    //     }
-    //   }
-    // }
-    //
-    // function updateSpectraPlot() {
-    //   updatenearFieldPlot(
-    //       {
-    //         activatedMaterials: $store.state.guiRuntime.activatedMaterials,
-    //         sourceUnits: sourceUnits.value,
-    //         fromWL: fromWL.value,
-    //         toWL: toWL.value,
-    //         pointsWL: pointsWL.value,
-    //         plotRange: plotRange.value,
-    //         isPlotReN: isPlotReN.value,
-    //         isPlotImN: isPlotImN.value,
-    //         isPlotInterpolation: isPlotInterpolation.value
-    //       })
-    // }
-    //
-    // updateSpectraPlot()
-    //
-    // const materialsToPlot=computed(()=>$store.state.guiRuntime.activatedMaterials
-    //     .filter((val)=>val.isPlot)
-    //     .map(val=>val.name))
-    //
-    // watch ([materialsToPlot, plotRange, isPlotReN, isPlotImN, isPlotInterpolation], ()=>{
-    //   updateSpectraPlot()
-    // })
-    //
-    // onActivated(()=>updateSpectraPlot())
-
     return {
       nearFieldPlot, totalR
 

+ 8 - 92
guiapp/src/components/nearfield/RunSimulationNearField.vue

@@ -21,15 +21,9 @@
     </div>
 <!--    <div class="col-xs-grow col-sm q-px-xs">-->
 <!--      <div class="row justify-xs-center justify-sm-start items-baseline">-->
-
 <!--        <div class="col-auto">-->
-<!--          <q-btn-->
-<!--              color="primary"-->
-<!--              no-caps-->
-<!--              @click="saveSpectrumSimulation"-->
-<!--          >Save</q-btn>-->
+<!--          <SaveSimulationNearField/>-->
 <!--        </div>-->
-
 <!--      </div>-->
 <!--    </div>-->
   </div>
@@ -38,15 +32,14 @@
 <script lang="ts">
 import {computed, defineComponent, nextTick} from 'vue'
 import {useStore} from 'src/store'
-import {getModeName, range, rangeInt} from 'components/utils'
 import {cloneDeep} from 'lodash'
-import {saveAs} from 'file-saver'
 import {nearFieldPlane} from 'src/store/simulation-setup/state';
+// import SaveSimulationNearField from 'components/nearfield/SaveSimulationNearField.vue'
 
 
 export default defineComponent({
   name: 'RunSimulationNearField',
-
+  // components: {SaveSimulationNearField},
   setup() {
     const $store = useStore()
 
@@ -75,7 +68,8 @@ export default defineComponent({
           $store.commit('simulationSetup/copySetupFromGuiToCurrent')
 
           const host = $store.state.simulationSetup.current.hostIndex
-          const plotSideResolution = $store.state.simulationSetup.current.nearFieldSetup.plotSideResolution
+          const plotXSideResolution = $store.state.simulationSetup.current.nearFieldSetup.plotXSideResolution
+          const plotYSideResolution = $store.state.simulationSetup.current.nearFieldSetup.plotYSideResolution
           const relativePlotSize = $store.state.simulationSetup.current.nearFieldSetup.relativePlotSize
           const crossSection = $store.state.simulationSetup.current.nearFieldSetup.crossSection
           try {
@@ -95,7 +89,8 @@ export default defineComponent({
             nmie.SetModeNmaxAndType(-1, -1)
 
             nmie.RunFieldCalculationCartesian(
-                plotSideResolution,
+                plotYSideResolution,
+                plotXSideResolution, // in simulation z-axis resolution for Ek and Hk cross-sections
                 relativePlotSize,
                 crossSection,
                 0, 0, 0, 1
@@ -117,88 +112,9 @@ export default defineComponent({
     }
 
     runNearFieldSimulation()
-    // watch(isRunning, ()=>{
-    //       console.log(isRunning.value)
-    // })
-
-    // onActivated(()=>{
-    //   if (isNmieLoaded.value) runNearFieldSimulation()
-    // })
-
-
 
     return { isRunning, isNmieLoaded,
-      runNearFieldSimulation,
-      saveSpectrumSimulation(){
-        const fileHeader = '# # You can open and plot this file using Python\n' +
-            '# # (without manually removing this header, it will be skipped), see example below.\n' +
-            '# import numpy as np\n' +
-            '# from matplotlib import pyplot as plt\n' +
-            '# data = np.genfromtxt(\'scattnlay-spectra.txt\', skip_header=21, names=True, delimiter=\', \')\n' +
-            '# x = data[data.dtype.names[0]] # x-axis has units\n' +
-            '# # Possible labels for spectrum data: Qsca, Qabs, Qext,\n' +
-            '# # Qsca_E_dipole, etc. (see last comment before spectra data)\n' +
-            '# a = data[\'Qsca\']\n' +
-            '# b = data[\'Qsca_E_dipole\']\n' +
-            '# c = data[\'Qsca_H_dipole\']\n' +
-            '# \n' +
-            '# plt.figure()\n' +
-            '# plt.plot(x, a, label=\'Qsca\')\n' +
-            '# plt.plot(x, b, label=\'Qsca E dipole\')\n' +
-            '# plt.plot(x, c, label=\'Qsca H dipole\')\n' +
-            '# plt.legend()\n' +
-            '# plt.xlabel(data.dtype.names[0].replace(\'_\', \', \'))\n' +
-            '# plt.ylabel(\'Normalized cross-sections\')\n' +
-            '# plt.show()\n\n'
-        let xTitle = 'x'
-        if ( $store.state.plotRuntime.spectrumPlots.layout.xaxis ) {
-          xTitle = String($store.state.plotRuntime.spectrumPlots.layout.xaxis.title)
-        }
-
-        let columnNames = '# ' + xTitle + ', Qsca, Qabs, Qext, '
-        const mode_n = rangeInt($store.state.simulationSetup.current.numberOfModesToPlot, 1);
-        const mode_types = range(0, 1);
-        for (const n of mode_n) {
-          for (const mode_type of mode_types) {
-            const modeTypeName = mode_type == 0 ? 'E' : 'H'
-            columnNames += 'Qsca_' + modeTypeName + '_' +getModeName(n)+', '
-            columnNames += 'Qabs_' + modeTypeName + '_' +getModeName(n)+', '
-            columnNames += 'Qext_' + modeTypeName + '_' +getModeName(n)+', '
-          }
-        }
-        columnNames = columnNames.slice(0, -2)
-        columnNames += '\n'
-        let body = ''
-        const WLs = $store.state.plotRuntime.WLsInUnits
-        const Qsca = $store.state.plotRuntime.Qsca
-        const Qabs = $store.state.plotRuntime.Qabs
-        const Qext = $store.state.plotRuntime.Qext
-        const Qsca_n = $store.state.plotRuntime.Qsca_n
-        const Qabs_n = $store.state.plotRuntime.Qabs_n
-        const Qext_n = $store.state.plotRuntime.Qext_n
-        for (let i = 0; i < WLs.length; ++i) {
-          let row = WLs[i].toString() + ', '
-              + Qsca[i].toString() + ', '
-              + Qabs[i].toString() + ', '
-              + Qext[i].toString() + ', '
-          for (const n of mode_n) {
-            for (const mode_type of mode_types) {
-              row += Qsca_n[mode_type][n - 1][i].toString() + ', '
-              row += Qabs_n[mode_type][n - 1][i].toString() + ', '
-              row += Qext_n[mode_type][n - 1][i].toString() + ', '
-            }
-          }
-          row = row.slice(0, -2)
-          row += '\n'
-          body += row
-        }
-
-        const scattnlaySpectra = new Blob([fileHeader+columnNames+body],
-            {type: 'text/plain;charset=utf-8',
-              endings: 'native'}  //TODO test if newline is correctly written in Windows, MacOS
-        )
-        saveAs(scattnlaySpectra, 'scattnlay-spectra.txt');
-      }
+      runNearFieldSimulation
     }
   },
 })

+ 2 - 2
guiapp/src/components/spectrum/PlotSpectra.vue

@@ -5,8 +5,8 @@
 </template>
 
 <script>
-import ReactiveChart from 'guiapp/src/components/ReactiveChart.vue'
-import { useStore } from 'guiapp/src/store'
+import ReactiveChart from 'components/ReactiveChart.vue'
+import { useStore } from 'src/store'
 import {
   defineComponent,
   computed,

+ 2 - 1
guiapp/src/nmiejs.d.ts

@@ -21,7 +21,8 @@ export class nmie_class {
                              from_Theta: number,   to_Theta: number,
                              from_Phi: number,   to_Phi: number,
                              isIgnoreAvailableNmax: number): void;
-    RunFieldCalculationCartesian( side_points: number, relative_side_length: number, plane_selected: number,
+    RunFieldCalculationCartesian( side_1_points: number, side_2_points: number,
+                                  relative_side_length: number, plane_selected: number,
                                   at_x: number, at_y: number, at_z: number,
                                   isIgnoreAvailableNmax: number): void;
 

+ 5 - 1
guiapp/src/pages/Near-field.vue

@@ -12,8 +12,10 @@
     <PlotNearField/>
     <div class="q-ma-xs"/>
     <GetNearFieldColorScale/>
+    <div class="q-ma-xs"/>
+    <GetNearFieldRefinedSettings/>
 <!--    <div class="col-auto">-->
-<!--      Input result: {{$store.state.simulationSetup.gui.nearFieldSetup.plotSideResolution}}-->
+<!--      Input result: {{$store.state.simulationSetup.gui.nearFieldSetup.plotYSideResolution}}-->
 <!--    </div>-->
 
     <div class="q-ma-lg"/>
@@ -35,6 +37,7 @@ import RunSimulationNearField from 'components/nearfield/RunSimulationNearField.
 import PlotNearField from 'components/nearfield/PlotNearField.vue'
 import ShowNearFieldWarning from 'components/nearfield/ShowNearFieldWarning.vue'
 import GetNearFieldColorScale from 'components/nearfield/GetNearFieldColorScale.vue'
+import GetNearFieldRefinedSettings from 'components/nearfield/GetNearFieldRefinedSettings.vue'
 
 // import { useStore } from 'src/store'
 
@@ -42,6 +45,7 @@ import GetNearFieldColorScale from 'components/nearfield/GetNearFieldColorScale.
 export default defineComponent({
   name: 'NearField',
   components: {
+    GetNearFieldRefinedSettings,
     GetNearFieldColorScale,
     ShowNearFieldWarning,
     PlotNearField,

+ 5 - 1
guiapp/src/store/simulation-setup/mutations.ts

@@ -70,7 +70,11 @@ const mutation: MutationTree<sssi> = {
 
   setNearFieldWL                 (state: sssi, val: number)         {state.gui.nearFieldSetup.atWL               = val},
   setNearFieldRelativePlotSize   (state: sssi, val: number)         {state.gui.nearFieldSetup.relativePlotSize   = val},
-  setNearFieldPlotSideResolution (state: sssi, val: number)         {state.gui.nearFieldSetup.plotSideResolution = val},
+  setNearFieldAtRelativeX0       (state: sssi, val: number)         {state.gui.nearFieldSetup.atRelativeX0   = val},
+  setNearFieldAtRelativeY0       (state: sssi, val: number)         {state.gui.nearFieldSetup.atRelativeY0   = val},
+  setNearFieldAtRelativeZ0       (state: sssi, val: number)         {state.gui.nearFieldSetup.atRelativeZ0   = val},
+  setNearFieldPlotXSideResolution (state: sssi, val: number)      {state.gui.nearFieldSetup.plotXSideResolution = val},
+  setNearFieldPlotYSideResolution (state: sssi, val: number)      {state.gui.nearFieldSetup.plotYSideResolution = val},
   setNearFieldCrossSection       (state: sssi, val: nearFieldPlane) {state.gui.nearFieldSetup.crossSection       = val},
   // setNearFieldMaxComputeTime     (state: sssi, val: number)         {state.gui.nearFieldSetup.maxComputeTime     = val},
 

+ 12 - 2
guiapp/src/store/simulation-setup/state.ts

@@ -28,7 +28,13 @@ export enum nearFieldPlane {
 export interface nearFieldSetup {
   atWL:number
   relativePlotSize: number
-  plotSideResolution: number
+  // X0, Y0, and Z0 refers to simulation
+  atRelativeX0: number
+  atRelativeY0: number
+  atRelativeZ0: number
+  // X and Y refers to plot
+  plotXSideResolution: number
+  plotYSideResolution: number
   crossSection: nearFieldPlane
   // maxComputeTime: number //in seconds
 }
@@ -73,7 +79,11 @@ function setupFactory(hostIndex = 1,
                       nearFieldSetup = {
                         atWL: 619.3885178,
                         relativePlotSize: 2,
-                        plotSideResolution: 64,
+                        atRelativeX0: 0,
+                        atRelativeY0: 0,
+                        atRelativeZ0: 0,
+                        plotXSideResolution: 64,
+                        plotYSideResolution: 64,
                         crossSection: nearFieldPlane.Ek,
                         // maxComputeTime: 5 //in seconds
                       },

+ 4 - 2
src/nmie-applied-impl.hpp

@@ -313,7 +313,8 @@ namespace nmie {
   }
 
 template <typename FloatType>
-void MultiLayerMieApplied<FloatType>::RunFieldCalculationCartesian(const int side_points,
+void MultiLayerMieApplied<FloatType>::RunFieldCalculationCartesian(const int side_1_points,
+                                                                   const int side_2_points,
                                                             const double relative_side_length,
                                                             const int plane_selected,
                                                             const double at_x, const double at_y,
@@ -321,7 +322,8 @@ void MultiLayerMieApplied<FloatType>::RunFieldCalculationCartesian(const int sid
                                                             const int isIgnoreAvailableNmax) {
 //  std::cout<<'test'<<std::endl;
   ConvertToSP();
-  this->MultiLayerMie<FloatType>::RunFieldCalculationCartesian( side_points, relative_side_length, plane_selected,
+  this->MultiLayerMie<FloatType>::RunFieldCalculationCartesian( side_1_points, side_2_points,
+                                                                relative_side_length, plane_selected,
                                                                 at_x, at_y, at_z,
                                                                 isIgnoreAvailableNmax == 0 ? false : true);
 

+ 2 - 1
src/nmie-applied.hpp

@@ -64,7 +64,8 @@ namespace nmie {
                                   const double from_Theta, const double to_Theta,
                                   const double from_Phi, const double to_Phi,
                                   const int isIgnoreAvailableNmax);
-    void RunFieldCalculationCartesian(const int side_points,
+    void RunFieldCalculationCartesian(const int side_1_points,
+                                      const int side_2_points,
                                       const double relative_side_length,
                                       const int plane_selected,
                                       const double at_x, const double at_y,

+ 9 - 8
src/nmie-nearfield.hpp

@@ -654,7 +654,8 @@ bool MultiLayerMie<FloatType>::GetFieldConvergence () {
 }
 
 template <typename FloatType>
-void MultiLayerMie<FloatType>::RunFieldCalculationCartesian(const int side_points,
+void MultiLayerMie<FloatType>::RunFieldCalculationCartesian(const int side_1_points,
+                                                            const int side_2_points,
                                                             const double relative_side_length,
                                                             const int plane_selected,
                                                             const double at_x, const double at_y,
@@ -665,7 +666,7 @@ void MultiLayerMie<FloatType>::RunFieldCalculationCartesian(const int side_point
   std::vector<FloatType> Xp(0), Yp(0), Zp(0);
   if (size_param_.size()<1) throw "Expect size_param_ to have at least one element before running a simulation";
   const FloatType max_coord_value = size_param_.back() * relative_side_length;
-  const FloatType dx = max_coord_value*2/( (side_points<2 ? 2 : side_points) - 1.0);
+  const FloatType dx = max_coord_value*2/( (side_1_points<2 ? 2 : side_1_points) - 1.0);
   const FloatType dy = dx, dz = dx;
   auto push_coords = [&](
       const int nx, const int ny, const int nz,
@@ -681,18 +682,18 @@ void MultiLayerMie<FloatType>::RunFieldCalculationCartesian(const int side_point
     }
   };
   if (plane_selected == Planes::kEk ) {
-    push_coords(          side_points,      1,           side_points,
-                -max_coord_value+at_x,   at_y, -max_coord_value+at_z);
+    push_coords(side_1_points, 1, side_2_points,
+                -max_coord_value+at_x, at_y, -max_coord_value+at_z);
   }
   if (plane_selected == Planes::kHk ) {
-    push_coords(    1,            side_points,           side_points,
-                 at_x,  -max_coord_value+at_y, -max_coord_value+at_z);
+    push_coords(1, side_1_points, side_2_points,
+                at_x, -max_coord_value+at_y, -max_coord_value+at_z);
   }
   if (plane_selected == Planes::kEH) {
-    push_coords(          side_points,           side_points,    1,
+    push_coords(side_1_points, side_2_points, 1,
                 -max_coord_value+at_x, -max_coord_value+at_y, at_z);
   }
-  const unsigned int total_size = side_points*side_points;
+  const unsigned int total_size = side_1_points*side_2_points;
   if (Xp.size() != total_size || Yp.size() != total_size || Zp.size() != total_size)
     throw std::invalid_argument("Error! Wrong dimension of field monitor points for cartesian grid!");
   SetFieldCoords({Xp, Yp, Zp});

+ 2 - 1
src/nmie.hpp

@@ -169,7 +169,8 @@ inline std::complex<T> my_exp(const std::complex<T> &x) {
                                   const double from_Phi=0, const double to_Phi=static_cast<double>(3.14159265358979323),
                                   const bool isMarkUnconverged = true,
                                   int nmax_in = -1);
-    void RunFieldCalculationCartesian(const int side_points = 2,
+    void RunFieldCalculationCartesian(const int side_1_points = 2,
+                                      const int side_2_points = 2,
                                       const double relative_side_length = 2,
                                       const int plane_selected = Planes::kEk,
                                       const double at_x = 0, const double at_y = 0,

+ 3 - 3
tests/test_near_field.cc

@@ -15,11 +15,11 @@ TEST(RunFieldCalculationCartesian, HandlesInput) {
   nmie.RunMieCalculation();
   int nmax = 21;
   // TODO add check of E and H symmetry for X and Y axis inversion
-  nmie.RunFieldCalculationCartesian(2, 2, nmie::Planes::kEk,
+  nmie.RunFieldCalculationCartesian(2, 2, 2, nmie::Planes::kEk,
                                     0, 0, 0, true, nmax);
-  nmie.RunFieldCalculationCartesian(2, 2, nmie::Planes::kHk,
+  nmie.RunFieldCalculationCartesian(2, 2, 2, nmie::Planes::kHk,
                                     0, 0, 0, true, nmax);
-  nmie.RunFieldCalculationCartesian(2, 2, nmie::Planes::kEH,
+  nmie.RunFieldCalculationCartesian(2, 2, 2, nmie::Planes::kEH,
                                     0, 0, 0, true, nmax);
 
 //  EXPECT_EQ(1, nmie.GetMaxTerms());