diff --git a/festim/exports/derived_quantities/average_volume.py b/festim/exports/derived_quantities/average_volume.py index 4dc70e1ce..7c87e1908 100644 --- a/festim/exports/derived_quantities/average_volume.py +++ b/festim/exports/derived_quantities/average_volume.py @@ -62,25 +62,11 @@ class AverageVolumeCylindrical(AverageVolume): file function (dolfin.function.function.Function): the solution function of the field - azimuth_range (tuple, optional): Range of the azimuthal angle - (theta) needs to be between 0 and 2 pi. Defaults to (0, 2 * np.pi). """ - def __init__(self, field, volume, z, azimuth_range=(0, 2 * np.pi)) -> None: + def __init__(self, field, volume) -> None: super().__init__(field=field, volume=volume) self.r = None - self.z = z - self.azimuth_range = azimuth_range - - @property - def azimuth_range(self): - return self._azimuth_range - - @azimuth_range.setter - def azimuth_range(self, value): - if value[0] < 0 or value[1] > 2 * np.pi: - raise ValueError("Azimuthal range must be between 0 and pi") - self._azimuth_range = value def compute(self): @@ -91,15 +77,9 @@ def compute(self): rthetaz = f.SpatialCoordinate(mesh) # get the coordinates from the mesh self.r = rthetaz[0] # only care about r here - values = f.assemble(self.function * self.r * self.z * self.dx(self.volume)) * ( - self.azimuth_range[1] - self.azimuth_range[0] - ) - - volume = f.assemble(1 * self.r * self.z * self.dx(self.volume)) * ( - self.azimuth_range[1] - self.azimuth_range[0] - ) - - avg_vol = values / volume + avg_vol = f.assemble( + self.function * self.r * self.dx(self.volume) + ) / f.assemble(1 * self.r * self.dx(self.volume)) return avg_vol @@ -121,39 +101,11 @@ class AverageVolumeSpherical(AverageVolume): file function (dolfin.function.function.Function): the solution function of the field - azimuth_range (tuple, optional): Range of the azimuthal angle - (theta) needs to be between 0 and pi. Defaults to (0, np.pi) - polar_range (tuple, optional): Range of the polar angle - (phi) needs to be between - pi and pi. Defaults to (-np.pi, np.pi) """ - def __init__( - self, field, volume, azimuth_range=(0, np.pi), polar_range=(-np.pi, np.pi) - ) -> None: + def __init__(self, field, volume) -> None: super().__init__(field=field, volume=volume) self.r = None - self.azimuth_range = azimuth_range - self.polar_range = polar_range - - @property - def polar_range(self): - return self._polar_range - - @polar_range.setter - def polar_range(self, value): - if value[0] < -np.pi or value[1] > np.pi: - raise ValueError("Polar range must be between - pi and pi") - self._polar_range = value - - @property - def azimuth_range(self): - return self._azimuth_range - - @azimuth_range.setter - def azimuth_range(self, value): - if value[0] < 0 or value[1] > np.pi: - raise ValueError("Azimuthal range must be between 0 and pi") - self._azimuth_range = value def compute(self): @@ -164,18 +116,8 @@ def compute(self): rthetaphi = f.SpatialCoordinate(mesh) # get the coordinates from the mesh self.r = rthetaphi[0] # only care about r here - values = ( - f.assemble(self.function * self.r**2 * self.dx(self.volume)) - * (self.polar_range[1] - self.polar_range[0]) - * (-np.cos(self.azimuth_range[1]) + np.cos(self.azimuth_range[0])) - ) - - volume = ( - f.assemble(1 * self.r**2 * self.dx(self.volume)) - * (self.polar_range[1] - self.polar_range[0]) - * (-np.cos(self.azimuth_range[1]) + np.cos(self.azimuth_range[0])) - ) - - avg_vol = values / volume + avg_vol = f.assemble( + self.function * self.r**2 * self.dx(self.volume) + ) / f.assemble(1 * self.r**2 * self.dx(self.volume)) return avg_vol