Browse Source

add usage info to near field warning message

Konstantin Ladutenko 3 years ago
parent
commit
8a5152add7

+ 2 - 33
guiapp/src/components/GetWlFromPlot.vue

@@ -32,22 +32,18 @@
 <script lang="ts">
 <script lang="ts">
 import ReactiveChart from 'components/ReactiveChart.vue'
 import ReactiveChart from 'components/ReactiveChart.vue'
 import { useStore } from 'src/store'
 import { useStore } from 'src/store'
-import { useRouter } from 'vue-router'
 import {
 import {
   defineComponent,
   defineComponent,
   computed,
   computed,
-    onActivated
+    // onActivated,
   // watch,
   // watch,
   //   ref,
   //   ref,
 } from 'vue'
 } from 'vue'
 import { fromUnits, toUnits } from 'components/utils'
 import { fromUnits, toUnits } from 'components/utils'
 import InputWithUnits from 'components/InputWithUnits.vue'
 import InputWithUnits from 'components/InputWithUnits.vue'
 import { flexRowTitleStyle } from 'components/config'
 import { flexRowTitleStyle } from 'components/config'
-
 import { PlotlyHTMLElement } from 'plotly.js-dist-min'
 import { PlotlyHTMLElement } from 'plotly.js-dist-min'
 import { cloneDeep } from 'lodash'
 import { cloneDeep } from 'lodash'
-import { useQuasar } from 'quasar'
-
 
 
 export default defineComponent({
 export default defineComponent({
   name: 'GetWlFromPlot',
   name: 'GetWlFromPlot',
@@ -55,32 +51,6 @@ export default defineComponent({
     ReactiveChart, InputWithUnits
     ReactiveChart, InputWithUnits
   },
   },
   setup () {
   setup () {
-    const $q = useQuasar()
-    const router = useRouter()
-
-    let count = 0
-    onActivated(()=>{
-      if (count < 2) {
-        $q.notify({
-          message: 'Near-field simulation uses settings from spectrum simulation.',
-          multiLine: true,
-          position: 'top-right',
-          icon: 'o_info',
-          progress: true,
-          color: 'white',
-          textColor: 'black',
-          actions: [
-            { icon: 'settings', label: 'Change spectrum settings', color: 'primary',
-              handler: () => { void router.push({path: '/spectrum'}) } },
-            { icon: 'close', label: 'Close', color: 'primary'},
-
-          ],
-          timeout: 10000
-        })
-        count += 1
-      }
-    })
-
     const $store = useStore()
     const $store = useStore()
 
 
     const sourceUnits = computed( ()=>$store.state.guiRuntime.sourceUnits)
     const sourceUnits = computed( ()=>$store.state.guiRuntime.sourceUnits)
@@ -124,8 +94,7 @@ export default defineComponent({
     }
     }
     return {currentWavelengthInSourceUnits, sourceUnits,
     return {currentWavelengthInSourceUnits, sourceUnits,
       chartContent, flexRowTitleStyle, isShowingHelpForInputWithUnits,
       chartContent, flexRowTitleStyle, isShowingHelpForInputWithUnits,
-      mangeID
-
+      mangeID,
     }
     }
   }
   }
 })
 })

+ 17 - 17
guiapp/src/components/RunSimulationNearField.vue

@@ -19,24 +19,24 @@
           </template>
           </template>
         </q-btn>
         </q-btn>
     </div>
     </div>
-    <div class="col-xs-grow col-sm q-px-xs">
-      <div class="row justify-xs-center justify-sm-start items-baseline">
-
-        <div class="col-auto">
-          <q-btn
-              color="primary"
-              no-caps
-              @click="saveSpectrumSimulation"
-          >Save</q-btn>
-        </div>
-
-      </div>
-    </div>
+<!--    <div class="col-xs-grow col-sm q-px-xs">-->
+<!--      <div class="row justify-xs-center justify-sm-start items-baseline">-->
+
+<!--        <div class="col-auto">-->
+<!--          <q-btn-->
+<!--              color="primary"-->
+<!--              no-caps-->
+<!--              @click="saveSpectrumSimulation"-->
+<!--          >Save</q-btn>-->
+<!--        </div>-->
+
+<!--      </div>-->
+<!--    </div>-->
   </div>
   </div>
 </template>
 </template>
 
 
 <script lang="ts">
 <script lang="ts">
