Konstantin Ladutenko 3 years ago
parent
commit
833b69e518

+ 256 - 95
Makefile

@@ -1,97 +1,258 @@
-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 -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/
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.16
 
+# 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:
-	$(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
+	$(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
+

+ 2 - 2
guiapp/src/components/GetHostIndex.vue

@@ -39,8 +39,8 @@ export default defineComponent({
     const $store = useStore()
 
     const isShowingHelpForInputWithUnits = computed({
-      get: () => $store.state.plotRuntime.isShowingHelpForInputWithUnits,
-      set: val => $store.commit('plotRuntime/setIsShowingHelpForInputWithUnits', val)
+      get: () => $store.state.guiRuntime.isShowingHelpForInputWithUnits,
+      set: val => $store.commit('guiRuntime/setIsShowingHelpForInputWithUnits', val)
     })
 
     const hostIndex = computed({

+ 2 - 2
guiapp/src/components/GetParticleParameters.vue

@@ -127,8 +127,8 @@ export default defineComponent({
     const numberOfLayers=ref(1)
 
     const isShowingHelpForInputWithUnits = computed({
-      get: () => $store.state.plotRuntime.isShowingHelpForInputWithUnits,
-      set: val => $store.commit('plotRuntime/setIsShowingHelpForInputWithUnits', val)
+      get: () => $store.state.guiRuntime.isShowingHelpForInputWithUnits,
+      set: val => $store.commit('guiRuntime/setIsShowingHelpForInputWithUnits', val)
     })
 
     const units = computed({

+ 3 - 8
guiapp/src/components/GetSourceParameters.vue

@@ -44,7 +44,7 @@ import {
   } from 'vue'
 import { useStore } from 'src/store'
 import InputWithUnits from 'components/InputWithUnits.vue'
-import { flexRowTitleStyle, fromUnits, toUnits } from 'components/utils'
+import { flexRowTitleStyle, fromUnits, toUnits, isAlmostSame } from 'components/utils'
 
 export default defineComponent({
 
@@ -57,19 +57,14 @@ export default defineComponent({
     const $store = useStore()
 
     const isShowingHelpForInputWithUnits = computed({
-      get: () => $store.state.plotRuntime.isShowingHelpForInputWithUnits,
-      set: val => $store.commit('plotRuntime/setIsShowingHelpForInputWithUnits', val)
+      get: () => $store.state.guiRuntime.isShowingHelpForInputWithUnits,
+      set: val => $store.commit('guiRuntime/setIsShowingHelpForInputWithUnits', val)
     })
 
     const sourceUnits = computed(()=>{
       return $store.state.guiRuntime.sourceUnits
     })
 
-    function isAlmostSame(a:number,b:number) {
-      if ( Math.abs((a-b)/(a+b)) < 1e-15) return true
-      return false
-    }
-
     const fromWavelengthInSourceUnits = computed({
       get: () => toUnits($store.state.simulationSetup.gui.fromWL, sourceUnits.value),
       set: val => {

+ 67 - 62
guiapp/src/components/RunSimulationSpectrum.vue

@@ -23,7 +23,6 @@
 <script lang="ts">
 import {
   defineComponent,
-  ref,
   computed,
   } from 'vue'
 import { useStore } from 'src/store'
@@ -44,73 +43,79 @@ export default defineComponent({
 
     const isNmieLoaded = computed(()=>{ return $store.state.simulationSetup.isNmieLoaded })
 
-      //-----------------------------------------------------------------------//
-      //-------------------  Main  --------------------------------------------//
-      //-----------------------------------------------------------------------//
-    function runSpectrumSimulation() {
-        isRunning.value = true
-        $store.commit('simulationSetup/copySetupFromGuiToCurrent')
-
-        const host = $store.state.simulationSetup.current.hostIndex
-
-        const fromWL = $store.state.simulationSetup.current.fromWL
-        const toWL = $store.state.simulationSetup.current.toWL
-        const pointsWL = $store.state.simulationSetup.current.pointsWL
-        const stepWL = (toWL-fromWL)/(pointsWL-1)
-        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([])
-          })
+    function getWLs(){
+      const fromWL = $store.state.simulationSetup.current.fromWL
+      const toWL = $store.state.simulationSetup.current.toWL
+      const pointsWL = $store.state.simulationSetup.current.pointsWL
+      const stepWL = (toWL-fromWL)/(pointsWL-1)
+      const WLs = range(fromWL, toWL, stepWL);
+      return WLs
+    }
+
+    function initQ(mode_n:number[], mode_types:number[]) {
+      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());
-              });
-            });
+      })
+      return {Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n}
+    }
+
+    //-------------------------------------------------------------------------//
+    //---------------------  Main  --------------------------------------------//
+    //-------------------------------------------------------------------------//
+    function runSpectrumSimulation() {
+      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 )
+          }
+
+          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})
         } catch (e) {
           console.log(e)
         }
-        console.log(Qsca)
-        isRunning.value = false
+        // isRunning.value = false
       }
     return { isRunning, isNmieLoaded,
       runSpectrumSimulation

+ 5 - 0
guiapp/src/components/utils.ts

@@ -1,5 +1,10 @@
 export const flexRowTitleStyle='width:10em; margin: auto;'
 
+export function isAlmostSame(a:number,b:number) {
+    if ( Math.abs((a-b)/(a+b)) < 1e-15) return true
+    return false
+}
+
 export function range(start:number, stop:number, step = 1) {
     return Array(Math.round(((stop - start) / step)+1)).fill(start).map((x:number, y:number) => x + y * step)
 }

+ 1 - 1
guiapp/src/pages/Spectrum.vue

@@ -13,7 +13,7 @@
     <div class="q-ma-xs"/>
     <RunSimulationSpectrum/>
     <div class="col-auto q-pa-md">
-      Input result: {{$store.state.simulationSetup.gui.numberOfModesToPlot}}
+      Input result: {{$store.state.plotRuntime.Qsca}}
     </div>
   </q-page>
 </template>

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

@@ -1,11 +1,24 @@
-import { MutationTree } from 'vuex';
-import { plotRuntimeStateInterface } from './state';
+import { MutationTree } from 'vuex'
+import { plotRuntimeStateInterface, spectraData } from './state'
+import {cloneDeep} from 'lodash'
 
 const mutation: MutationTree<plotRuntimeStateInterface> = {
-  setIsShowingHelpForInputWithUnits (state: plotRuntimeStateInterface, newVal: boolean) {
-    // your code
-    state.isShowingHelpForInputWithUnits = newVal
+  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)
   }
-};
+}
 
-export default mutation;
+export default mutation

+ 26 - 5
guiapp/src/store/plot-runtime/state.ts

@@ -1,11 +1,32 @@
+export interface spectraData {
+  WLs: number[]
+  Qsca:number[]
+  Qabs:number[]
+  Qext:number[]
+  Qsca_n:number[][][]
+  Qabs_n:number[][][]
+  Qext_n:number[][][]
+}
+
 export interface plotRuntimeStateInterface {
-  isShowingHelpForInputWithUnits: boolean;
+  WLs: number[]
+  Qsca:number[]
+  Qabs:number[]
+  Qext:number[]
+  Qsca_n:number[][][]
+  Qabs_n:number[][][]
+  Qext_n:number[][][]
 }
 
 function state(): plotRuntimeStateInterface {
-  return {
-    isShowingHelpForInputWithUnits: true
+  const WLs:number[] = []
+  const Qsca:number[] = [], Qabs:number[] = [], Qext:number[] = []
+  const Qsca_n:number[][][] = [[], []]
+  const Qabs_n:number[][][] = [[], []]
+  const Qext_n:number[][][] = [[], []]
+  return { WLs,
+    Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n
   }
-};
+}
 
-export default state;
+export default state

+ 4 - 0
tests/test_bulk_sphere.cc

@@ -48,6 +48,10 @@ TEST(BulkSphere, HandlesInput) {
           {1,     {10,  10},   2.532993, 2.049405, 'k'},
           {1000,  {0.75,0},     1.997908, 1.997908, 'd'},
           {100,   {10,  10,},  2.071124, 1.836785, 'l'},
+          {10000, {1.33,1e-5}, 2.004089, 1.723857, 'f'},
+          {10000, {1.5, 1},    2.004368, 1.236574, 'j'},
+//          {10000, {10,  10},   2.005914, 1.791, 'm'},
+          {10000, {10,  10},   2.005914, 1.795393, 'm'},
 #ifndef MULTI_PRECISION
           {10000, {1.33,1e-5}, 2.004089, 1.723857, 'f'},
           {10000, {1.5, 1},    2.004368, 1.236574, 'j'},

+ 4 - 0
tests/test_cases.hpp

@@ -21,6 +21,10 @@ parameters_bulk_sphere
 {100,   {1.5, 1}, "Hong Du testcase:i"},
 {1,     {10,  10},   "Hong Du testcase:k"},
 {1000,  {0.75,0}, "Hong Du testcase:d"},
+//{10000, {1.33,1e-5}, "Hong Du testcase:f"}, // passes but takes too long
+//{100,   {10,  10,},  "Hong Du testcase:l"}, // fails in any precision
+//{10000, {1.5, 1},    "Hong Du testcase:j"},
+//{10000, {10,  10},   "Hong Du testcase:m"},
 #ifdef MULTI_PRECISION
 //{10000, {1.33,1e-5}, "Hong Du testcase:f"}, // passes but takes too long
 //{100,   {10,  10,},  "Hong Du testcase:l"}, // fails in any precision