Browse Source

introduce safeWL range for simulation and user warnings

Konstantin Ladutenko 3 years ago
parent
commit
4b7a9b13b1

+ 39 - 5
guiapp/src/components/GetParticleParameters.vue

@@ -73,15 +73,38 @@
           <q-select
           <q-select
               v-model="layer.material"
               v-model="layer.material"
               :options="activatedMaterials"
               :options="activatedMaterials"
-              :style="'width: '+basicWidthStyle"
+              :style="'min-width: '+basicWidthStyle"
               class="q-px-xs"
               class="q-px-xs"
               dense
               dense
               options-dense
               options-dense
               outlined
               outlined
               options-value="name"
               options-value="name"
               options-label="name"
               options-label="name"
-              :display-value="layer.material.name"
           >
           >
+            <template
+                v-if=" layer.material.spectrumRangeStart > fromWavelengthStore ||
+                       layer.material.spectrumRangeEnd   <   toWavelengthStore"
+                #after
+            >
+              <q-tooltip> Input conflict </q-tooltip>
+              <q-icon name="error" class="text-warning"/>
+            </template>
+
+            <template #selected>
+              <q-item dense class="q-pa-none" style="margin-top: -1px; margin-bottom: -1px;">
+                <q-item-section class="q-pa-none">
+                {{ layer.material.name }}
+                </q-item-section>
+                <q-item-section v-if="!(layer.material.name=='nk-constant' || layer.material.name=='PEC')" side>
+                  <ShowSpectrumRange
+                      class="text-caption"
+                      :spectrum-range-start="layer.material.spectrumRangeStart"
+                      :spectrum-range-end="layer.material.spectrumRangeEnd"
+                  />
+                </q-item-section>
+              </q-item>
+
+            </template>
             <template #option="scope">
             <template #option="scope">
               <span v-if="scope.opt.name =='link'">
               <span v-if="scope.opt.name =='link'">
                 <q-item clickable dense
                 <q-item clickable dense
