|
Electromagnetic Template Library (EMTL)
|
Congratulations, you have installed the HiFDTD library! It's time to run the first script. Firstly, create an empty directory:
mkdir EmptyDir
Second step, you should create an empty '.py' (python extension) file and copy this code into this file:
import emtl
import sys
emtl.emInit(sys.argv[1:])
h_plate = 0.1
task = emtl.uiPyExperiment()
task.UseLambda(1)
task.SetWavelengthRange(600, 0.3, 1.2)
dx = 0.001
task.SetResolution(dx, 0.5) #accuracy
task.SetInternalSpace(emtl.Vector_3(0),emtl.Vector_3(0, 0, 3*h_plate))
task.SetBC(emtl.BC_PER, emtl.BC_PER, emtl.BC_PML)
task.SetPMLType(emtl.CPML_TYPE);
task.SetFourierOnFly(True)
plate = emtl.GetPlate(emtl.Vector_3(0, 0, 1), emtl.Vector_3(0, 0, h_plate), h_plate)
gold = emtl.getAu()
task.AddObject(gold, plate)
task.AddTFSFPlane(emtl.INF, emtl.INF, 0.05)
task.SetPlaneWave(emtl.Vector_3(0,0,1), emtl.Vector_3(1,0,0))
task.AddRTASet("flux", 2, 0.025, 3*h_plate-0.025)
task.BuildDimensions();
task.Calculate(16)
task.Analyze()
This script moddelling light reflecting from gold plate. This script return picture of spectrum of reflection coefficient with name 'Reflecting_spectrum.png'. You can vizulize it using standart python libraries 'matplotlib' and 'pandas'. You should make new python script and copy this code into it:
import matplotlib.pyplot as plt
import pandas as pd
data_spectrum = pd.read_csv('flux.d', sep = '\t', dtype = float)
fig, ax = plt.subplots()
ax.plot(data_spectrum['#wavelength'], 100*data_spectrum['W[0]']/data_spectrum['W[1]'], color = 'blue')
ax.grid()
ax.set_xlabel('Wavelength, $\mu$')
ax.set_ylabel('Reflecting, %')
ax.set_title('Reflecting coefficient')
fig.savefig('Reflecting_spectrum')
If you have not got this libraries, run this code in command promt:
pip install matplotlib
and after installation of matplotlib, run this code:
pip install pandas