Konstantin Ladutenko пре 5 година
родитељ
комит
2bcd5a2b03

+ 33 - 16
vue-cli3-webapp/src/App.vue

@@ -171,6 +171,7 @@
             height: 0
             height: 0
           },
           },
           units: 'nm',
           units: 'nm',
+          units_prev: 'nm',
           source_units: 'nm',
           source_units: 'nm',
           isSourceOtherUnits: false,
           isSourceOtherUnits: false,
           simulationSetup: {
           simulationSetup: {
@@ -297,12 +298,22 @@
             this.source_units = this.units;
             this.source_units = this.units;
           }
           }
           let u = this.units;
           let u = this.units;
-          let ru = this.simulationRuntime.r_units;
-          this.simulationSetup.layers[0].R = this.convertUnits(ru, u,this.simulationRuntime.layers[0].R);
+          let ru = this.units_prev;
+          let layers = this.simulationSetup.layers;
+          for (let i=0; i<layers.length; i++) {
+            layers[i].R = this.convertUnits(ru, u, layers[i].R);
+          }
+          this.units_prev = this.units;
         }
         }
       },
       },
       source_units: {
       source_units: {
         handler: function () {
         handler: function () {
+          this.$buefy.notification.open({
+            duration: 4000,
+            message: 'Source parameters were restored from last simulation for correct plotting.',
+            type: 'is-info',
+            position: 'is-top',
+          });
           this.setXaxisTitle();
           this.setXaxisTitle();
           let su = this.source_units;
           let su = this.source_units;
           let rsu = this.simulationRuntime.r_source_units;
           let rsu = this.simulationRuntime.r_source_units;
@@ -432,15 +443,12 @@
         this.simulationRuntime.fromWL = this.simulationSetup.fromWL;
         this.simulationRuntime.fromWL = this.simulationSetup.fromWL;
         this.simulationRuntime.toWL = this.simulationSetup.toWL;
         this.simulationRuntime.toWL = this.simulationSetup.toWL;
         this.simulationRuntime.stepWL = this.simulationSetup.stepWL;
         this.simulationRuntime.stepWL = this.simulationSetup.stepWL;
-        this.simulationRuntime.layers[0].R = this.simulationSetup.layers[0].R;
+        this.simulationRuntime.layers = JSON.parse(JSON.stringify(this.simulationSetup.layers));
 
 
         let t0 = performance.now();
         let t0 = performance.now();
         let fromWL = parseFloat(this.simulationSetup.fromWL);
         let fromWL = parseFloat(this.simulationSetup.fromWL);
         let toWL = parseFloat(this.simulationSetup.toWL);
         let toWL = parseFloat(this.simulationSetup.toWL);
         let stepWL = parseFloat(this.simulationSetup.stepWL);
         let stepWL = parseFloat(this.simulationSetup.stepWL);
-        let R = parseFloat(this.simulationSetup.layers[0].R);
-        let reN = parseFloat(this.simulationSetup.layers[0].reN);
-        let imN = parseFloat(this.simulationSetup.layers[0].imN);
         let host = parseFloat(this.simulationSetup.hostIndex);
         let host = parseFloat(this.simulationSetup.hostIndex);
 
 
 
 
@@ -465,15 +473,24 @@
 
 
         // Provide all sizes (germetry and wavelengths) to nmie in same units [nm]
         // Provide all sizes (germetry and wavelengths) to nmie in same units [nm]
         const nmie = this.nmie;
         const nmie = this.nmie;
-        nmie.ClearTarget();
-        nmie.AddTargetLayerReIm( this.convertUnits2nm(this.units, R)*host,
-                reN/host, imN/host);
+        // nmie.ClearTarget();
+        // nmie.AddTargetLayerReIm( this.convertUnits2nm(this.units, R)*host,
+        //         reN/host, imN/host);
         let WLs_nm = range(fromWL, toWL, stepWL);
         let WLs_nm = range(fromWL, toWL, stepWL);
-        var WL_points = WLs_nm.length;
-        for (var i = 0; i < WL_points; i++) {
-          WLs_nm[i] = this.convertUnits2nm(this.source_units, WLs[i]);
-        }
-        WLs_nm.forEach(function (WL) {
+        let WL_points = WLs_nm.length;
+        for (let i = 0; i < WL_points; i++) {
+          let WL = this.convertUnits2nm(this.source_units, WLs[i]);
+          nmie.ClearTarget();
+          for (let num_layer = 0;
+               num_layer < this.simulationRuntime.layers.length; 
+               num_layer++) {
+            let R = parseFloat(this.simulationRuntime.layers[num_layer].R);
+            let reN = parseFloat(this.simulationRuntime.layers[num_layer].reN);
+            let imN = parseFloat(this.simulationRuntime.layers[num_layer].imN);
+            nmie.AddTargetLayerReIm( this.convertUnits2nm(this.units, R)*host,
+                    reN/host, imN/host);
+            
+          }
           nmie.SetModeNmaxAndType(-1, -1);
           nmie.SetModeNmaxAndType(-1, -1);
           nmie.SetWavelength(WL);
           nmie.SetWavelength(WL);
           nmie.RunMieCalculation();
           nmie.RunMieCalculation();
@@ -486,8 +503,8 @@
               Qsca_n[mode_type][n - 1].push(nmie.GetQsca());
               Qsca_n[mode_type][n - 1].push(nmie.GetQsca());
               Qabs_n[mode_type][n - 1].push(nmie.GetQabs());
               Qabs_n[mode_type][n - 1].push(nmie.GetQabs());
             });
             });
-            });
-        });
+          });
+        }
         this.simulationRuntime.Qsca = Qsca;
         this.simulationRuntime.Qsca = Qsca;
         this.simulationRuntime.Qabs = Qabs;
         this.simulationRuntime.Qabs = Qabs;
         this.simulationRuntime.Qsca_n = Qsca_n;
         this.simulationRuntime.Qsca_n = Qsca_n;