-import {computed, defineComponent, nextTick, watch} from 'vue'
+import {computed, defineComponent, nextTick} 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'
 import {cloneDeep} from 'lodash'
 import {cloneDeep} from 'lodash'
@@ -119,9 +119,9 @@ export default defineComponent({
     }
     }
 
 
     runNearFieldSimulation()
     runNearFieldSimulation()
-    watch(isRunning, ()=>{
-          console.log(isRunning.value)
-    })
+    // watch(isRunning, ()=>{
+    //       console.log(isRunning.value)
+    // })
 
 
     // onActivated(()=>{
     // onActivated(()=>{
     //   if (isNmieLoaded.value) runNearFieldSimulation()
     //   if (isNmieLoaded.value) runNearFieldSimulation()

+ 65 - 0
guiapp/src/components/ShowNearFieldWarning.vue

@@ -0,0 +1,65 @@
+<template>
+  <div>
+    <q-card v-if="showWarning">
+      <div class="q-pa-sm">
+      <div class="text-h6 q-ml-sm text-warning"><q-icon name="warning"/> Warning</div>
+      <div class="q-ma-sm">Near-field evaluation is an experimental feature. In general, it provides a correct result. However, it is not as tested as spectrum computations, especially for the case of large, multilayer, and absorbing spheres. Please, verify the result before using it.</div>
+      <div class="q-ma-xs"/>
+      <div class="q-ml-sm text-h6"><q-icon size='sm' name="o_info"/> Usage</div>
+      <div class="q-ma-sm">Near-field simulation uses settings from spectrum simulation.</div>
+              <q-separator inset/>
+        <div class="q-ma-sm"/>
+        <q-btn icon="settings" flat text-color="primary"
+               label="Change spectrum settings"
+               @click="void router.push({path: '/spectrum'})"/>
+      <q-btn icon="close" flat text-color="primary"
+               label="Close"
+               @click="showWarning=false"/>
+      </div>
+    </q-card>
+    <div class="q-ma-md"/>
+  </div>
+</template>
+
+<script lang="ts">
+import { useRouter } from 'vue-router'
+import {
+  defineComponent,
+  ref,
+} from 'vue'
+
+export default defineComponent({
+  name: 'ShowNearFieldWarning',
+  setup () {
+    const router = useRouter()
+    let showWarning = ref(true)
+
+    // import { useQuasar } from 'quasar'
+    // const $q = useQuasar()
+    // onActivated(()=>{
+    //   if (count.value < 2) {
+    //     $q.notify({
+    //       message: 'Near-field simulation uses settings from spectrum simulation.',
+    //       multiLine: true,
+    //       position: 'top-right',
+    //       icon: 'o_info',
+    //       progress: true,
+    //       color: 'white',
+    //       textColor: 'black',
+    //       actions: [
+    //         { icon: 'settings', label: 'Change spectrum settings', color: 'primary',
+    //           handler: () => { void router.push({path: '/spectrum'}) } },
+    //         { icon: 'close', label: 'Close', color: 'primary'},
+    //
+    //       ],
+    //       timeout: 10000
+    //     })
+    //     count.value += 1
+    //   }
+    // })
+    //
+
+    return { showWarning, router }
+  }
+})
+</script>

+ 3 - 0
guiapp/src/pages/Near-field.vue

@@ -1,6 +1,7 @@
 <template>
 <template>
   <q-page class="column q-px-md">
   <q-page class="column q-px-md">
     <div class="q-ma-md"/>
     <div class="q-ma-md"/>
