If not yet available some libraries and their python bindings have to be installed :
In [1]:
import numpy as np
from scipy import constants
import scipy.integrate
import scipy.special as func
from MeshedFields import *
In [6]:
mesh = MeshedField.CircularMesh(R=1.0, ratio=1.0, lcar=0.10)
pts = [np.array([p[0],p[1],5.0]) for p in mesh.points]
screen = MeshedField(pts, mesh.triangles)
print("%d points" % len(screen.points))
print("%d triangles" % len(screen.triangles))
area = screen.MeshArea()
normals = screen.MeshNormals()
average = np.sum(normals, axis=0)/screen.Np
print("total mesh area = %7.3f cm²" % (1.0e4*np.sum(area)))
print("screen normal = %s" % average)
print("bounding box :", screen.BoundingBox())
In [7]:
# time step
screen.dt = 2.0e-13
# all points use the same timing grid
screen.Nt = 400
screen.t0 = np.array([np.linalg.norm(p)/constants.c -200*screen.dt for p in screen.pos])
print("expected arrival time : ", 5.0/constants.c)
print(np.min(screen.t0))
print(np.max(screen.t0)+screen.Nt*screen.dt)
print(len(screen.t0))
In [17]:
filename="../tests/ForwardDiffractionRadiation.h5"
screen.WriteMeshedField(filename)
In [2]:
filename="../tests/ForwardDiffractionRadiation.h5"
computed = MeshedField.ReadMeshedField(filename)
print("%d points" % len(computed.points))
print("%d triangles" % len(computed.triangles))
area = computed.MeshArea()
normals = computed.MeshNormals()
average = np.sum(normals, axis=0)/computed.Np
print("total mesh area = %7.3f cm²" % (1.0e4*np.sum(area)))
print("screen normal = %s" % average)
In [3]:
area = computed.MeshArea()
S = [np.linalg.norm(computed.EnergyFlowVector(i)) for i in range(computed.Np)]
peak_index = np.argmax(S)
Pz = [computed.NormalEnergyFlow(i) for i in range(computed.Np)]
print("peak energy density = %.6f J/m² index=%d" % (S[peak_index],peak_index))
print("total pulse energy = %.3f µJ" % (1e6*np.dot(area,Pz)))
In [4]:
computed.ShowMeshedField(scalars=Pz,scalarTitle="Pz",highlight=[peak_index],showGrid=True)
computed.ShowFieldTrace(peak_index)
In [5]:
def pick(id):
if id>0 and id<computed.Np:
print("cell No. %d pos=%s" % (id,computed.pos[id]))
print("pointing vector S=%s" % computed.EnergyFlowVector(id))
computed.ShowFieldTrace(id)
computed.ShowMeshedField(scalars=Pz,scalarTitle="Pz",pickAction=pick,showGrid=False)
In [ ]: