Sfoglia il codice sorgente

final touches to near-field before deploy

Konstantin Ladutenko 3 anni fa
parent
commit
3943086734

+ 86 - 13
guiapp/src/components/nearfield/GetNearFieldSettings.vue

@@ -21,14 +21,57 @@
                 units=""
               />
             </div>
-            <div class="col-auto">
-              <q-checkbox v-model="isSquareNearField" size="sm">
-                square
-              </q-checkbox>
+          </div>
+        </div>
+      </div>
+      <div class="q-ma-xs" />
+      <div class="row justify-center items-center">
+        <div class="col-auto text-center q-py-xs q-pr-md">
+          <div :style="flexRowTitleStyle">ratio</div>
+        </div>
+        <div class="col-xs-grow col-sm">
+          <div class="row justify-xs-center justify-sm-start items-center">
+            <div class="q-gutter-md q-py-sm q-px-xs">
+              <q-radio
+                v-model="plotRatioLabel"
+                dense
+                size="sm"
+                :val="'any'"
+                label="any"
+              />
+              <q-radio
+                v-model="plotRatioLabel"
+                dense
+                size="sm"
+                :val="'fixed'"
+                label="fixed"
+              />
+              <q-radio
+                v-model="plotRatioLabel"
+                dense
+                size="sm"
+                :val="'1:1'"
+                label="1:1"
+              />
+              <q-radio
+                v-model="plotRatioLabel"
+                dense
+                size="sm"
+                :val="'3:2'"
+                label="3:2"
+              />
+              <q-radio
+                v-model="plotRatioLabel"
+                dense
+                size="sm"
+                :val="'2:1'"
+                label="2:1"
+              />
             </div>
           </div>
         </div>
       </div>
+
       <div class="row justify-center items-baseline">
         <div class="col-auto text-center q-py-xs q-pr-md">
           <div :style="flexRowTitleStyle">y-side resolution</div>
@@ -39,7 +82,7 @@
               v-model:input-result="plotYSideResolution"
               v-model:is-showing-help="isShowingHelpForInputWithUnits"
               :initial-expression="plotYSideResolution.toString()"
-              :is-info-mode="isSquareNearField"
+              :is-info-mode="isFixedRatioNearField"
               title="points"
               units=""
             />
@@ -101,7 +144,7 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, computed, watch } from 'vue';
+import { defineComponent, computed, watch, ref } from 'vue';
 import { useStore } from 'src/store';
 import InputWithUnits from 'components/InputWithUnits.vue';
 import { flexRowTitleStyle } from 'components/config';
@@ -133,9 +176,9 @@ export default defineComponent({
         $store.commit('simulationSetup/setNearFieldRelativePlotSize', val),
     });
 
-    const isSquareNearField = computed({
-      get: () => $store.state.guiRuntime.isSquareNearField,
-      set: (val) => $store.commit('guiRuntime/setIsSquareNearField', val),
+    const isFixedRatioNearField = computed({
+      get: () => $store.state.guiRuntime.isFixedRatioNearField,
+      set: (val) => $store.commit('guiRuntime/setIsFixedRatioNearField', val),
     });
 
     // const maxComputeTime = computed({
@@ -164,15 +207,45 @@ export default defineComponent({
         ),
     });
 
-    watch([plotXSideResolution, isSquareNearField], () => {
-      if (isSquareNearField.value)
-        plotYSideResolution.value = plotXSideResolution.value;
+    const plotRatioLabel = ref('any');
+    const plotRatio = ref(1);
+
+    watch(plotRatioLabel, () => {
+      if (plotRatioLabel.value == 'any') isFixedRatioNearField.value = false;
+      else isFixedRatioNearField.value = true;
+    });
+    watch(isFixedRatioNearField, () => {
+      if (!isFixedRatioNearField.value) plotRatioLabel.value = 'any';
     });
 
+    watch(plotRatioLabel, () => {
+      switch (plotRatioLabel.value) {
+        case '1:1':
+          plotRatio.value = 1;
+          break;
+        case '3:2':
+          plotRatio.value = 2 / 3;
+          break;
+        case '2:1':
+          plotRatio.value = 1 / 2;
+          break;
+        case 'fixed':
+          plotRatio.value =
+            plotYSideResolution.value / plotXSideResolution.value;
+          break;
+        default:
+          break;
+      }
+    });
+    watch([plotXSideResolution, plotRatioLabel], () => {
+      if (isFixedRatioNearField.value)
+        plotYSideResolution.value = plotRatio.value * plotXSideResolution.value;
+    });
     return {
       crossSection,
+      plotRatioLabel,
       isShowingHelpForInputWithUnits,
-      isSquareNearField,
+      isFixedRatioNearField,
       flexRowTitleStyle,
       relativePlotSize,
       // maxComputeTime,

+ 4 - 4
guiapp/src/components/nearfield/PlotNearField.vue

@@ -162,10 +162,10 @@ export default defineComponent({
       nearFieldPlot.data.push({ ...xy.value, ...heatMapSettings });
 
       const isPlotShapes =
-        arrayMin(xy.value.x) < -totalR.value &&
-        arrayMax(xy.value.x) > totalR.value &&
-        arrayMin(xy.value.y) < -totalR.value &&
-        arrayMax(xy.value.y) > totalR.value;
+        arrayMin(xy.value.x) < -toUnits(totalR.value, units.value) &&
+        arrayMax(xy.value.x) > toUnits(totalR.value, units.value) &&
+        arrayMin(xy.value.y) < -toUnits(totalR.value, units.value) &&
+        arrayMax(xy.value.y) > toUnits(totalR.value, units.value);
 
       if (nearFieldPlot.layout.shapes) nearFieldPlot.layout.shapes.length = 0;
       if (nearFieldPlot.layout.shapes && isPlotShapes) {

+ 2 - 8
guiapp/src/components/nearfield/RunSimulationNearField.vue

@@ -47,7 +47,7 @@
         :disable="isRunning || !isNmieLoaded"
         color="primary"
         no-caps
-        :label="isNmieLoaded ? 'Refine on zoom' : 'Loading...'"
+        :label="isNmieLoaded ? 'Refine zoomed region' : 'Loading...'"
         @click="refineOnZoom"
       >
         <template #loading>
@@ -242,7 +242,7 @@ export default defineComponent({
 
     function refineOnZoom() {
       if (sideX.value == 0 || sideY.value == 0) return;
-      $store.commit('guiRuntime/setIsSquareNearField', false),
+      $store.commit('guiRuntime/setIsFixedRatioNearField', false),
         $store.commit(
           'simulationSetup/setNearFieldRelativePlotSize',
           sideX.value / 2.0
@@ -255,10 +255,6 @@ export default defineComponent({
         'simulationSetup/setNearFieldPlotYSideResolution',
         floor(Math.sqrt((totalPoints.value * sideY.value) / sideX.value))
       );
-      console.log(
-        floor(Math.sqrt((totalPoints.value * sideX.value) / sideY.value)),
-        floor(Math.sqrt((totalPoints.value * sideY.value) / sideX.value))
-      );
       if (crossSection.value == nearFieldPlane.Ek) {
         $store.commit('simulationSetup/setNearFieldAtRelativeZ0', atX.value);
         $store.commit('simulationSetup/setNearFieldAtRelativeX0', atY.value);
@@ -276,13 +272,11 @@ export default defineComponent({
 
     watch([atX, atY, sideX, sideY], () => {
       if (!isAutoRefineNearField.value) return;
-      console.log(nearFieldZoom.value);
       refineOnZoom();
     });
 
     let count = 0;
     watch([plotXSideResolutionGUI, plotYSideResolutionGUI], () => {
-      console.log(plotXSideResolutionGUI.value, plotYSideResolutionGUI.value);
       if (
         plotYSideResolutionGUI.value * plotXSideResolutionGUI.value >
           150 * 150 &&

+ 12 - 0
guiapp/src/components/spectrum/RunSimulationSpectrum.vue

@@ -37,6 +37,15 @@
             >Save</q-btn
           >
         </div>
+        <div class="col-auto q-px-md">
+          <q-btn
+            icon="arrow_forward"
+            flat
+            text-color="primary"
+            label="near-field"
+            @click="void router.push({ path: '/nearfield' })"
+          />
+        </div>
       </div>
     </div>
   </div>
@@ -48,12 +57,14 @@ import { useStore } from 'src/store';
 import { getModeName, range, rangeInt } from 'components/utils';
 import { cloneDeep } from 'lodash';
 import { saveAs } from 'file-saver';
+import { useRouter } from 'vue-router';
 
 export default defineComponent({
   name: 'RunSimulationSpectrum',
 
   setup() {
     const $store = useStore();
+    const router = useRouter();
 
     const isRunning = computed({
       get: () => $store.state.simulationSetup.nmies.spectrum.isNmieRunning,
@@ -233,6 +244,7 @@ export default defineComponent({
     });
 
     return {
+      router,
       isRunning,
       isNmieLoaded,
       runSpectrumSimulation,

+ 2 - 2
guiapp/src/store/gui-runtime/mutations.ts

@@ -15,8 +15,8 @@ function compare(a: material, b: material) {
 }
 
 const mutation: MutationTree<grsi> = {
-  setIsSquareNearField(state: grsi, val: boolean) {
-    state.isSquareNearField = val;
+  setIsFixedRatioNearField(state: grsi, val: boolean) {
+    state.isFixedRatioNearField = val;
   },
   setIsSaveWithPythonScript(state: grsi, val: boolean) {
     state.isSaveWithPythonScript = val;

+ 2 - 2
guiapp/src/store/gui-runtime/state.ts

@@ -12,7 +12,7 @@ export interface guiRuntimeStateInterface {
   safeToWL: number;
   isSaveWithPythonScript: boolean;
   isAutoRefineNearField: boolean;
-  isSquareNearField: boolean;
+  isFixedRatioNearField: boolean;
   nearFieldZoom: { fromX: number; toX: number; fromY: number; toY: number };
 }
 
@@ -27,7 +27,7 @@ function state(): guiRuntimeStateInterface {
     isSaveWithPythonScript: true,
     nearFieldZoom: { fromX: 0, toX: 1, fromY: 0, toY: 1 },
     isAutoRefineNearField: true,
-    isSquareNearField: true,
+    isFixedRatioNearField: true,
     activatedMaterials: [
       // 'PEC',
       {

+ 3 - 0
guiapp/src/store/simulation-setup/mutations.ts

@@ -92,12 +92,15 @@ const mutation: MutationTree<sssi> = {
     state.gui.nearFieldSetup.relativePlotSize = val;
   },
   setNearFieldAtRelativeX0(state: sssi, val: number) {
+    if (val < 1e-15) val = 0;
     state.gui.nearFieldSetup.atRelativeX0 = val;
   },
   setNearFieldAtRelativeY0(state: sssi, val: number) {
+    if (val < 1e-15) val = 0;
     state.gui.nearFieldSetup.atRelativeY0 = val;
   },
   setNearFieldAtRelativeZ0(state: sssi, val: number) {
+    if (val < 1e-15) val = 0;
     state.gui.nearFieldSetup.atRelativeZ0 = val;
   },
   setNearFieldPlotXSideResolution(state: sssi, val: number) {