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
               v-model="layer.material"
               :options="activatedMaterials"
-              :style="'width: '+basicWidthStyle"
+              :style="'min-width: '+basicWidthStyle"
               class="q-px-xs"
               dense
               options-dense
               outlined
               options-value="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">
               <span v-if="scope.opt.name =='link'">
                 <q-item clickable dense
@@ -169,6 +192,10 @@ export default defineComponent({
   setup() {
     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 particleType=ref('bulk')
     if (numberOfLayers.value == 1) particleType.value='bulk'
@@ -215,15 +242,21 @@ export default defineComponent({
     watch(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++) {
             if (isAlmostSame(storeLayers[i].layerWidth, layers[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('guiRuntime/setSafeWL', {safeFromWL:safeFromWL, safeToWL:safeToWL})
         },
         { deep: true }
     )
@@ -272,6 +305,7 @@ export default defineComponent({
 
     return { flexRowTitleStyle, basicWidthStyle,
       basicSelectorWidthStyle, maxNumberOfLayers,
+      fromWavelengthStore, toWavelengthStore,
       particleType,
       numberOfLayers, layers, getLayerTitle, getTooltipText,
       units, toUnits, fromUnits, isShowingHelpForInputWithUnits,

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

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

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

@@ -27,10 +27,17 @@
             :props="props"
         >
           <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"
                    @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 auto-width>

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

@@ -1,6 +1,13 @@
 <template>
   <div class="row items-baseline">
     <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"
                :disable="isRunning||!isNmieLoaded"
                color="primary"
@@ -32,7 +39,8 @@
 import {
   defineComponent,
   computed, watch,
-    onActivated
+    onActivated,
+    nextTick
 } from 'vue'
 import { useStore } from 'src/store'
 import { getModeName, range, rangeInt} from 'components/utils'
@@ -56,9 +64,11 @@ export default defineComponent({
 
     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
       if (sourceUnits.value.endsWith('Hz') || sourceUnits.value.endsWith('eV')) {
         const fromF = 1./fromWL
@@ -98,12 +108,13 @@ export default defineComponent({
         return
       }
       isRunning.value = true
-      setTimeout(()=> {
-
+      void nextTick(()=> {
         $store.commit('simulationSetup/copySetupFromGuiToCurrent')
 
         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_types = range(0, 1);
         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)
         }
         isRunning.value = false
-      },200)
+      })
     }
 
     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
       it is correct, however, we do not provide any warranty.
       <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>.
       <br><br>
       If it was useful for your project, please, cite the following reference:
@@ -35,10 +35,10 @@
       </q-card-section>
       <q-card-section>
         <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>
       </q-card-section>
     </q-card>
@@ -50,9 +50,3 @@ export default {
   // name: 'PageName',
 }
 </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"/>
     <MaterialsSelector/>
     <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/>
     <div class="q-ma-xs"/>
     <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
 
   try {
-    console.log('Public path:', process.env.publicPath)
     const response = await fetch(process.env.publicPath+'refractiveindex.info-database/database/data/'+filename)
     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},
   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) {
     state.activatedMaterials.push(material)

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

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