+ 17 - 2
vue-cli3-webapp/src/components/GetLayerParameters.vue

@@ -1,20 +1,29 @@
 <template>
 <template>
     <div class="field is-horizontal layer">
     <div class="field is-horizontal layer">
         <div class="field-label is-normal">
         <div class="field-label is-normal">
-            <label class="label">
+            <label class="label lnorm">
                 <div v-if="particle==='bulk'"> bulk </div>
                 <div v-if="particle==='bulk'"> bulk </div>
                 <div v-else-if="particle==='core-shell'">
                 <div v-else-if="particle==='core-shell'">
                     <div v-if="index == 0"> core </div>
                     <div v-if="index == 0"> core </div>
                     <div v-else> shell </div>
                     <div v-else> shell </div>
                 </div>
                 </div>
-                <div v-else> layer {{index+1}} </div>
+                <div v-else>
+                    layer {{index+1}}
+                </div>
             </label>
             </label>
         </div>
         </div>
         <div class="field-body">
         <div class="field-body">
             <div class="field is-grouped is-grouped-multiline">
             <div class="field is-grouped is-grouped-multiline">
+                <div v-if="index == 0" class="rh-input">
                 <input-with-units title="R" v-bind:units="units"
                 <input-with-units title="R" v-bind:units="units"
                                   v-bind:value="layer.R"
                                   v-bind:value="layer.R"
                                   @newdata="layer.R=$event"/>
                                   @newdata="layer.R=$event"/>
+                </div>
+                <div v-else  class="rh-input">
+                <input-with-units title="h" v-bind:units="units"
+                                  v-bind:value="layer.R"
+                                  @newdata="layer.R=$event"/>
+                </div>
                 <input-with-units title="Re(n)" units=""
                 <input-with-units title="Re(n)" units=""
                                   v-bind:value="layer.reN"
                                   v-bind:value="layer.reN"
                                   @newdata="layer.reN=$event"/>
                                   @newdata="layer.reN=$event"/>
@@ -48,4 +57,10 @@
     .layer {
     .layer {
         margin: 0.5rem;
         margin: 0.5rem;
     }
     }
+    .lnorm {
+        font-weight: normal;
+    }
+    .rh-input {
+        margin-right: 12px;
+    }
 </style>
 </style>

+ 3 - 3
vue-cli3-webapp/src/components/GetParticleParameters.vue

@@ -58,12 +58,12 @@
                     while (this.layersNum < this.layers.length) {
                     while (this.layersNum < this.layers.length) {
                         this.layers.pop();
                         this.layers.pop();
                     }
                     }
-                    let r_prev = this.layers.slice(-1)[0].R;
+                    let r_prev = this.layers[0].R;
                     while (this.layersNum > this.layers.length) {
                     while (this.layersNum > this.layers.length) {
-                        r_prev = r_prev*1.1;
+                        // r_prev = r_prev*1.1;
                         this.layers.push(
                         this.layers.push(
                             {
                             {
-                                R: r_prev,
+                                R: r_prev*0.1,
                                 reN: 4.0,
                                 reN: 4.0,
                                 imN: 0.01,
                                 imN: 0.01,
                                 index: 1
                                 index: 1