# Path: gprMax/constants.py

# 
# Path: gprMax/constants.py

# 
# Path: gprMax/grid.py
# def Ix(x, y, z, Hx, Hy, Hz, G):
#     """Calculates the x-component of current at a grid position.
# 
#     Args:
#         x, y, z (float): Coordinates of position in grid.
#         Hx, Hy, Hz (memory view): numpy array of magnetic field values.
#         G (class): Grid class instance - holds essential parameters describing the model.
#     """
# 
#     if y == 0 or z == 0:
#         Ix = 0
#     else:
#         Ix = G.dy * (Hy[x, y, z - 1] - Hy[x, y, z]) + G.dz * (Hz[x, y, z] - Hz[x, y - 1, z])
# 
#     return Ix
# 
# Path: gprMax/grid.py
# def Iy(x, y, z, Hx, Hy, Hz, G):
#     """Calculates the y-component of current at a grid position.
# 
#     Args:
#         x, y, z (float): Coordinates of position in grid.
#         Hx, Hy, Hz (memory view): numpy array of magnetic field values.
#         G (class): Grid class instance - holds essential parameters describing the model.
#     """
# 
#     if x == 0 or z == 0:
#         Iy = 0
#     else:
#         Iy = G.dx * (Hx[x, y, z] - Hx[x, y, z - 1]) + G.dz * (Hz[x - 1, y, z] - Hz[x, y, z])
# 
#     return Iy
# 
# Path: gprMax/grid.py
# def Iz(x, y, z, Hx, Hy, Hz, G):
#     """Calculates the z-component of current at a grid position.
# 
#     Args:
#         x, y, z (float): Coordinates of position in grid.
#         Hx, Hy, Hz (memory view): numpy array of magnetic field values.
#         G (class): Grid class instance - holds essential parameters describing the model.
#     """
# 
#     if x == 0 or y == 0:
#         Iz = 0
#     else:
#         Iz = G.dx * (Hx[x, y - 1, z] - Hx[x, y, z]) + G.dy * (Hy[x, y, z] - Hy[x - 1, y, z])
# 
#     return Iz
# 
# Path: gprMax/utilities.py
# def round_value(value, decimalplaces=0):
#     """Rounding function.
# 
#     Args:
#         value (float): Number to round.
#         decimalplaces (int): Number of decimal places of float to represent rounded value.
# 
#     Returns:
#         rounded (int/float): Rounded value.
#     """
# 
#     # Rounds to nearest integer (half values are rounded downwards)
#     if decimalplaces == 0:
#         rounded = int(d.Decimal(value).quantize(d.Decimal('1'), rounding=d.ROUND_HALF_DOWN))
# 
#     # Rounds down to nearest float represented by number of decimal places
#     else:
#         precision = '1.{places}'.format(places='0' * decimalplaces)
#         rounded = float(d.Decimal(value).quantize(d.Decimal(precision), rounding=d.ROUND_FLOOR))
# 
#     return rounded


from copy import deepcopy
from gprMax.constants import c
from gprMax.constants import floattype
from gprMax.grid import Ix
from gprMax.grid import Iy
from gprMax.grid import Iz
from gprMax.utilities import round_value
import numpy as np
    import pycuda.gpuarray as gpuarray
        """Calculates all waveform values for source for duration of simulation.

        Args:
            G (class): Grid class instance - holds essential parameters describing the model.
        """

        # Waveform values on timesteps
        self.waveformvalues_wholestep = np.zeros((G.iterations), dtype=floattype)

        # Waveform values on half timesteps
        self.waveformvalues_halfstep = np.zeros((G.iterations), dtype=floattype)

        waveform = next(x for x in G.waveforms if x.ID == self.waveformID)

        for iteration in range(G.iterations):
            time = G.dt * iteration
            if time >= self.start and time <= self.stop:
                # Set the time of the waveform evaluation to account for any delay in the start
                time -= self.start
                self.waveformvalues_wholestep[iteration] = waveform.calculate_value(time, G.dt)
                self.waveformvalues_halfstep[iteration] = waveform.calculate_value(time + 0.5 * G.dt, G.dt)
                

class VoltageSource(Source):
    """A voltage source can be a hard source if it's resistance is zero, 
        i.e. the time variation of the specified electric field component is 
        prescribed. If it's resistance is non-zero it behaves as a resistive 
        voltage source."""

    def __init__(self):

# Path: gprMax/constants.py

# 
# Path: gprMax/constants.py

# 
# Path: gprMax/grid.py
# def Ix(x, y, z, Hx, Hy, Hz, G):
#     """Calculates the x-component of current at a grid position.
# 
#     Args:
#         x, y, z (float): Coordinates of position in grid.
#         Hx, Hy, Hz (memory view): numpy array of magnetic field values.
#         G (class): Grid class instance - holds essential parameters describing the model.
#     """
# 
#     if y == 0 or z == 0:
#         Ix = 0
#     else:
#         Ix = G.dy * (Hy[x, y, z - 1] - Hy[x, y, z]) + G.dz * (Hz[x, y, z] - Hz[x, y - 1, z])
# 
#     return Ix
# 
# Path: gprMax/grid.py
# def Iy(x, y, z, Hx, Hy, Hz, G):
#     """Calculates the y-component of current at a grid position.
# 
#     Args:
#         x, y, z (float): Coordinates of position in grid.
#         Hx, Hy, Hz (memory view): numpy array of magnetic field values.
#         G (class): Grid class instance - holds essential parameters describing the model.
#     """
# 
#     if x == 0 or z == 0:
#         Iy = 0
#     else:
#         Iy = G.dx * (Hx[x, y, z] - Hx[x, y, z - 1]) + G.dz * (Hz[x - 1, y, z] - Hz[x, y, z])
# 
#     return Iy
# 
# Path: gprMax/grid.py
# def Iz(x, y, z, Hx, Hy, Hz, G):
#     """Calculates the z-component of current at a grid position.
# 
#     Args:
#         x, y, z (float): Coordinates of position in grid.
#         Hx, Hy, Hz (memory view): numpy array of magnetic field values.
#         G (class): Grid class instance - holds essential parameters describing the model.
#     """
# 
#     if x == 0 or y == 0:
#         Iz = 0
#     else:
#         Iz = G.dx * (Hx[x, y - 1, z] - Hx[x, y, z]) + G.dy * (Hy[x, y, z] - Hy[x - 1, y, z])
# 
#     return Iz
# 
# Path: gprMax/utilities.py
# def round_value(value, decimalplaces=0):
#     """Rounding function.
# 
#     Args:
#         value (float): Number to round.
#         decimalplaces (int): Number of decimal places of float to represent rounded value.
# 
#     Returns:
#         rounded (int/float): Rounded value.
#     """
# 
#     # Rounds to nearest integer (half values are rounded downwards)
#     if decimalplaces == 0:
#         rounded = int(d.Decimal(value).quantize(d.Decimal('1'), rounding=d.ROUND_HALF_DOWN))
# 
#     # Rounds down to nearest float represented by number of decimal places
#     else:
#         precision = '1.{places}'.format(places='0' * decimalplaces)
#         rounded = float(d.Decimal(value).quantize(d.Decimal(precision), rounding=d.ROUND_FLOOR))
# 
#     return rounded


# Path: gprMax/sources.py
from copy import deepcopy
from gprMax.constants import c
from gprMax.constants import floattype
from gprMax.grid import Ix
from gprMax.grid import Iy
from gprMax.grid import Iz
from gprMax.utilities import round_value
import numpy as np
    import pycuda.gpuarray as gpuarray

        """Calculates all waveform values for source for duration of simulation.

        Args:
            G (class): Grid class instance - holds essential parameters describing the model.
        """

        # Waveform values on timesteps
        self.waveformvalues_wholestep = np.zeros((G.iterations), dtype=floattype)

        # Waveform values on half timesteps
        self.waveformvalues_halfstep = np.zeros((G.iterations), dtype=floattype)

        waveform = next(x for x in G.waveforms if x.ID == self.waveformID)

        for iteration in range(G.iterations):
            time = G.dt * iteration
            if time >= self.start and time <= self.stop:
                # Set the time of the waveform evaluation to account for any delay in the start
                time -= self.start
                self.waveformvalues_wholestep[iteration] = waveform.calculate_value(time, G.dt)
                self.waveformvalues_halfstep[iteration] = waveform.calculate_value(time + 0.5 * G.dt, G.dt)
                

class VoltageSource(Source):
    """A voltage source can be a hard source if it's resistance is zero, 
        i.e. the time variation of the specified electric field component is 
        prescribed. If it's resistance is non-zero it behaves as a resistive 
        voltage source."""

    def __init__(self):

        super().__init__()