# 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
            self.update_voltage(iteration, G)

        # Shorten number of cells in the transmission line before use with main grid
        self.nl = self.antpos + 1

    def update_abc(self, G):
        """Updates absorbing boundary condition at end of the transmission line.

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

        h = (c * G.dt - self.dl) / (c * G.dt + self.dl)
        self.voltage[0] = h * (self.voltage[1] - self.abcv0) + self.abcv1
        self.abcv0 = self.voltage[0]
        self.abcv1 = self.voltage[1]

    def update_voltage(self, iteration, G):
        """Updates voltage values along the transmission line.

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

        # Update all the voltage values along the line
        self.voltage[1:self.nl] -= (self.resistance * (c * G.dt / self.dl) 
                                    * (self.current[1:self.nl] - self.current[0:self.nl - 1]))

        # Update the voltage at the position of the one-way injector excitation

# 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

            self.update_voltage(iteration, G)

        # Shorten number of cells in the transmission line before use with main grid
        self.nl = self.antpos + 1

    def update_abc(self, G):
        """Updates absorbing boundary condition at end of the transmission line.

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

        h = (c * G.dt - self.dl) / (c * G.dt + self.dl)
        self.voltage[0] = h * (self.voltage[1] - self.abcv0) + self.abcv1
        self.abcv0 = self.voltage[0]
        self.abcv1 = self.voltage[1]

    def update_voltage(self, iteration, G):
        """Updates voltage values along the transmission line.

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

        # Update all the voltage values along the line
        self.voltage[1:self.nl] -= (self.resistance * (c * G.dt / self.dl) 
                                    * (self.current[1:self.nl] - self.current[0:self.nl - 1]))

        # Update the voltage at the position of the one-way injector excitation

        self.voltage[self.srcpos] += ((c * G.dt / self.dl) 