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

Add methods to Member for returning result arrays #144

Closed
connorferster opened this issue Jan 28, 2023 · 2 comments
Closed

Add methods to Member for returning result arrays #144

connorferster opened this issue Jan 28, 2023 · 2 comments

Comments

@connorferster
Copy link
Collaborator

connorferster commented Jan 28, 2023

Is your feature request related to a problem? Please describe.
In order to generate a factored load envelope, I need access to the results arrays of various load cases/combinations. I can generate these on my own but thought that it would be a welcome addition and possibly a stepping stone for future features in #101.

I am happy to create the PR for this!

Describe the solution you'd like
The suggestion is to create the following methods onto Member:

  • .axial_array
  • .torque_array
  • .shear_array
  • .moment_array
  • .deflection_array

They could be implemented similar to the hard-coded approach you have in .plot_shear, etc.

def shear_array(dir: str, n: int, combo_name: str) -> np.ndarray:
    """
    Returns an array describing the shear result...
    ...
    """
    L = self.L
    x_arr = np.linspace(0, L, n)
    y_arr = np.array(
        [self.shear(dir, combo_name) for x in x_arr]
    )
    return np.array([x_arr, y_arr])

These methods could then replace those sections of code in the .plot_... methods and would allow for the .plot_... methods to have a user-specified n indicating the number of points they would like to discretize the plot with, which would be good because sometimes 20 points is just not enough and the plots end up looking distorted and confusing.

Describe alternatives you've considered
Generating the arrays myself

Additional context
Having access to results arrays allows for plots to be generated in any plotting software, not just matplotlib. By generating the resulting arrays conveniently, it allows for a little bit extra extensibility both for plotting and post-processing.

@JWock82
Copy link
Owner

JWock82 commented Jan 31, 2023

I like this idea. I think there's a way to do it with minimal extra lines of code. What if we had a boolean argument in the plot_shear method named 'to_array' (defaults to False) that changed the output of the method to an array instead of a matplotlib plot? I agree that 20 points is often just not enough too. I've been meaning to add an 'n' argument to plot_shear as well.

@JWock82
Copy link
Owner

JWock82 commented Jan 31, 2023

It seems like all it would take is an if statement placed conveniently to ignore the plotting commands and return the array directly.

JWock82 added a commit that referenced this issue Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants