Sources now use pre-calculated waveform values that are stored in an array, instead of being calculated on-the-fly.

这个提交包含在:
Craig Warren
2017-02-21 12:49:10 +00:00
父节点 a8df199415
当前提交 a28bea41c1

查看文件

@@ -132,6 +132,8 @@ def process_multicmds(multicmds, G):
v.stop = G.timewindow v.stop = G.timewindow
startstop = ' ' startstop = ' '
v.calculate_waveform_values(G)
if G.messages: if G.messages:
print('Voltage source with polarity {} at {:g}m, {:g}m, {:g}m, resistance {:.1f} Ohms,'.format(v.polarisation, v.xcoord * G.dx, v.ycoord * G.dy, v.zcoord * G.dz, v.resistance) + startstop + 'using waveform {} created.'.format(v.waveformID)) print('Voltage source with polarity {} at {:g}m, {:g}m, {:g}m, resistance {:.1f} Ohms,'.format(v.polarisation, v.xcoord * G.dx, v.ycoord * G.dy, v.zcoord * G.dz, v.resistance) + startstop + 'using waveform {} created.'.format(v.waveformID))
@@ -164,7 +166,7 @@ def process_multicmds(multicmds, G):
h = HertzianDipole() h = HertzianDipole()
h.polarisation = polarisation h.polarisation = polarisation
# Set length of dipole to grid size in polaristion direction # Set length of dipole to grid size in polarisation direction
if h.polarisation == 'x': if h.polarisation == 'x':
h.dl = G.dx h.dl = G.dx
elif h.polarisation == 'y': elif h.polarisation == 'y':
@@ -202,6 +204,8 @@ def process_multicmds(multicmds, G):
h.stop = G.timewindow h.stop = G.timewindow
startstop = ' ' startstop = ' '
h.calculate_waveform_values(G)
if G.messages: if G.messages:
if G.dimension == '2D': if G.dimension == '2D':
print('Hertzian dipole is a line source in 2D with polarity {} at {:g}m, {:g}m, {:g}m,'.format(h.polarisation, h.xcoord * G.dx, h.ycoord * G.dy, h.zcoord * G.dz) + startstop + 'using waveform {} created.'.format(h.waveformID)) print('Hertzian dipole is a line source in 2D with polarity {} at {:g}m, {:g}m, {:g}m,'.format(h.polarisation, h.xcoord * G.dx, h.ycoord * G.dy, h.zcoord * G.dz) + startstop + 'using waveform {} created.'.format(h.waveformID))
@@ -265,6 +269,8 @@ def process_multicmds(multicmds, G):
m.start = 0 m.start = 0
m.stop = G.timewindow m.stop = G.timewindow
startstop = ' ' startstop = ' '
m.calculate_waveform_values(G)
if G.messages: if G.messages:
print('Magnetic dipole with polarity {} at {:g}m, {:g}m, {:g}m,'.format(m.polarisation, m.xcoord * G.dx, m.ycoord * G.dy, m.zcoord * G.dz) + startstop + 'using waveform {} created.'.format(m.waveformID)) print('Magnetic dipole with polarity {} at {:g}m, {:g}m, {:g}m,'.format(m.polarisation, m.xcoord * G.dx, m.ycoord * G.dy, m.zcoord * G.dz) + startstop + 'using waveform {} created.'.format(m.waveformID))
@@ -307,7 +313,6 @@ def process_multicmds(multicmds, G):
t.ID = t.__class__.__name__ + '(' + str(t.xcoord) + ',' + str(t.ycoord) + ',' + str(t.zcoord) + ')' t.ID = t.__class__.__name__ + '(' + str(t.xcoord) + ',' + str(t.ycoord) + ',' + str(t.zcoord) + ')'
t.resistance = resistance t.resistance = resistance
t.waveformID = tmp[5] t.waveformID = tmp[5]
t.calculate_incident_V_I(G)
if len(tmp) > 6: if len(tmp) > 6:
# Check source start & source remove time parameters # Check source start & source remove time parameters
@@ -329,6 +334,9 @@ def process_multicmds(multicmds, G):
t.start = 0 t.start = 0
t.stop = G.timewindow t.stop = G.timewindow
startstop = ' ' startstop = ' '
t.calculate_waveform_values(G)
t.calculate_incident_V_I(G)
if G.messages: if G.messages:
print('Transmission line with polarity {} at {:g}m, {:g}m, {:g}m, resistance {:.1f} Ohms,'.format(t.polarisation, t.xcoord * G.dx, t.ycoord * G.dy, t.zcoord * G.dz, t.resistance) + startstop + 'using waveform {} created.'.format(t.waveformID)) print('Transmission line with polarity {} at {:g}m, {:g}m, {:g}m, resistance {:.1f} Ohms,'.format(t.polarisation, t.xcoord * G.dx, t.ycoord * G.dy, t.zcoord * G.dz, t.resistance) + startstop + 'using waveform {} created.'.format(t.waveformID))
@@ -359,19 +367,21 @@ def process_multicmds(multicmds, G):
r.ycoordorigin = ycoord r.ycoordorigin = ycoord
r.zcoordorigin = zcoord r.zcoordorigin = zcoord
# If no ID or outputs are specified, use default i.e Ex, Ey, Ez, Hx, Hy, Hz, Ix, Iy, Iz # If no ID or outputs are specified, use default
if len(tmp) == 3: if len(tmp) == 3:
r.ID = r.__class__.__name__ + '(' + str(r.xcoord) + ',' + str(r.ycoord) + ',' + str(r.zcoord) + ')' r.ID = r.__class__.__name__ + '(' + str(r.xcoord) + ',' + str(r.ycoord) + ',' + str(r.zcoord) + ')'
for key in Rx.defaultoutputs: for key in Rx.defaultoutputs:
r.outputs[key] = np.zeros(G.iterations, dtype=floattype) r.outputs[key] = np.zeros(G.iterations, dtype=floattype)
else: else:
r.ID = tmp[3] r.ID = tmp[3]
# Get allowable outputs
allowableoutputs = Rx.allowableoutputs
# Check and add field output names # Check and add field output names
for field in tmp[4::]: for field in tmp[4::]:
if field in Rx.availableoutputs: if field in allowableoutputs:
r.outputs[field] = np.zeros(G.iterations, dtype=floattype) r.outputs[field] = np.zeros(G.iterations, dtype=floattype)
else: else:
raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' contains an output type that is not available') raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' contains an output type that is not allowable. Allowable outputs in current context are {}'.format(allowableoutputs))
if G.messages: if G.messages:
print('Receiver at {:g}m, {:g}m, {:g}m with output component(s) {} created.'.format(r.xcoord * G.dx, r.ycoord * G.dy, r.zcoord * G.dz, ', '.join(r.outputs))) print('Receiver at {:g}m, {:g}m, {:g}m with output component(s) {} created.'.format(r.xcoord * G.dx, r.ycoord * G.dy, r.zcoord * G.dz, ', '.join(r.outputs)))