|
@@ -21,15 +21,9 @@
|
|
</div>
|
|
</div>
|
|
<!-- <div class="col-xs-grow col-sm q-px-xs">-->
|
|
<!-- <div class="col-xs-grow col-sm q-px-xs">-->
|
|
<!-- <div class="row justify-xs-center justify-sm-start items-baseline">-->
|
|
<!-- <div class="row justify-xs-center justify-sm-start items-baseline">-->
|
|
-
|
|
|
|
<!-- <div class="col-auto">-->
|
|
<!-- <div class="col-auto">-->
|
|
-<!-- <q-btn-->
|
|
|
|
-<!-- color="primary"-->
|
|
|
|
-<!-- no-caps-->
|
|
|
|
-<!-- @click="saveSpectrumSimulation"-->
|
|
|
|
-<!-- >Save</q-btn>-->
|
|
|
|
|
|
+<!-- <SaveSimulationNearField/>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
-
|
|
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
</div>
|
|
</div>
|
|
@@ -38,15 +32,14 @@
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
import {computed, defineComponent, nextTick} 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 {cloneDeep} from 'lodash'
|
|
import {cloneDeep} from 'lodash'
|
|
-import {saveAs} from 'file-saver'
|
|
|
|
import {nearFieldPlane} from 'src/store/simulation-setup/state';
|
|
import {nearFieldPlane} from 'src/store/simulation-setup/state';
|
|
|
|
+// import SaveSimulationNearField from 'components/nearfield/SaveSimulationNearField.vue'
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
name: 'RunSimulationNearField',
|
|
name: 'RunSimulationNearField',
|
|
-
|
|
|
|
|
|
+ // components: {SaveSimulationNearField},
|
|
setup() {
|
|
setup() {
|
|
const $store = useStore()
|
|
const $store = useStore()
|
|
|
|
|
|
@@ -75,7 +68,8 @@ export default defineComponent({
|
|
$store.commit('simulationSetup/copySetupFromGuiToCurrent')
|
|
$store.commit('simulationSetup/copySetupFromGuiToCurrent')
|
|
|
|
|
|
const host = $store.state.simulationSetup.current.hostIndex
|
|
const host = $store.state.simulationSetup.current.hostIndex
|
|
- const plotSideResolution = $store.state.simulationSetup.current.nearFieldSetup.plotSideResolution
|
|
|
|
|
|
+ const plotXSideResolution = $store.state.simulationSetup.current.nearFieldSetup.plotXSideResolution
|
|
|
|
+ const plotYSideResolution = $store.state.simulationSetup.current.nearFieldSetup.plotYSideResolution
|
|
const relativePlotSize = $store.state.simulationSetup.current.nearFieldSetup.relativePlotSize
|
|
const relativePlotSize = $store.state.simulationSetup.current.nearFieldSetup.relativePlotSize
|
|
const crossSection = $store.state.simulationSetup.current.nearFieldSetup.crossSection
|
|
const crossSection = $store.state.simulationSetup.current.nearFieldSetup.crossSection
|
|
try {
|
|
try {
|
|
@@ -95,7 +89,8 @@ export default defineComponent({
|
|
nmie.SetModeNmaxAndType(-1, -1)
|
|
nmie.SetModeNmaxAndType(-1, -1)
|
|
|
|
|
|
nmie.RunFieldCalculationCartesian(
|
|
nmie.RunFieldCalculationCartesian(
|
|
- plotSideResolution,
|
|
|
|
|
|
+ plotYSideResolution,
|
|
|
|
+ plotXSideResolution, // in simulation z-axis resolution for Ek and Hk cross-sections
|
|
relativePlotSize,
|
|
relativePlotSize,
|
|
crossSection,
|
|
crossSection,
|
|
0, 0, 0, 1
|
|
0, 0, 0, 1
|
|
@@ -117,88 +112,9 @@ export default defineComponent({
|
|
}
|
|
}
|
|
|
|
|
|
runNearFieldSimulation()
|
|
runNearFieldSimulation()
|
|
- // watch(isRunning, ()=>{
|
|
|
|
- // console.log(isRunning.value)
|
|
|
|
- // })
|
|
|
|
-
|
|
|
|
- // onActivated(()=>{
|
|
|
|
- // if (isNmieLoaded.value) runNearFieldSimulation()
|
|
|
|
- // })
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
return { isRunning, isNmieLoaded,
|
|
return { isRunning, isNmieLoaded,
|
|
- runNearFieldSimulation,
|
|
|
|
- saveSpectrumSimulation(){
|
|
|
|
- const fileHeader = '# # You can open and plot this file using Python\n' +
|
|
|
|
- '# # (without manually removing this header, it will be skipped), see example below.\n' +
|
|
|
|
- '# import numpy as np\n' +
|
|
|
|
- '# from matplotlib import pyplot as plt\n' +
|
|
|
|
- '# data = np.genfromtxt(\'scattnlay-spectra.txt\', skip_header=21, names=True, delimiter=\', \')\n' +
|
|
|
|
- '# x = data[data.dtype.names[0]] # x-axis has units\n' +
|
|
|
|
- '# # Possible labels for spectrum data: Qsca, Qabs, Qext,\n' +
|
|
|
|
- '# # Qsca_E_dipole, etc. (see last comment before spectra data)\n' +
|
|
|
|
- '# a = data[\'Qsca\']\n' +
|
|
|
|
- '# b = data[\'Qsca_E_dipole\']\n' +
|
|
|
|
- '# c = data[\'Qsca_H_dipole\']\n' +
|
|
|
|
- '# \n' +
|
|
|
|
- '# plt.figure()\n' +
|
|
|
|
- '# plt.plot(x, a, label=\'Qsca\')\n' +
|
|
|
|
- '# plt.plot(x, b, label=\'Qsca E dipole\')\n' +
|
|
|
|
- '# plt.plot(x, c, label=\'Qsca H dipole\')\n' +
|
|
|
|
- '# plt.legend()\n' +
|
|
|
|
- '# plt.xlabel(data.dtype.names[0].replace(\'_\', \', \'))\n' +
|
|
|
|
- '# plt.ylabel(\'Normalized cross-sections\')\n' +
|
|
|
|
- '# plt.show()\n\n'
|
|
|
|
- let xTitle = 'x'
|
|
|
|
- if ( $store.state.plotRuntime.spectrumPlots.layout.xaxis ) {
|
|
|
|
- xTitle = String($store.state.plotRuntime.spectrumPlots.layout.xaxis.title)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let columnNames = '# ' + xTitle + ', Qsca, Qabs, Qext, '
|
|
|
|
- const mode_n = rangeInt($store.state.simulationSetup.current.numberOfModesToPlot, 1);
|
|
|
|
- const mode_types = range(0, 1);
|
|
|
|
- for (const n of mode_n) {
|
|
|
|
- for (const mode_type of mode_types) {
|
|
|
|
- const modeTypeName = mode_type == 0 ? 'E' : 'H'
|
|
|
|
- columnNames += 'Qsca_' + modeTypeName + '_' +getModeName(n)+', '
|
|
|
|
- columnNames += 'Qabs_' + modeTypeName + '_' +getModeName(n)+', '
|
|
|
|
- columnNames += 'Qext_' + modeTypeName + '_' +getModeName(n)+', '
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- columnNames = columnNames.slice(0, -2)
|
|
|
|
- columnNames += '\n'
|
|
|
|
- let body = ''
|
|
|
|
- const WLs = $store.state.plotRuntime.WLsInUnits
|
|
|
|
- const Qsca = $store.state.plotRuntime.Qsca
|
|
|
|
- const Qabs = $store.state.plotRuntime.Qabs
|
|
|
|
- const Qext = $store.state.plotRuntime.Qext
|
|
|
|
- const Qsca_n = $store.state.plotRuntime.Qsca_n
|
|
|
|
- const Qabs_n = $store.state.plotRuntime.Qabs_n
|
|
|
|
- const Qext_n = $store.state.plotRuntime.Qext_n
|
|
|
|
- for (let i = 0; i < WLs.length; ++i) {
|
|
|
|
- let row = WLs[i].toString() + ', '
|
|
|
|
- + Qsca[i].toString() + ', '
|
|
|
|
- + Qabs[i].toString() + ', '
|
|
|
|
- + Qext[i].toString() + ', '
|
|
|
|
- for (const n of mode_n) {
|
|
|
|
- for (const mode_type of mode_types) {
|
|
|
|
- row += Qsca_n[mode_type][n - 1][i].toString() + ', '
|
|
|
|
- row += Qabs_n[mode_type][n - 1][i].toString() + ', '
|
|
|
|
- row += Qext_n[mode_type][n - 1][i].toString() + ', '
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- row = row.slice(0, -2)
|
|
|
|
- row += '\n'
|
|
|
|
- body += row
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const scattnlaySpectra = new Blob([fileHeader+columnNames+body],
|
|
|
|
- {type: 'text/plain;charset=utf-8',
|
|
|
|
- endings: 'native'} //TODO test if newline is correctly written in Windows, MacOS
|
|
|
|
- )
|
|
|
|
- saveAs(scattnlaySpectra, 'scattnlay-spectra.txt');
|
|
|
|
- }
|
|
|
|
|
|
+ runNearFieldSimulation
|
|
}
|
|
}
|
|
},
|
|
},
|
|
})
|
|
})
|