Skip to content

Commit

Permalink
remove angles
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdark committed Jul 26, 2024
1 parent a83849e commit 4bc4a6a
Showing 1 changed file with 8 additions and 66 deletions.
74 changes: 8 additions & 66 deletions festim/exports/derived_quantities/average_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 69 in festim/exports/derived_quantities/average_volume.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/derived_quantities/average_volume.py#L68-L69

Added lines #L68 - L69 were not covered by tests
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):

Expand All @@ -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

Check warning on line 78 in festim/exports/derived_quantities/average_volume.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/derived_quantities/average_volume.py#L77-L78

Added lines #L77 - L78 were not covered by tests

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(

Check warning on line 80 in festim/exports/derived_quantities/average_volume.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/derived_quantities/average_volume.py#L80

Added line #L80 was not covered by tests
self.function * self.r * self.dx(self.volume)
) / f.assemble(1 * self.r * self.dx(self.volume))

return avg_vol

Check warning on line 84 in festim/exports/derived_quantities/average_volume.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/derived_quantities/average_volume.py#L84

Added line #L84 was not covered by tests

Expand All @@ -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

Check warning on line 108 in festim/exports/derived_quantities/average_volume.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/derived_quantities/average_volume.py#L107-L108

Added lines #L107 - L108 were not covered by tests
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):

Expand All @@ -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

Check warning on line 117 in festim/exports/derived_quantities/average_volume.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/derived_quantities/average_volume.py#L116-L117

Added lines #L116 - L117 were not covered by tests

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(

Check warning on line 119 in festim/exports/derived_quantities/average_volume.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/derived_quantities/average_volume.py#L119

Added line #L119 was not covered by tests
self.function * self.r**2 * self.dx(self.volume)
) / f.assemble(1 * self.r**2 * self.dx(self.volume))

return avg_vol

Check warning on line 123 in festim/exports/derived_quantities/average_volume.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/derived_quantities/average_volume.py#L123

Added line #L123 was not covered by tests

0 comments on commit 4bc4a6a

Please sign in to comment.