# Path: gprMax/constants.py

# 
# Path: gprMax/constants.py

# 
# Path: gprMax/constants.py

# 
# Path: gprMax/exceptions.py
# class GeneralError(ValueError):
#     """Handles general errors. Subclasses the ValueError class."""
# 
#     def __init__(self, message, *args):
# 
#         self.message = message
#         super(GeneralError, self).__init__(message, *args)
#         print(Fore.RED)


from importlib import import_module
from tqdm import tqdm
from gprMax.constants import e0
from gprMax.constants import z0
from gprMax.constants import floattype
from gprMax.exceptions import GeneralError
import numpy as np
        import pycuda.gpuarray as gpuarray

        if self.direction[0] == 'x':
            self.EPhi1 = np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz + 1), dtype=floattype)
            self.EPhi2 = np.zeros((len(self.CFS), self.nx + 1, self.ny + 1, self.nz), dtype=floattype)
            self.HPhi1 = np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz), dtype=floattype)
            self.HPhi2 = np.zeros((len(self.CFS), self.nx, self.ny, self.nz + 1), dtype=floattype)
        elif self.direction[0] == 'y':
            self.EPhi1 = np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz + 1), dtype=floattype)
            self.EPhi2 = np.zeros((len(self.CFS), self.nx + 1, self.ny + 1, self.nz), dtype=floattype)
            self.HPhi1 = np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz), dtype=floattype)
            self.HPhi2 = np.zeros((len(self.CFS), self.nx, self.ny, self.nz + 1), dtype=floattype)
        elif self.direction[0] == 'z':
            self.EPhi1 = np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz + 1), dtype=floattype)
            self.EPhi2 = np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz + 1), dtype=floattype)
            self.HPhi1 = np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz), dtype=floattype)
            self.HPhi2 = np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz), dtype=floattype)

    def calculate_update_coeffs(self, er, mr, G):
        """Calculates electric and magnetic update coefficients for the PML.

        Args:
            er (float): Average permittivity of underlying material
            mr (float): Average permeability of underlying material
            G (class): Grid class instance - holds essential parameters describing the model.
        """

        self.ERA = np.zeros((len(self.CFS), self.thickness), dtype=floattype)
        self.ERB = np.zeros((len(self.CFS), self.thickness), dtype=floattype)
        self.ERE = np.zeros((len(self.CFS), self.thickness), dtype=floattype)
        self.ERF = np.zeros((len(self.CFS), self.thickness), dtype=floattype)

# Path: gprMax/constants.py

# 
# Path: gprMax/constants.py

# 
# Path: gprMax/constants.py

# 
# Path: gprMax/exceptions.py
# class GeneralError(ValueError):
#     """Handles general errors. Subclasses the ValueError class."""
# 
#     def __init__(self, message, *args):
# 
#         self.message = message
#         super(GeneralError, self).__init__(message, *args)
#         print(Fore.RED)


# Path: gprMax/pml.py
from importlib import import_module
from tqdm import tqdm
from gprMax.constants import e0
from gprMax.constants import z0
from gprMax.constants import floattype
from gprMax.exceptions import GeneralError
import numpy as np
        import pycuda.gpuarray as gpuarray


        if self.direction[0] == 'x':
            self.EPhi1 = np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz + 1), dtype=floattype)
            self.EPhi2 = np.zeros((len(self.CFS), self.nx + 1, self.ny + 1, self.nz), dtype=floattype)
            self.HPhi1 = np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz), dtype=floattype)
            self.HPhi2 = np.zeros((len(self.CFS), self.nx, self.ny, self.nz + 1), dtype=floattype)
        elif self.direction[0] == 'y':
            self.EPhi1 = np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz + 1), dtype=floattype)
            self.EPhi2 = np.zeros((len(self.CFS), self.nx + 1, self.ny + 1, self.nz), dtype=floattype)
            self.HPhi1 = np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz), dtype=floattype)
            self.HPhi2 = np.zeros((len(self.CFS), self.nx, self.ny, self.nz + 1), dtype=floattype)
        elif self.direction[0] == 'z':
            self.EPhi1 = np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz + 1), dtype=floattype)
            self.EPhi2 = np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz + 1), dtype=floattype)
            self.HPhi1 = np.zeros((len(self.CFS), self.nx + 1, self.ny, self.nz), dtype=floattype)
            self.HPhi2 = np.zeros((len(self.CFS), self.nx, self.ny + 1, self.nz), dtype=floattype)

    def calculate_update_coeffs(self, er, mr, G):
        """Calculates electric and magnetic update coefficients for the PML.

        Args:
            er (float): Average permittivity of underlying material
            mr (float): Average permeability of underlying material
            G (class): Grid class instance - holds essential parameters describing the model.
        """

        self.ERA = np.zeros((len(self.CFS), self.thickness), dtype=floattype)
        self.ERB = np.zeros((len(self.CFS), self.thickness), dtype=floattype)
        self.ERE = np.zeros((len(self.CFS), self.thickness), dtype=floattype)
        self.ERF = np.zeros((len(self.CFS), self.thickness), dtype=floattype)

        self.HRA = np.zeros((len(self.CFS), self.thickness), dtype=floattype)