|
@@ -105,7 +105,7 @@
|
|
|
import InputWithUnits from "./components/InputWithUnits.vue";
|
|
|
import ReactiveChart from "./components/ReactiveChart.vue";
|
|
|
|
|
|
- // You should put *.wasm to public and *.js to src folder
|
|
|
+ // You should put *.wasm to public/ and *.js to src/ folder
|
|
|
|
|
|
// To compile fibbonacci example use
|
|
|
// emcc -O3 -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME="fibonacci"' -o ./fibonacci.js fibonacci.c
|
|
@@ -153,119 +153,121 @@
|
|
|
console.log(nmie.GetQsca());
|
|
|
}
|
|
|
|
|
|
-const range = (start, stop, step = 1) =>
|
|
|
- Array(Math.ceil((stop - start) / step)).fill(start).map((x, y) => x + y * step);
|
|
|
+ const range = (start, stop, step = 1) =>
|
|
|
+ Array(Math.ceil((stop - start) / step)).fill(start).map((x, y) => x + y * step);
|
|
|
|
|
|
-export default {
|
|
|
- name: 'app',
|
|
|
- components: {
|
|
|
- InputWithUnits,
|
|
|
- ReactiveChart
|
|
|
- // HelloWorld
|
|
|
- },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- window: {
|
|
|
- width: 0,
|
|
|
- height: 0
|
|
|
- },
|
|
|
- // on change of initial value for __ units __
|
|
|
- // remember to update this.chart.layout.xaxis.title
|
|
|
- units: 'nm',
|
|
|
- simulationRuntime: {
|
|
|
- mode_n : [],
|
|
|
- mode_types: range(0,2),
|
|
|
- mode_names: ['E','H'],
|
|
|
- WLs: [],
|
|
|
- Qsca: [],
|
|
|
- Qabs: [],
|
|
|
- Qsca_n: [[],[]],
|
|
|
- Qabs_n: [[],[]],
|
|
|
- layout: {},
|
|
|
- trace1: {},
|
|
|
- trace2: {}
|
|
|
- },
|
|
|
- simulationSetup: {
|
|
|
- stepWL: 0.5,
|
|
|
- fromWL: 300.0,
|
|
|
- toWL: 1000.0,
|
|
|
- R: 100.0,
|
|
|
- reN: 4.0,
|
|
|
- imN: 0.01,
|
|
|
- total_mode_n:4
|
|
|
- },
|
|
|
- changes: 0,
|
|
|
- isShowInfo: false,
|
|
|
- chart: {
|
|
|
- uuid: "123",
|
|
|
- traces: [
|
|
|
- {
|
|
|
- y: [],
|
|
|
- line: {
|
|
|
- color: "#5e9e7e",
|
|
|
- width: 4,
|
|
|
- shape: "line"
|
|
|
+ export default {
|
|
|
+ name: 'app',
|
|
|
+ components: {
|
|
|
+ InputWithUnits,
|
|
|
+ ReactiveChart
|
|
|
+ // HelloWorld
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ window: {
|
|
|
+ width: 0,
|
|
|
+ height: 0
|
|
|
+ },
|
|
|
+ // on change of initial value for __ units __
|
|
|
+ // remember to update this.chart.layout.xaxis.title
|
|
|
+ units: 'nm',
|
|
|
+ simulationRuntime: {
|
|
|
+ mode_n : [],
|
|
|
+ mode_types: range(0,2),
|
|
|
+ mode_names: ['E','H'],
|
|
|
+ WLs: [],
|
|
|
+ Qsca: [],
|
|
|
+ Qabs: [],
|
|
|
+ Qsca_n: [[],[]],
|
|
|
+ Qabs_n: [[],[]],
|
|
|
+ layout: {},
|
|
|
+ trace1: {},
|
|
|
+ trace2: {}
|
|
|
+ },
|
|
|
+ simulationSetup: {
|
|
|
+ stepWL: 0.5,
|
|
|
+ fromWL: 300.0,
|
|
|
+ toWL: 1000.0,
|
|
|
+ R: 100.0,
|
|
|
+ reN: 4.0,
|
|
|
+ imN: 0.01,
|
|
|
+ total_mode_n:4
|
|
|
+ },
|
|
|
+ changes: 0,
|
|
|
+ isShowInfo: false,
|
|
|
+ chart: {
|
|
|
+ uuid: "123",
|
|
|
+ traces: [
|
|
|
+ {
|
|
|
+ y: [],
|
|
|
+ line: {
|
|
|
+ color: "#5e9e7e",
|
|
|
+ width: 4,
|
|
|
+ shape: "line"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ layout: {
|
|
|
+ title:'reactive charts',
|
|
|
+ xaxis: {
|
|
|
+ // initial value should be same as in units
|
|
|
+ title: 'Wavelength, nm'
|
|
|
+ },
|
|
|
+ yaxis: {
|
|
|
+ title: 'yaxis title'
|
|
|
}
|
|
|
- }
|
|
|
- ],
|
|
|
- layout: {
|
|
|
- title:'reactive charts',
|
|
|
- xaxis: {
|
|
|
- // initial value should be same as in units
|
|
|
- title: 'Wavelength, nm'
|
|
|
- },
|
|
|
- yaxis: {
|
|
|
- title: 'yaxis title'
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- };
|
|
|
+ };
|
|
|
|
|
|
- },
|
|
|
- created() {
|
|
|
- window.addEventListener('resize', this.handleResize)
|
|
|
- this.handleResize();
|
|
|
- },
|
|
|
- destroyed() {
|
|
|
- window.removeEventListener('resize', this.handleResize)
|
|
|
- },
|
|
|
- mounted(){ this.runMie();},
|
|
|
- watch: {
|
|
|
- simulationSetup: {
|
|
|
- handler: function () {
|
|
|
- this.runMie();
|
|
|
- },
|
|
|
- deep: true
|
|
|
},
|
|
|
- units:{
|
|
|
- handler: function () {
|
|
|
- this.chart.layout.xaxis.title = "Wavelength, "+this.units;
|
|
|
+ created() {
|
|
|
+ window.addEventListener('resize', this.handleResize)
|
|
|
+ this.handleResize();
|
|
|
+ },
|
|
|
+ destroyed() {
|
|
|
+ window.removeEventListener('resize', this.handleResize)
|
|
|
+ },
|
|
|
+ mounted(){ this.runMie();},
|
|
|
+ watch: {
|
|
|
+ simulationSetup: {
|
|
|
+ handler: function () {
|
|
|
+ this.runMie();
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
+ },
|
|
|
+ units:{
|
|
|
+ handler: function () {
|
|
|
+ this.chart.layout.xaxis.title = "Wavelength, "+this.units;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- handleResize() {
|
|
|
- this.window.width = window.innerWidth;
|
|
|
- this.window.height = window.innerHeight;
|
|
|
},
|
|
|
- runMie(){
|
|
|
-
|
|
|
- // let t0 = performance.now();
|
|
|
- // let fromWL = parseFloat(this.simulationSetup.fromWL);
|
|
|
- // let toWL = parseFloat(this.simulationSetup.toWL);
|
|
|
- // let stepWL = parseFloat(this.simulationSetup.stepWL);
|
|
|
- // let R = parseFloat(this.simulationSetup.R);
|
|
|
- // let reN = parseFloat(this.simulationSetup.reN);
|
|
|
- // let imN = parseFloat(this.simulationSetup.imN);
|
|
|
- // this.simulationRuntime.Qsca = [], this.simulationRuntime.Qabs = [];
|
|
|
- // this.simulationRuntime.Qsca_n = [[],[]], this.simulationRuntime.Qabs_n = [[],[]];
|
|
|
- // nmie.ClearTarget();
|
|
|
- // nmie.AddTargetLayerReIm(R, reN, imN)
|
|
|
+ methods: {
|
|
|
+ handleResize() {
|
|
|
+ this.window.width = window.innerWidth;
|
|
|
+ this.window.height = window.innerHeight;
|
|
|
+ },
|
|
|
+ runMie(){
|
|
|
+ module.onRuntimeInitialized = () => {
|
|
|
+ const nmie = new module.nmie();
|
|
|
|
|
|
+ // let t0 = performance.now();
|
|
|
+ // let fromWL = parseFloat(this.simulationSetup.fromWL);
|
|
|
+ // let toWL = parseFloat(this.simulationSetup.toWL);
|
|
|
+ // let stepWL = parseFloat(this.simulationSetup.stepWL);
|
|
|
+ let R = parseFloat(this.simulationSetup.R);
|
|
|
+ let reN = parseFloat(this.simulationSetup.reN);
|
|
|
+ let imN = parseFloat(this.simulationSetup.imN);
|
|
|
+ this.simulationRuntime.Qsca = [], this.simulationRuntime.Qabs = [];
|
|
|
+ this.simulationRuntime.Qsca_n = [[], []], this.simulationRuntime.Qabs_n = [[], []];
|
|
|
+ nmie.ClearTarget();
|
|
|
+ nmie.AddTargetLayerReIm(R, reN, imN)
|
|
|
+ }
|
|
|
|
|
|
- this.changes++;
|
|
|
- }
|
|
|
- },
|
|
|
+ this.changes++;
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
}
|
|
|
</script>
|