Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow axial direction in probe response #1075

Merged
merged 8 commits into from
Jul 4, 2024

Conversation

jguarato
Copy link
Contributor

@jguarato jguarato commented Jun 21, 2024

This PR introduces support for obtaining the response in the axial direction of a 6 dof model using the Probe class. This was created to resolve issue #1059.

Changes:

  1. Enhancements to Probe Class:
    • Added direction parameter to the constructor to distinguish between radial and axial measurements.
    • When direction is radial, the angle parameter must be provided; for axial direction, angle is None.
    • Implemented the get_label() method to generate informative labels for probes based on their attributes (node, angle, and direction).
def __init__(self, node, angle=None, direction="radial", tag=None):
    self.node = node
    self.angle = angle
    self.direction = direction
    self.tag = tag

    if self.direction not in ("radial", "axial"):
        raise ValueError("Direction must be 'radial' or 'axial'")

    if self.direction == "radial" and self.angle is None:
        raise ValueError("Angle must be provided when direction is 'radial'")
    elif self.direction == "axial":
        self.angle = None
def get_label(self, id=None):
    label = "Probe" if id is None else f"Probe {id}"
    label += f" - Node {self.node} "

    if self.direction == "radial":
        try:
            angle = Q_(self.angle, "rad").to("deg").m
            label += f"({angle:.0f}°)"
        except TypeError:
            label += f"({self.angle})"
    else:
        label += "(axial direction)"

    return label
  1. Handling of Probe Objects and Tuples in TimeRensponseResults and Faults classes:

    • Deprecated the use of tuples for representing probes in favor of the Probe class.
    • Introduced a DeprecationWarning when tuples are detected, advising users.
  2. Plotting Time Response Results:

    • Updated the plot_1d() method to accept lists of Probe objects directly.
    • Automatic label generation for probes, when tag is not provided, using the get_label() method.
for i, p in enumerate(probe):
        probe_direction = "radial"
        try:
                node = p.node
                angle = p.angle
                probe_tag = p.tag or p.get_label(i + 1)
                if p.direction == "axial":
                        if num_dof == 6:
                                probe_direction = p.direction
                        else:
                                continue
        except AttributeError:
                node = p[0]
                warn(
                        "The use of tuples in the probe argument is deprecated. Use the Probe class instead.",
                        DeprecationWarning,
                )
                try:
                angle = Q_(p[1], probe_units).to("rad").m
                except TypeError:
                        angle = p[1]
                try:
                        probe_tag = p[2]
                except IndexError:
                        probe_tag = f"Probe {i+1} - Node {p[0]}"]}"

Example 1: Probes without tags

probes = [
    Probe(3, angle=Q_(0, "deg")),
    Probe(3, angle=Q_(90, "deg")),
    Probe(3, direction="axial"),
]
fig = response.plot_1d(probes)

4dof_no_tag
6dof_no_tag

Example 2: Probes with tags

probes = [
    Probe(3, Q_(0, "deg"), tag="Node 3 - x"),
    Probe(3, Q_(90, "deg"), tag="Node 3 - y"),
    Probe(3, direction="axial", tag="Node 3 - z"),
]
fig = response.plot_1d(probes)

4dof_with_tag
6dof_with_tag

Note: The probe_units argument may no longer be necessary when plotting responses, as the use of tuples for representing probes has been deprecated in favor of using the Probe class.

@jguarato jguarato marked this pull request as draft June 21, 2024 20:32
@codecov-commenter
Copy link

codecov-commenter commented Jun 21, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 65.15152% with 46 lines in your changes missing coverage. Please review.

Project coverage is 84.63%. Comparing base (f39e32a) to head (cb71d30).
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1075      +/-   ##
==========================================
- Coverage   85.04%   84.63%   -0.41%     
==========================================
  Files          35       35              
  Lines        7830     7895      +65     
==========================================
+ Hits         6659     6682      +23     
- Misses       1171     1213      +42     
Files Coverage Δ
ross/faults/crack.py 97.16% <ø> (ø)
ross/faults/misalignment.py 97.56% <ø> (ø)
ross/faults/rubbing.py 93.10% <ø> (ø)
ross/rotor_assembly.py 93.89% <ø> (ø)
ross/utils.py 91.78% <ø> (ø)
ross/probe.py 76.47% <69.23%> (-16.39%) ⬇️
ross/faults/abs_fault.py 75.00% <48.38%> (-20.75%) ⬇️
ross/results.py 84.85% <70.66%> (-1.29%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 614b466...cb71d30. Read the comment docs.

@jguarato jguarato marked this pull request as ready for review June 27, 2024 18:07
@raphaeltimbo raphaeltimbo merged commit 5e392e5 into petrobras:main Jul 4, 2024
9 checks passed
@jguarato jguarato deleted the dev/probe-resp-6dof branch July 11, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants