Преглед на файлове

simple RunSimulation seems to work

Konstantin Ladutenko преди 3 години
родител
ревизия
fdf427e660
променени са 2 файла, в които са добавени 54 реда и са изтрити 4 реда
  1. 53 3
      guiapp/src/components/RunSimulationSpectrum.vue
  2. 1 1
      guiapp/src/components/utils.ts

+ 53 - 3
guiapp/src/components/RunSimulationSpectrum.vue

@@ -44,11 +44,10 @@ export default defineComponent({
 
     const isNmieLoaded = computed(()=>{ return $store.state.simulationSetup.isNmieLoaded })
 
-    return { isRunning, isNmieLoaded,
       //-----------------------------------------------------------------------//
       //-------------------  Main  --------------------------------------------//
       //-----------------------------------------------------------------------//
-      runSpectrumSimulation() {
+    function runSpectrumSimulation() {
         isRunning.value = true
         $store.commit('simulationSetup/copySetupFromGuiToCurrent')
 
@@ -58,12 +57,63 @@ export default defineComponent({
         const toWL = $store.state.simulationSetup.current.toWL
         const pointsWL = $store.state.simulationSetup.current.pointsWL
         const stepWL = (toWL-fromWL)/(pointsWL-1)
-        let WLs = range(fromWL, toWL, stepWL);
+        const WLs = range(fromWL, toWL, stepWL);
 
         const total_mode_n = $store.state.simulationSetup.current.numberOfModesToPlot
+        const mode_n = rangeInt(total_mode_n, 1);
+        const mode_types = range(0, 1);
+
+        let Qsca:number[] = [], Qabs:number[] = [], Qext:number[] = []
+        let Qsca_n:number[][][] = [[], []]
+        let Qabs_n:number[][][] = [[], []]
+        let Qext_n:number[][][] = [[], []]
+
+        mode_types.forEach(function (mode_type) {
+          mode_n.forEach(function () {
+            Qsca_n[mode_type].push([])
+            Qabs_n[mode_type].push([])
+            Qext_n[mode_type].push([])
+          })
+        })
+        try {
+          if (!$store.state.simulationSetup.nmie) throw 'ERROR! Scattnlay module was not loaded'
+          const nmie = $store.state.simulationSetup.nmie
 
+          for (const WL of WLs) {
+            nmie.ClearTarget()
+            for (const layer of $store.state.simulationSetup.current.layers) {
+              let reN = layer.n
+              let imN = layer.k
+              if (layer.nSpline) reN = layer.nSpline.at(WL)
+              if (layer.kSpline) imN = layer.kSpline.at(WL)
+              nmie.AddTargetLayerReIm(  layer.layerWidth*host,
+                  reN/host, imN/host);
+            }
+            nmie.SetModeNmaxAndType(-1, -1);
+            nmie.SetWavelength(WL);
+            nmie.RunMieCalculation();
+            Qsca.push(nmie.GetQsca());
+            Qabs.push(nmie.GetQabs());
+            Qext.push(nmie.GetQsca()+nmie.GetQabs());
+            mode_types.forEach(function (mode_type) {
+              mode_n.forEach(function (n) {
+                nmie.SetModeNmaxAndType(n, mode_type);
+                nmie.RunMieCalculation();
+                Qsca_n[mode_type][n - 1].push(nmie.GetQsca());
+                Qabs_n[mode_type][n - 1].push(nmie.GetQabs());
+                Qext_n[mode_type][n - 1].push(nmie.GetQext());
+              });
+            });
+
+          }
+        } catch (e) {
+          console.log(e)
+        }
+        console.log(Qsca)
         isRunning.value = false
       }
+    return { isRunning, isNmieLoaded,
+      runSpectrumSimulation
     }
   },
 })

+ 1 - 1
guiapp/src/components/utils.ts

@@ -1,7 +1,7 @@
 export const flexRowTitleStyle='width:10em; margin: auto;'
 
 export function range(start:number, stop:number, step = 1) {
-    return Array(Math.ceil((stop - start) / step)).fill(start).map((x:number, y:number) => x + y * step)
+    return Array(Math.round(((stop - start) / step)+1)).fill(start).map((x:number, y:number) => x + y * step)
 }
 
 export function rangeInt(size:number, startAt = 0) {