Add files via upload

这个提交包含在:
AdittyaPal
2023-08-13 19:38:39 +05:30
提交者 GitHub
父节点 477e5c4fe2
当前提交 8cff14d48a
共有 2 个文件被更改,包括 45 次插入21 次删除

查看文件

@@ -719,26 +719,36 @@ class TransmissionLine(UserObjectMulti):
grid.transmissionlines.append(t)
"""
------------------------------------------------------------------------------
Add the User MultiObject Class for the Discrete Plane Wave Implementation
Add the UserMultiObject Class for the Discrete Plane Wave Implementation
------------------------------------------------------------------------------
"""
class PlaneWaves(UserObjectMulti):
"""Specifies a current density term at an electric field location.
class PlaneWaves():#UserObjectMulti):
"""
Specifies a plane wave implemented using the discrete plane wave formulation.
The simplest excitation, often referred to as an additive or soft source.
Attributes:
polarisation: string required for polarisation of the source x, y, z.
p1: tuple required for position of source x, y, z.
waveform_id: string required for identifier of waveform used with source.
start: float optional to delay start time (secs) of source.
stop: float optional to time (secs) to remove source.
__________________________
Instance variables:
--------------------------
x_length, double : stores the length along the x axis of the TFSF box
y_length, double : stores the length along the y axis of the TFSF box
z_length, double : stores the length along the z axis of the TFSF box
time_duration, int : stores the number of time steps over which the FDTD simulation is run
dx, double : stores the discretization of the x component of the TFSF box
dy, double : stores the discretixation of the y component of the TFSF box
dz, double : stores the discretization of the z component of the TFSF box
dt, double : stores the time step discretization for the FDTD simulation
corners, int array : stores the coordinates of the cornets of the total field/scattered field boundaries
noOfWaves, int : store the number of waves in the TFSF box in case there are multiple plane waves incident
snapshot, int : stores the interval after which a snapshot of the request fields is recorded
ppw, double : stores the number of points per wavelength for the requested source
"""
def __init__(self, dictOfParams, **kwargs):
super().__init__(**kwargs)
#super().__init__(**kwargs)
self.x_length = dictOfParams['x_domain']
self.y_length = dictOfParams['y_domain']
self.z_length = dictOfParams['z_domain']
@@ -759,7 +769,7 @@ class PlaneWaves(UserObjectMulti):
number = (int)(max(number_x, number_y, number_z))
angles = np.array([[-np.pi/2, 180+63.4, 2, 180-36.7, 1],
[np.pi/2, 63.4, 2, 36.7, 1]])
print("Starting run...")
print("Starting the FDTD run...")
start = time.time()
DPW1 = DiscretePlaneWaveUser(self.time_duration, 3, number_x, number_y, number_z)
@@ -767,6 +777,13 @@ class PlaneWaves(UserObjectMulti):
SpaceGrid = TFSFBoxUser(number_x, number_y, number_z, self.corners, self.time_duration,
3, self.noOfWaves)
"""
DPW1 = DiscretePlaneWave(self.time_duration, 3, number_x, number_y, number_z)
DPW2 = DiscretePlaneWave(self.time_duration, 3, number_x, number_y, number_z)
SpaceGrid = TFSFBox(number_x, number_y, number_z, self.corners, self.time_duration,
3, self.noOfWaves)
"""
SpaceGrid.getFields([DPW1, DPW2], self.snapshot, angles, number,
self.dx, self.dy, self.dz, self.dt, self.ppw)
end = time.time()
@@ -774,7 +791,7 @@ class PlaneWaves(UserObjectMulti):
print("Elapsed (with compilation) = %s sec" % (end - start))
"""
------------------------------------------------------------------------------
End of the User MultiObject Class for the Discrete Plane Wave Implementation
End of the UserMultiObject Class for the Discrete Plane Wave Implementation
------------------------------------------------------------------------------
"""

查看文件

@@ -491,7 +491,7 @@ class TransmissionLine(Source):
self.update_current(iteration, G)
class DiscretePlaneWave():
class DiscretePlaneWave(Source):
'''
Class to implement the discrete plane wave (DPW) formulation as described in
Tan, T.; Potter, M. (2010).
@@ -521,6 +521,8 @@ class DiscretePlaneWave():
time_dimension, int : local variable to store the time length over which the simulation is run
dimensions, int : local variable to store the number of dimensions in which the simulation is run
'''
super().__init__()
self.waveformID = "ricker".encode('UTF-8')
self.m = np.zeros(dimensions+1, dtype=np.int32) #+1 to store the max(m_x, m_y, m_z)
self.directions = np.zeros(dimensions, dtype=np.int32)
self.dimensions = dimensions
@@ -530,6 +532,7 @@ class DiscretePlaneWave():
self.ds = 0
self.E_fields = []
self.H_fields = []
self.dt = 0
def initializeGrid(self, dl, dt):
'''
@@ -605,8 +608,10 @@ class DiscretePlaneWave():
self.directions, self.m = getIntegerForAngles(phi, Delta_phi, theta, Delta_theta,
np.array([dx, dy, dz])) #get the integers for the nearest rational angle
#store max(m_x, m_y, m_z) in the last element of the array
print(self.m)
print(self.directions)
print("[m_x, m_y, m_z] :", self.m[:-1])
print("Approximated Phi : ", "{:.3f}".format(np.arctan2(self.m[1]/dy, self.m[0]/dx)*180/np.pi))
print("Approximated Theta : ", "{:.3f}".format(np.arctan2(np.sqrt((self.m[0]/dx)*(self.m[0]/dx)+
(self.m[1]/dy)*(self.m[1]/dy)), self.m[2]/dz)*180/np.pi))
self.length = int(2*np.sum(self.m[:-1])*number) #set an appropriate length fo the one dimensional arrays
#the 1D grid has no ABC to terminate it, sufficiently long array prevents reflections from the back
#self.m = np.abs(self.m.astype(np.int32, copy=False)) #typecast to positive integers
@@ -617,7 +622,7 @@ class DiscretePlaneWave():
if self.m[0] == 0: #calculate dr that is needed for sourcing the 1D array
if self.m[1] == 0:
if self.m[2] == 0:
raise ValueError("not all M values can be zero")
raise ValueError("not all m_i values can be zero")
else:
self.ds = P[2]*dz/self.m[2]
else:
@@ -686,9 +691,11 @@ class TFSFBox():
def getFields(self, planeWaves, snapshot, angles, number, dx, dy, dz, dt, ppw):
face_fields, abccoef = self.initializeABC()
for i in range(self.noOfWaves):
print(f"Plane Wave {i+1} :")
planeWaves[i].runDiscretePlaneWave(angles[i, 0], angles[i, 1], angles[i, 2], angles[i, 3],
angles[i, 4], number, dx, dy, dz)
C, D = planeWaves[i].initializeGrid(np.array([dx, dy, dz]), dt) #initialize the one dimensional arrays and coefficients
getGridFields(planeWaves, C, D, snapshot, self.n_x, self.n_y, self.n_z, self.fields,
self.corners, self.time_duration, face_fields, abccoef, dt, self.noOfWaves,
constants.c, ppw, self.dimensions)
getGridFields(planeWaves, C, D, snapshot, self.n_x, self.n_y, self.n_z, self.fields, self.corners,
self.time_duration, face_fields, abccoef, dt, self.noOfWaves, constants.c, ppw,
self.dimensions, './snapshots/electric', [0], [])