Konstantin Ladutenko 3 jaren geleden
bovenliggende
commit
90aa99d780

+ 96 - 256
Makefile

@@ -1,258 +1,98 @@
-# CMAKE generated file: DO NOT EDIT!
-# Generated by "Unix Makefiles" Generator, CMake Version 3.16
+PYTHON=`which python3`
+DESTDIR=/
+PROJECT=python-scattnlay
+VERSION=2.3
+BUILDIR=$(CURDIR)/debian/$(PROJECT)
+SRCDIR=$(CURDIR)/src
+MULTIPREC=100
+CXX_NMIE_HEADERS=$(SRCDIR)/nmie.hpp $(SRCDIR)/nmie-basic.hpp $(SRCDIR)/nmie-nearfield.hpp  $(SRCDIR)/nmie-precision.hpp
+
+all:
+	@echo "make source - Create source package for Python extension"
+	@echo "make ext - Create Python extension in place"
+	@echo "make install - Install Python extension on local system"
+	@echo "make rpm - Generate a rpm package for Python extension"
+	@echo "make deb - Generate a deb package for Python extension"
+	@echo "make standalone - Create standalone programs (scattnlay and fieldnlay)"
+	@echo "make clean - Delete temporal files"
+#	make standalone
+
+source:
+	$(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../
+
+ext: $(SRCDIR)/pb11_wrapper.cc $(CXX_NMIE_HEADERS)
+	$(PYTHON) setup.py build_ext --inplace
+
+install:
+	$(PYTHON) setup.py install --root $(DESTDIR) $(COMPILE)
+
+rpm:
+	#$(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall
+	$(PYTHON) setup.py bdist_rpm --dist-dir=../
+
+deb: source
+	# build the source package in the parent directory
+	# then rename it to project_version.orig.tar.gz
+	rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*
+	# build the package
+	dpkg-buildpackage -i -I -rfakeroot
+
+standalone: scattnlay-dp fieldnlay-dp scattnlay-mp fieldnlay-mp
+
+# standalone programs with DP
+scattnlay-dp: $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc $(CXX_NMIE_HEADERS)
+	$(CXX) -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc  -lm -o scattnlay-dp $(CXXFLAGS) $(LDFLAGS)
+
+fieldnlay-dp: $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc $(CXX_NMIE_HEADERS)
+	$(CXX) -DNDEBUG -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc  -lm -o fieldnlay-dp $(CXXFLAGS) $(LDFLAGS)
+
+# standalone programs with MP
+scattnlay-mp: $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc $(CXX_NMIE_HEADERS)
+	$(CXX) -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/farfield.cc $(SRCDIR)/nmie.cc  -lm -o scattnlay-mp $(CXXFLAGS) $(LDFLAGS)
+
+fieldnlay-mp: $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc $(CXX_NMIE_HEADERS)
+	$(CXX) -DNDEBUG -DMULTI_PRECISION=$(MULTIPREC) -O2 -Wall -std=c++11 $(SRCDIR)/nearfield.cc $(SRCDIR)/nmie.cc  -lm -o fieldnlay-mp $(CXXFLAGS) $(LDFLAGS)
+
+wasm: $(SRCDIR)/nmie-js-wrapper.cc $(CXX_NMIE_HEADERS)
+#    emcc -lm -Wall -O2 -std=c++11 --bind -s ENVIRONMENT="web" -s MODULARIZE=1 -s SINGLE_FILE=1 -s WASM=1 -o nmie.js $(SRCDIR)/nmie-js-wrapper.cc
+#	emcc --bind -lm -Wall -O2 -std=c++11 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun']" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
+# 	emcc --bind -lm -Wall -O2 -std=c++11 -s MODULARIZE=1 -s WASM=1 -o nmie.js $(SRCDIR)/nmie-js-wrapper.cc
+
+	emcc --bind -lm -Wall -pedantic -O2 -std=c++11 -s NO_DISABLE_EXCEPTION_CATCHING -s MODULARIZE=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
+#	emcc --bind -lm -Wall -pedantic -Oz -std=c++11 -s NO_DISABLE_EXCEPTION_CATCHING -s MODULARIZE=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
+#	emcc --bind -lm -Wall -pedantic -Oz -std=c++11 -s NO_DISABLE_EXCEPTION_CATCHING -s MODULARIZE=1 -s EXPORT_ES6=1 -s ASSERTIONS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORT_NAME="nmiejs" -s ENVIRONMENT="web" -o nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
+
+#	emcc --bind -lm -Wall -O3 -std=c++11 -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME="nmiejs"' -o ./nmiejs.js $(SRCDIR)/nmie-js-wrapper.cc
+# 	emcc -g --bind -lm -Wall -std=c++11 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun']" -o nmie.js $(SRCDIR)/nmie-js-wrapper.cc
+# 	emcc --bind -lm -Wall -O2 -std=c++11 -s MODULARIZE=1 -s EXPORT_ES6=1 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun']" -o nmie.js $(SRCDIR)/nmie-js-wrapper.cc
+
+#     "build:codec": "emcc -O3 -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"cwrap\"]' -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME=\"fibonacci\"' -o ./fibonacci.js fibonacci.c",
+
+# emcc -O2 \
+#     oniguruma/src/.libs/libonig.so \
+#     src/onigasm.cc\
+#     -Isrc -Ioniguruma/src \
+#     -s ENVIRONMENT=shell \
+#     -s NO_EXIT_RUNTIME=1 \
+#     -s NO_FILESYSTEM=1 \
+#     -s TOTAL_MEMORY=157286400 \
+#     -s ALLOW_MEMORY_GROWTH=1 \
+#     -s DEMANGLE_SUPPORT=1 \
+#     -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall']" \
+#     -s MODULARIZE=1 \
+#     -s EXPORT_NAME="'Onigasm'" \
+#     -o lib/onigasm.js
+
+
+	@cp -f nmiejs.js vue-cli3-webapp/src/
+	@cp -f nmiejs.js guiapp/src/
+	@cp -f nmiejs.wasm vue-cli3-webapp/public/
+	@cp -f nmiejs.wasm guiapp/public/
 
-# Default target executed when no arguments are given to make.
-default_target: all
-
-.PHONY : default_target
-
-# Allow only one "make -f Makefile2" at a time, but pass parallelism.
-.NOTPARALLEL:
-
-
-#=============================================================================
-# Special targets provided by cmake.
-
-# Disable implicit rules so canonical targets will work.
-.SUFFIXES:
-
-
-# Remove some rules from gmake that .SUFFIXES does not remove.
-SUFFIXES =
-
-.SUFFIXES: .hpux_make_needs_suffix_list
-
-
-# Suppress display of executed commands.
-$(VERBOSE).SILENT:
-
-
-# A target that is always out of date.
-cmake_force:
-
-.PHONY : cmake_force
-
-#=============================================================================
-# Set environment variables for the build.
-
-# The shell in which to execute make rules.
-SHELL = /bin/sh
-
-# The CMake executable.
-CMAKE_COMMAND = /opt/cmake/bin/cmake
-
-# The command to remove a file.
-RM = /opt/cmake/bin/cmake -E remove -f
-
-# Escaping for special characters.
-EQUALS = =
-
-# The top-level source directory on which CMake was run.
-CMAKE_SOURCE_DIR = /home/tig/KOsty/Prog/GitHub/scattnlay
-
-# The top-level build directory on which CMake was run.
-CMAKE_BINARY_DIR = /home/tig/KOsty/Prog/GitHub/scattnlay
-
-#=============================================================================
-# Targets provided globally by CMake.
-
-# Special rule for the target rebuild_cache
-rebuild_cache:
-	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
-	/opt/cmake/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
-.PHONY : rebuild_cache
-
-# Special rule for the target rebuild_cache
-rebuild_cache/fast: rebuild_cache
-
-.PHONY : rebuild_cache/fast
-
-# Special rule for the target edit_cache
-edit_cache:
-	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
-	/opt/cmake/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
-.PHONY : edit_cache
-
-# Special rule for the target edit_cache
-edit_cache/fast: edit_cache
-
-.PHONY : edit_cache/fast
-
-# Special rule for the target test
-test:
-	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
-	/opt/cmake/bin/ctest --force-new-ctest-process $(ARGS)
-.PHONY : test
-
-# Special rule for the target test
-test/fast: test
-
-.PHONY : test/fast
-
-# The main all target
-all: cmake_check_build_system
-	$(CMAKE_COMMAND) -E cmake_progress_start /home/tig/KOsty/Prog/GitHub/scattnlay/CMakeFiles /home/tig/KOsty/Prog/GitHub/scattnlay/CMakeFiles/progress.marks
-	$(MAKE) -f CMakeFiles/Makefile2 all
-	$(CMAKE_COMMAND) -E cmake_progress_start /home/tig/KOsty/Prog/GitHub/scattnlay/CMakeFiles 0
-.PHONY : all
-
-# The main clean target
 clean:
-	$(MAKE) -f CMakeFiles/Makefile2 clean
-.PHONY : clean
-
-# The main clean target
-clean/fast: clean
-
-.PHONY : clean/fast
-
-# Prepare targets for installation.
-preinstall: all
-	$(MAKE) -f CMakeFiles/Makefile2 preinstall
-.PHONY : preinstall
-
-# Prepare targets for installation.
-preinstall/fast:
-	$(MAKE) -f CMakeFiles/Makefile2 preinstall
-.PHONY : preinstall/fast
-
-# clear depends
-depend:
-	$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
-.PHONY : depend
-
-#=============================================================================
-# Target rules for targets named python3-scattnlay
-
-# Build rule for target.
-python3-scattnlay: cmake_check_build_system
-	$(MAKE) -f CMakeFiles/Makefile2 python3-scattnlay
-.PHONY : python3-scattnlay
-
-# fast build rule for target.
-python3-scattnlay/fast:
-	$(MAKE) -f src/CMakeFiles/python3-scattnlay.dir/build.make src/CMakeFiles/python3-scattnlay.dir/build
-.PHONY : python3-scattnlay/fast
-
-#=============================================================================
-# Target rules for targets named farfield
-
-# Build rule for target.
-farfield: cmake_check_build_system
-	$(MAKE) -f CMakeFiles/Makefile2 farfield
-.PHONY : farfield
-
-# fast build rule for target.
-farfield/fast:
-	$(MAKE) -f src/CMakeFiles/farfield.dir/build.make src/CMakeFiles/farfield.dir/build
-.PHONY : farfield/fast
-
-#=============================================================================
-# Target rules for targets named nearfield
-
-# Build rule for target.
-nearfield: cmake_check_build_system
-	$(MAKE) -f CMakeFiles/Makefile2 nearfield
-.PHONY : nearfield
-
-# fast build rule for target.
-nearfield/fast:
-	$(MAKE) -f src/CMakeFiles/nearfield.dir/build.make src/CMakeFiles/nearfield.dir/build
-.PHONY : nearfield/fast
-
-#=============================================================================
-# Target rules for targets named test_near_field_multi_precision
-
-# Build rule for target.
-test_near_field_multi_precision: cmake_check_build_system
-	$(MAKE) -f CMakeFiles/Makefile2 test_near_field_multi_precision
-.PHONY : test_near_field_multi_precision
-
-# fast build rule for target.
-test_near_field_multi_precision/fast:
-	$(MAKE) -f tests/CMakeFiles/test_near_field_multi_precision.dir/build.make tests/CMakeFiles/test_near_field_multi_precision.dir/build
-.PHONY : test_near_field_multi_precision/fast
-
-#=============================================================================
-# Target rules for targets named test_near_field
-
-# Build rule for target.
-test_near_field: cmake_check_build_system
-	$(MAKE) -f CMakeFiles/Makefile2 test_near_field
-.PHONY : test_near_field
-
-# fast build rule for target.
-test_near_field/fast:
-	$(MAKE) -f tests/CMakeFiles/test_near_field.dir/build.make tests/CMakeFiles/test_near_field.dir/build
-.PHONY : test_near_field/fast
-
-#=============================================================================
-# Target rules for targets named test_Riccati_Bessel_logarithmic_derivative
-
-# Build rule for target.
-test_Riccati_Bessel_logarithmic_derivative: cmake_check_build_system
-	$(MAKE) -f CMakeFiles/Makefile2 test_Riccati_Bessel_logarithmic_derivative
-.PHONY : test_Riccati_Bessel_logarithmic_derivative
-
-# fast build rule for target.
-test_Riccati_Bessel_logarithmic_derivative/fast:
-	$(MAKE) -f tests/CMakeFiles/test_Riccati_Bessel_logarithmic_derivative.dir/build.make tests/CMakeFiles/test_Riccati_Bessel_logarithmic_derivative.dir/build
-.PHONY : test_Riccati_Bessel_logarithmic_derivative/fast
-
-#=============================================================================
-# Target rules for targets named test_bulk_sphere
-
-# Build rule for target.
-test_bulk_sphere: cmake_check_build_system
-	$(MAKE) -f CMakeFiles/Makefile2 test_bulk_sphere
-.PHONY : test_bulk_sphere
-
-# fast build rule for target.
-test_bulk_sphere/fast:
-	$(MAKE) -f tests/CMakeFiles/test_bulk_sphere.dir/build.make tests/CMakeFiles/test_bulk_sphere.dir/build
-.PHONY : test_bulk_sphere/fast
-
-#=============================================================================
-# Target rules for targets named test_bulk_sphere_multi_precision
-
-# Build rule for target.
-test_bulk_sphere_multi_precision: cmake_check_build_system
-	$(MAKE) -f CMakeFiles/Makefile2 test_bulk_sphere_multi_precision
-.PHONY : test_bulk_sphere_multi_precision
-
-# fast build rule for target.
-test_bulk_sphere_multi_precision/fast:
-	$(MAKE) -f tests/CMakeFiles/test_bulk_sphere_multi_precision.dir/build.make tests/CMakeFiles/test_bulk_sphere_multi_precision.dir/build
-.PHONY : test_bulk_sphere_multi_precision/fast
-
-# Help Target
-help:
-	@echo "The following are some of the valid targets for this Makefile:"
-	@echo "... all (the default if no target is provided)"
-	@echo "... clean"
-	@echo "... depend"
-	@echo "... rebuild_cache"
-	@echo "... edit_cache"
-	@echo "... test"
-	@echo "... python3-scattnlay"
-	@echo "... farfield"
-	@echo "... nearfield"
-	@echo "... test_near_field_multi_precision"
-	@echo "... test_near_field"
-	@echo "... test_Riccati_Bessel_logarithmic_derivative"
-	@echo "... test_bulk_sphere"
-	@echo "... test_bulk_sphere_multi_precision"
-.PHONY : help
-
-
-
-#=============================================================================
-# Special targets to cleanup operation of make.
-
-# Special rule to run CMake to check the build system integrity.
-# No rule that depends on this can have commands that come from listfiles
-# because they might be regenerated.
-cmake_check_build_system:
-	$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
-.PHONY : cmake_check_build_system
-
+	$(PYTHON) setup.py clean
+	$(MAKE) -f $(CURDIR)/debian/rules clean
+	rm -rf build/ MANIFEST
+	find . -name '*.pyc' -delete
+	find . -name '*.o' -delete
+	find . -name '*.so' -delete

+ 7 - 1
guiapp/src/components/GetParticleParameters.vue

@@ -113,7 +113,7 @@ import {
   watch
   } from 'vue'
 import { useStore } from 'src/store'
-import { flexRowTitleStyle, fromUnits, toUnits } from 'components/utils'
+import {flexRowTitleStyle, fromUnits, isAlmostSame, toUnits} from 'components/utils'
 import {cloneDeep} from 'lodash'
 import InputWithUnits from 'components/InputWithUnits.vue';
 
@@ -149,6 +149,12 @@ export default defineComponent({
     })
 
     watch(layers, ()=>{
+      const storeLayers = $store.state.simulationSetup.gui.layers
+      for (let i = 0; i<layers.length; i++) {
+        if (isAlmostSame(storeLayers[i].layerWidth, layers[i].layerWidth)) {
+          layers[i].layerWidth = storeLayers[i].layerWidth
+        }
+      }
       $store.commit('simulationSetup/setLayers', layers)
     })
 

+ 61 - 43
guiapp/src/components/RunSimulationSpectrum.vue

@@ -6,8 +6,11 @@
                color="primary"
                no-caps
                :label="isNmieLoaded ? 'Run simulation' : 'Loading...'"
-               @click="runSpectrumSimulation"
-      />
+               @click="runSpectrumSimulation">
+          <template #loading>
+            <q-spinner-gears />
+          </template>
+        </q-btn>
     </div>
     <div class="col-xs-grow col-sm q-px-xs">
       <div class="row justify-xs-center justify-sm-start items-baseline">
@@ -23,10 +26,11 @@
 <script lang="ts">
 import {
   defineComponent,
-  computed,
-  } from 'vue'
+  computed, watch,
+} from 'vue'
 import { useStore } from 'src/store'
 import { range, rangeInt } from 'components/utils'
+import { cloneDeep } from 'lodash'
 
 export default defineComponent({
   name: 'RunSimulationSpectrum',
@@ -71,52 +75,66 @@ export default defineComponent({
     //---------------------  Main  --------------------------------------------//
     //-------------------------------------------------------------------------//
     function runSpectrumSimulation() {
+      if (isRunning.value) {
+        console.log('Some Nmie is already running!')
+        return
+      }
       isRunning.value = true
-      $store.commit('simulationSetup/copySetupFromGuiToCurrent')
-
-      const host = $store.state.simulationSetup.current.hostIndex
-      const WLs = getWLs()
-      const mode_n = rangeInt($store.state.simulationSetup.current.numberOfModesToPlot, 1);
-      const mode_types = range(0, 1);
-      let {Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n} = initQ(mode_n, mode_types)
-
-      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.SetWavelength(WL)
-
-          nmie.ClearTarget()
-          for (const layer of $store.state.simulationSetup.current.layers) {
-            if (layer.nSpline) layer.n = layer.nSpline.at(WL)
-            if (layer.kSpline) layer.k = layer.kSpline.at(WL)
-            nmie.AddTargetLayerReIm( layer.layerWidth*host, layer.n/host, layer.k/host )
-          }
+      setTimeout(()=> {
+
+        $store.commit('simulationSetup/copySetupFromGuiToCurrent')
+
+        const host = $store.state.simulationSetup.current.hostIndex
+        const WLs = getWLs()
+        const mode_n = rangeInt($store.state.simulationSetup.current.numberOfModesToPlot, 1);
+        const mode_types = range(0, 1);
+        let {Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n} = initQ(mode_n, mode_types)
+
+        try {
+          if (!$store.state.simulationSetup.nmie) throw 'ERROR! Scattnlay module was not loaded'
+          const nmie = $store.state.simulationSetup.nmie
+          const nmieStartedTime = performance.now()
+          const layers = cloneDeep($store.state.simulationSetup.current.layers)
+          for (const WL of WLs) {
+            nmie.SetWavelength(WL)
+
+            nmie.ClearTarget()
+            for (const layer of layers) {
+              if (layer.nSpline) layer.n = layer.nSpline.at(WL)
+              if (layer.kSpline) layer.k = layer.kSpline.at(WL)
+              nmie.AddTargetLayerReIm(layer.layerWidth * host, layer.n / host, layer.k / host)
+            }
 
-          nmie.SetModeNmaxAndType(-1, -1)
-          nmie.RunMieCalculation()
-          Qsca.push(nmie.GetQsca())
-          Qabs.push(nmie.GetQabs())
-          Qext.push(nmie.GetQext())
-
-          for (const mode_type of mode_types) {
-            for (const n of mode_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())
+            nmie.SetModeNmaxAndType(-1, -1)
+            nmie.RunMieCalculation()
+            Qsca.push(nmie.GetQsca())
+            Qabs.push(nmie.GetQabs())
+            Qext.push(nmie.GetQext())
+
+            for (const mode_type of mode_types) {
+              for (const n of mode_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())
+              }
             }
           }
-        }
-        isRunning.value = false
-        $store.commit('plotRuntime/setQ', {WLs, Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n})
+          const nmieTotalRunTime = (performance.now()-nmieStartedTime)/1000
+          $store.commit('simulationSetup/setNmieTotalRunTime', nmieTotalRunTime)
+          $store.commit('plotRuntime/setQ', {WLs, Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n})
         } catch (e) {
           console.log(e)
         }
-        // isRunning.value = false
-      }
+        isRunning.value = false
+      },50)
+    }
+
+    watch(isNmieLoaded, ()=>{
+      if (isNmieLoaded.value) runSpectrumSimulation()
+    })
+
     return { isRunning, isNmieLoaded,
       runSpectrumSimulation
     }

+ 7 - 14
guiapp/src/store/plot-runtime/mutations.ts

@@ -4,20 +4,13 @@ import {cloneDeep} from 'lodash'
 
 const mutation: MutationTree<plotRuntimeStateInterface> = {
   setQ (state: plotRuntimeStateInterface, val: spectraData) {
-    state.WLs    = (val.WLs)
-    state.Qsca   = (val.Qsca)
-    state.Qabs   = (val.Qabs)
-    state.Qext   = (val.Qext)
-    state.Qsca_n = (val.Qsca_n)
-    state.Qabs_n = (val.Qabs_n)
-    state.Qext_n = (val.Qext_n)
-    // state.WLs    = cloneDeep(val.WLs)
-    // state.Qsca   = cloneDeep(val.Qsca)
-    // state.Qabs   = cloneDeep(val.Qabs)
-    // state.Qext   = cloneDeep(val.Qext)
-    // state.Qsca_n = cloneDeep(val.Qsca_n)
-    // state.Qabs_n = cloneDeep(val.Qabs_n)
-    // state.Qext_n = cloneDeep(val.Qext_n)
+    state.WLs    = cloneDeep(val.WLs)
+    state.Qsca   = cloneDeep(val.Qsca)
+    state.Qabs   = cloneDeep(val.Qabs)
+    state.Qext   = cloneDeep(val.Qext)
+    state.Qsca_n = cloneDeep(val.Qsca_n)
+    state.Qabs_n = cloneDeep(val.Qabs_n)
+    state.Qext_n = cloneDeep(val.Qext_n)
   }
 }
 

+ 4 - 9
guiapp/src/store/simulation-setup/actions.ts

@@ -6,15 +6,10 @@ import nmiejs from 'src/nmiejs.js';
 
 const actions: ActionTree<simulationSetupStateInterface, StateInterface> = {
   async loadScattnlay ({commit,state}/* context */) {
-    // Test nmiejs if working
     const module = await nmiejs()
     const nmie = new module.nmie()
     commit('setNmie', nmie)
-    if (state.nmie) {
-      // setTimeout(()=>{
-      commit('markNmieAsLoaded')
-      // },3000)
-    }
+    // Test nmiejs if working
     if (state.nmie && !state.isNmieRunning) {
       commit('markNmieAsStarted')
       state.nmie.ClearTarget()
@@ -33,11 +28,11 @@ const actions: ActionTree<simulationSetupStateInterface, StateInterface> = {
           0.1, 1.5, 0, 3.1415, 0, 3.1415,
           0)
       console.log('Field Eabs:', state.nmie.GetFieldEabs())
-      // setTimeout(()=>{
       commit('markNmieAsFinished')
-      // },3000)
     }
-
+    if (state.nmie) {
+      commit('markNmieAsLoaded')
+    }
   }
 };
 

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

@@ -11,12 +11,11 @@ const mutation: MutationTree<sssi> = {
   markNmieAsLoaded  (state: sssi) {state.isNmieLoaded  = true },
   markNmieAsStarted (state: sssi) {
     state.isNmieRunning = true
-    state.nmieStartedTime = performance.now()
   },
   markNmieAsFinished(state: sssi) {
     state.isNmieRunning = false
-    state.nmieTotalRunTime = (performance.now()-state.nmieStartedTime)/1000
   },
+  setNmieTotalRunTime(state: sssi, val:number) {state.nmieTotalRunTime = val},
 
   setCurrentState (state: sssi,
                    newVal: simulationSetup) {

+ 1 - 3
guiapp/src/store/simulation-setup/state.ts

@@ -24,7 +24,6 @@ export interface simulationSetupStateInterface {
   nmie: import('src/nmiejs').nmie_class|undefined
   isNmieLoaded: boolean
   isNmieRunning: boolean
-  nmieStartedTime: number
   nmieTotalRunTime: number
 }
 
@@ -55,7 +54,6 @@ function state(): simulationSetupStateInterface {
   const nmie = undefined
   const isNmieLoaded = false
   const isNmieRunning = false
-  const nmieStartedTime = 0
   const nmieTotalRunTime = 0
 
   return {
@@ -63,7 +61,7 @@ function state(): simulationSetupStateInterface {
     gui, // simulation setup config as shown in GUI
     current, // simulation setup used for the latest simulation
     nmie,
-    isNmieLoaded, isNmieRunning, nmieStartedTime, nmieTotalRunTime
+    isNmieLoaded, isNmieRunning, nmieTotalRunTime
   }
 };