+    <ShowNearFieldWarning/>
     <RunSimulationSpectrum v-show="false"/>
     <RunSimulationSpectrum v-show="false"/>
     <GetWlFromPlot/>
     <GetWlFromPlot/>
     <div class="q-ma-xs"/>
     <div class="q-ma-xs"/>
@@ -30,6 +31,7 @@ import GetNearFieldSettings from 'components/GetNearFieldSettings.vue'
 import RunSimulationSpectrum from 'components/RunSimulationSpectrum.vue'
 import RunSimulationSpectrum from 'components/RunSimulationSpectrum.vue'
 import RunSimulationNearField from 'components/RunSimulationNearField.vue'
 import RunSimulationNearField from 'components/RunSimulationNearField.vue'
 import PlotNearField from 'components/PlotNearField.vue'
 import PlotNearField from 'components/PlotNearField.vue'
+import ShowNearFieldWarning from 'components/ShowNearFieldWarning.vue'
 
 
 // import { useStore } from 'src/store'
 // import { useStore } from 'src/store'
 
 
@@ -37,6 +39,7 @@ import PlotNearField from 'components/PlotNearField.vue'
 export default defineComponent({
 export default defineComponent({
   name: 'NearField',
   name: 'NearField',
   components: {
   components: {
+    ShowNearFieldWarning,
     PlotNearField,
     PlotNearField,
     RunSimulationNearField,
     RunSimulationNearField,
     GetWlFromPlot, RunSimulationSpectrum,
     GetWlFromPlot, RunSimulationSpectrum,

+ 9 - 4
src/nmie-nearfield.hpp

@@ -84,7 +84,7 @@ namespace nmie {
     isExpCoeffsCalc_ = false;
     isExpCoeffsCalc_ = false;
     aln_.clear(); bln_.clear(); cln_.clear(); dln_.clear();
     aln_.clear(); bln_.clear(); cln_.clear(); dln_.clear();
 
 
-    std::complex<FloatType> /*c_one(1.0, 0.0),*/ c_zero(0.0, 0.0);
+    std::complex<FloatType> c_one(1.0, 0.0), c_zero(0.0, 0.0);
 
 
     const int L = refractive_index_.size();
     const int L = refractive_index_.size();
 
 
@@ -104,8 +104,8 @@ namespace nmie {
     for (int n = 0; n < nmax_; n++) {
     for (int n = 0; n < nmax_; n++) {
       aln_[L][n] = an_[n];
       aln_[L][n] = an_[n];
       bln_[L][n] = bn_[n];
       bln_[L][n] = bn_[n];
-      cln_[L][n] = c_zero;
-      dln_[L][n] = c_zero;
+      cln_[L][n] = c_one;
+      dln_[L][n] = c_one;
     }
     }
 
 
     std::vector<std::complex<FloatType> > D1z(nmax_ + 1), D1z1(nmax_ + 1), D3z(nmax_ + 1), D3z1(nmax_ + 1);
     std::vector<std::complex<FloatType> > D1z(nmax_ + 1), D1z1(nmax_ + 1), D3z(nmax_ + 1), D3z1(nmax_ + 1);
@@ -269,6 +269,12 @@ namespace nmie {
       H[i] = c_zero;
       H[i] = c_zero;
     }
     }
 
 
+    const unsigned L = refractive_index_.size();
+    for (int n = 0; n < nmax_; n++) {
+      cln_[L][n] = c_zero;
+      dln_[L][n] = c_zero;
+    }
+
     unsigned int l;
     unsigned int l;
     GetIndexAtRadius(Rho, ml, l);
     GetIndexAtRadius(Rho, ml, l);
 
 
@@ -351,7 +357,6 @@ namespace nmie {
           ) break;
           ) break;
     }  // end of for all n
     }  // end of for all n
 
 
-    const unsigned L = refractive_index_.size();
     // Add the incident field
     // Add the incident field
     if(l==L) {
     if(l==L) {
 //      using nmm::sin_t;
 //      using nmm::sin_t;