@@ -169,6 +192,10 @@ export default defineComponent({
   setup() {
   setup() {
     const $store = useStore()
     const $store = useStore()
 
 
+    const fromWavelengthStore = computed(()=>$store.state.simulationSetup.gui.fromWL)
+    const toWavelengthStore = computed(()=>$store.state.simulationSetup.gui.toWL)
+
+
     const numberOfLayers=ref($store.state.simulationSetup.gui.layers.length)
     const numberOfLayers=ref($store.state.simulationSetup.gui.layers.length)
     const particleType=ref('bulk')
     const particleType=ref('bulk')
     if (numberOfLayers.value == 1) particleType.value='bulk'
     if (numberOfLayers.value == 1) particleType.value='bulk'
@@ -215,15 +242,21 @@ export default defineComponent({
     watch(layers,
     watch(layers,
         ()=>{
         ()=>{
           const storeLayers = $store.state.simulationSetup.gui.layers
           const storeLayers = $store.state.simulationSetup.gui.layers
+          let safeFromWL = 0
+          let safeToWL = 1e300
           for (let i = 0; i<layers.length && i<storeLayers.length; i++) {
           for (let i = 0; i<layers.length && i<storeLayers.length; i++) {
             if (isAlmostSame(storeLayers[i].layerWidth, layers[i].layerWidth)) {
             if (isAlmostSame(storeLayers[i].layerWidth, layers[i].layerWidth)) {
               layers[i].layerWidth = storeLayers[i].layerWidth
               layers[i].layerWidth = storeLayers[i].layerWidth
             }
             }
-            // if (layers[i].material.name == 'link') {
-            //   layers[i].material.name = storeLayers[i].material.name
-            // }
+            let layerFromWL = layers[i].material.spectrumRangeStart
+            let layerToWL = layers[i].material.spectrumRangeEnd
+            if (layerFromWL && layerFromWL > safeFromWL) safeFromWL = layerFromWL
+            if (layerToWL && layerToWL < safeToWL) safeToWL = layerToWL
+
+
           }
           }
           $store.commit('simulationSetup/setLayers', layers)
           $store.commit('simulationSetup/setLayers', layers)
+          $store.commit('guiRuntime/setSafeWL', {safeFromWL:safeFromWL, safeToWL:safeToWL})
         },
         },
         { deep: true }
         { deep: true }
     )
     )
@@ -272,6 +305,7 @@ export default defineComponent({
 
 
     return { flexRowTitleStyle, basicWidthStyle,
     return { flexRowTitleStyle, basicWidthStyle,
       basicSelectorWidthStyle, maxNumberOfLayers,
       basicSelectorWidthStyle, maxNumberOfLayers,
+      fromWavelengthStore, toWavelengthStore,
       particleType,
       particleType,
       numberOfLayers, layers, getLayerTitle, getTooltipText,
       numberOfLayers, layers, getLayerTitle, getTooltipText,
       units, toUnits, fromUnits, isShowingHelpForInputWithUnits,
       units, toUnits, fromUnits, isShowingHelpForInputWithUnits,

+ 2 - 0
guiapp/src/components/GetSourceParameters.vue

@@ -19,6 +19,7 @@
             :initial-expression="fromSource.toString()"
             :initial-expression="fromSource.toString()"
             :units="sourceUnits"
             :units="sourceUnits"
             :is-info-mode="isInfoMode"
             :is-info-mode="isInfoMode"
+            :is-error="fromSource<$store.state.guiRuntime.safeFromWL"
             title="from"
             title="from"
         /></div>
         /></div>
         <div class="col-auto"><input-with-units
         <div class="col-auto"><input-with-units
@@ -27,6 +28,7 @@
             :initial-expression="toSource.toString()"
             :initial-expression="toSource.toString()"
             :units="sourceUnits"
             :units="sourceUnits"
             :is-info-mode="isInfoMode"
             :is-info-mode="isInfoMode"
+            :is-error="toSource>$store.state.guiRuntime.safeToWL"
             title="to"
             title="to"
         /></div>
         /></div>
         <div v-if="!isInfoMode" class="col-auto">
         <div v-if="!isInfoMode" class="col-auto">

+ 9 - 2
guiapp/src/components/MaterialsActivated.vue

@@ -27,10 +27,17 @@
             :props="props"
             :props="props"
         >
         >
           <q-td auto-width>
           <q-td auto-width>
-            <q-tooltip anchor="top start" self="bottom start" >
-              Delete from simulation</q-tooltip>
+            <span v-if="!$store.state.simulationSetup.gui.layers.find(el=>el.material.name===props.row.name)">
+            <q-tooltip anchor="top middle" self="bottom middle" >
+              Delete</q-tooltip>
             <q-btn size="sm" padding="5px" color="primary" round dense icon="delete"
             <q-btn size="sm" padding="5px" color="primary" round dense icon="delete"
                    @click="deleteFromSimulation(props.row.name)"/>
                    @click="deleteFromSimulation(props.row.name)"/>
+            </span>
+            <span v-else >
+            <q-tooltip anchor="top start" self="bottom start" >
+              Used in spectrum simulation</q-tooltip>
+              <q-btn size="sm" padding="5px" text-color="primary" round dense flat icon="push_pin" to="/spectrum"/>
+            </span>
           </q-td>
           </q-td>
 
 
           <q-td auto-width>
           <q-td auto-width>

+ 19 - 8
guiapp/src/components/RunSimulationSpectrum.vue

@@ -1,6 +1,13 @@
 <template>
 <template>
   <div class="row items-baseline">
   <div class="row items-baseline">
     <div class="col-xs-12 col-sm-auto text-weight-bold text-center q-px-md q-py-sm">
     <div class="col-xs-12 col-sm-auto text-weight-bold text-center q-px-md q-py-sm">
+      <q-tooltip
+          v-if=" $store.state.guiRuntime.safeFromWL > $store.state.simulationSetup.gui.fromWL ||
+                 $store.state.guiRuntime.safeToWL < $store.state.simulationSetup.gui.toWL "
+          anchor="top middle" self="center middle"
+          class="bg-amber-4 text-black shadow-4">
+        Will use materials<br> spectrum range.
+      </q-tooltip>
         <q-btn :loading="isRunning"
         <q-btn :loading="isRunning"
                :disable="isRunning||!isNmieLoaded"
                :disable="isRunning||!isNmieLoaded"
                color="primary"
                color="primary"
@@ -32,7 +39,8 @@
 import {
 import {
   defineComponent,
   defineComponent,
   computed, watch,
   computed, watch,
-    onActivated
+    onActivated,
+    nextTick
 } from 'vue'
 } from 'vue'
 import { useStore } from 'src/store'
 import { useStore } from 'src/store'
 import { getModeName, range, rangeInt} from 'components/utils'
 import { getModeName, range, rangeInt} from 'components/utils'
@@ -56,9 +64,11 @@ export default defineComponent({
 
 
     const sourceUnits = computed( ()=>$store.state.guiRuntime.sourceUnits)
     const sourceUnits = computed( ()=>$store.state.guiRuntime.sourceUnits)
 
 
-    function getWLs(){
-      const fromWL = $store.state.simulationSetup.current.fromWL
-      const toWL = $store.state.simulationSetup.current.toWL
+    function getWLs(safeFromWL:number, safeToWL:number){
+      let fromWL = $store.state.simulationSetup.current.fromWL
+      let toWL = $store.state.simulationSetup.current.toWL
+      if (fromWL < safeFromWL) fromWL=safeFromWL
+      if (toWL > safeToWL) toWL=safeToWL
       const pointsWL = $store.state.simulationSetup.current.pointsWL
       const pointsWL = $store.state.simulationSetup.current.pointsWL
       if (sourceUnits.value.endsWith('Hz') || sourceUnits.value.endsWith('eV')) {
       if (sourceUnits.value.endsWith('Hz') || sourceUnits.value.endsWith('eV')) {
         const fromF = 1./fromWL
         const fromF = 1./fromWL
@@ -98,12 +108,13 @@ export default defineComponent({
         return
         return
       }
       }
       isRunning.value = true
       isRunning.value = true
-      setTimeout(()=> {
-
+      void nextTick(()=> {
         $store.commit('simulationSetup/copySetupFromGuiToCurrent')
         $store.commit('simulationSetup/copySetupFromGuiToCurrent')
 
 
         const host = $store.state.simulationSetup.current.hostIndex
         const host = $store.state.simulationSetup.current.hostIndex
-        const WLs = getWLs()
+        const safeFromWL = $store.state.guiRuntime.safeFromWL
+        const safeToWL = $store.state.guiRuntime.safeToWL
+        const WLs = getWLs(safeFromWL, safeToWL)
         const mode_n = rangeInt($store.state.simulationSetup.current.numberOfModesToPlot, 1);
         const mode_n = rangeInt($store.state.simulationSetup.current.numberOfModesToPlot, 1);
         const mode_types = range(0, 1);
         const mode_types = range(0, 1);
         let {Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n} = initQ(mode_n, mode_types)
         let {Qsca, Qabs, Qext, Qsca_n, Qabs_n, Qext_n} = initQ(mode_n, mode_types)
@@ -154,7 +165,7 @@ export default defineComponent({
           console.log(e)
           console.log(e)
         }
         }
         isRunning.value = false
         isRunning.value = false
-      },200)
+      })
     }
     }
 
 
     watch(isNmieLoaded, ()=>{
     watch(isNmieLoaded, ()=>{

+ 5 - 11
guiapp/src/pages/Info.vue

@@ -10,7 +10,7 @@
       Feel free to use provided software, however, use it at your own risk. We made our best effort to verify
       Feel free to use provided software, however, use it at your own risk. We made our best effort to verify
       it is correct, however, we do not provide any warranty.
       it is correct, however, we do not provide any warranty.
       <br><br> Report bugs, issues, and feature requests at project's
       <br><br> Report bugs, issues, and feature requests at project's
-      <a href="https://github.com/ovidiopr/scattnlay">GitHub</a>
+      <a href="https://github.com/ovidiopr/scattnlay">GitHub<q-icon name="launch" style="padding-left: 0.1rem; padding-bottom: 1rem" /></a>
       (preferred) or mail to <a href="mailto:k.ladutenko@metalab.ifmo.ru?subject=Mie calculator webapp (Scattnlay)">k.ladutenko@metalab.ifmo.ru</a>.
       (preferred) or mail to <a href="mailto:k.ladutenko@metalab.ifmo.ru?subject=Mie calculator webapp (Scattnlay)">k.ladutenko@metalab.ifmo.ru</a>.
       <br><br>
       <br><br>
       If it was useful for your project, please, cite the following reference:
       If it was useful for your project, please, cite the following reference:
@@ -35,10 +35,10 @@
       </q-card-section>
       </q-card-section>
       <q-card-section>
       <q-card-section>
         <ul>
         <ul>
-          <li><a href="https://nanocomposix.com/pages/mie-theory-calculator">Bulk or core-shell,</a>   only dipole and quadrupole contributions by Nanocomposix. </li>
-          <li><a href="https://de.ifmo.ru/miecalculator/">Bulk particles</a>   by Ivan Toftul.</li>
-          <li><a href="https://saviot.cnrs.fr/mie/index.en.html">Bulk</a> and <a href="https://saviot.cnrs.fr/miecoat/index.en.html">core-shell</a> calculators by Lucien Saviot.</li>
-          <li><a href="https://omlc.org/calc/mie_calc.html">Angle distribution</a>  by Scott Prahl.</li>
+          <li><a href="https://nanocomposix.com/pages/mie-theory-calculator">Bulk or core-shell<q-icon name="launch" style="padding-left: 0.1rem; padding-bottom: 1rem" />,</a>   only dipole and quadrupole contributions by Nanocomposix. </li>
+          <li><a href="https://de.ifmo.ru/miecalculator/">Bulk particles<q-icon name="launch" style="padding-left: 0.1rem; padding-bottom: 1rem" /></a>   by Ivan Toftul.</li>
+          <li><a href="https://saviot.cnrs.fr/mie/index.en.html">Bulk<q-icon name="launch" style="padding-left: 0.1rem; padding-bottom: 1rem" /></a> and <a href="https://saviot.cnrs.fr/miecoat/index.en.html">core-shell<q-icon name="launch" style="padding-left: 0.1rem; padding-bottom: 1rem" /></a> calculators by Lucien Saviot.</li>
+          <li><a href="https://omlc.org/calc/mie_calc.html">Angle distribution<q-icon name="launch" style="padding-left: 0.1rem; padding-bottom: 1rem" /></a>  by Scott Prahl.</li>
         </ul>
         </ul>
       </q-card-section>
       </q-card-section>
     </q-card>
     </q-card>
@@ -50,9 +50,3 @@ export default {
   // name: 'PageName',
   // name: 'PageName',
 }
 }
 </script>
 </script>
-<style lang="scss">
- a {
-   margin: 0.2rem;
-
- }
-</style>

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

@@ -3,7 +3,7 @@
     <div class="q-ma-sm"/>
     <div class="q-ma-sm"/>
     <MaterialsSelector/>
     <MaterialsSelector/>
     <div class="q-ma-xs"/>
     <div class="q-ma-xs"/>
-    <router-link to="/spectrum#GetSourceParametersHref"> <GetSourceParameters :is-info-mode="true"/> </router-link>
+    <router-link to="/spectrum"> <GetSourceParameters :is-info-mode="true"/> </router-link>
     <MaterialsActivated/>
     <MaterialsActivated/>
     <div class="q-ma-xs"/>
     <div class="q-ma-xs"/>
     <PlotMaterials/>
     <PlotMaterials/>

+ 0 - 1
guiapp/src/store/gui-runtime/actions.ts

@@ -14,7 +14,6 @@ async function loadMaterialData(filename:string):Promise<number[][] | undefined>
   let Ag_data
   let Ag_data
 
 
   try {
   try {
-    console.log('Public path:', process.env.publicPath)
     const response = await fetch(process.env.publicPath+'refractiveindex.info-database/database/data/'+filename)
     const response = await fetch(process.env.publicPath+'refractiveindex.info-database/database/data/'+filename)
     const Ag_data = await response.text()
     const Ag_data = await response.text()
 
 

+ 4 - 0
guiapp/src/store/gui-runtime/mutations.ts

@@ -19,6 +19,10 @@ const mutation: MutationTree<grsi> = {
   setSourceUnits       (state: grsi, val: string ) {state.sourceUnits       = val},
   setSourceUnits       (state: grsi, val: string ) {state.sourceUnits       = val},
   setIsSourceSameUnits (state: grsi, val: boolean) {state.isSourceSameUnits = val},
   setIsSourceSameUnits (state: grsi, val: boolean) {state.isSourceSameUnits = val},
 
 
+  setSafeWL            (state: grsi, val: {safeFromWL:number, safeToWL:number}) {
+    state.safeFromWL = val.safeFromWL
+    state.safeToWL = val.safeToWL
+  },
 
 
   addMaterial(state: grsi, material:material) {
   addMaterial(state: grsi, material:material) {
     state.activatedMaterials.push(material)
     state.activatedMaterials.push(material)

+ 4 - 0
guiapp/src/store/gui-runtime/state.ts

@@ -9,6 +9,8 @@ export interface guiRuntimeStateInterface {
   sourceUnits: string
   sourceUnits: string
   isSourceSameUnits: boolean
   isSourceSameUnits: boolean
   activatedMaterials: material[]
   activatedMaterials: material[]
+  safeFromWL:number
+  safeToWL:number
 }
 }
 
 
 function state(): guiRuntimeStateInterface {
 function state(): guiRuntimeStateInterface {
@@ -17,6 +19,8 @@ function state(): guiRuntimeStateInterface {
     units: 'nm',
     units: 'nm',
     sourceUnits: 'nm',
     sourceUnits: 'nm',
     isSourceSameUnits: true,
     isSourceSameUnits: true,
+    safeFromWL:0,
+    safeToWL:1e300,
     activatedMaterials: [
     activatedMaterials: [
         // 'PEC',
         // 'PEC',
       {name:'link',  spectrumRangeStart:0, spectrumRangeEnd:1e300,
       {name:'link',  spectrumRangeStart:0, spectrumRangeEnd:1e300,