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 Strain Example from MHKiT-Python #156

Merged
merged 11 commits into from
Jan 28, 2025

Conversation

simmsa
Copy link
Contributor

@simmsa simmsa commented Jan 21, 2025

Use MATLAB's Markup syntax (similar to Markdown) to create a Livescript example
in .m format. This format allows version control diffability while maintaining
Livescript functionality when opened in MATLAB.

The Markup specification is documented here:
https://www.mathworks.com/help/matlab/matlab_prog/marking-up-matlab-comments-for-publishing.html.

This approach is forward-compatible with MATLAB R2024b's new plain text
format for Live Scripts:
https://www.mathworks.com/help/matlab/matlab_env/beta-new-desktop-for-matlab.html

To hedge against MATLAB removing support for Markup it is also
recommended to generate the .mlx and html files.

Uses MATLAB's Markup syntax (similar to Markdown) to create a Livescript example
in .m format. This format allows version control diffability while maintaining
Livescript functionality when opened in MATLAB.

The Markup specification is documented here:
https://www.mathworks.com/help/matlab/matlab_prog/marking-up-matlab-comments-for-publishing.html.

This approach is forward-compatible with MATLAB R2024b's new plain text
format for Live Scripts:
https://www.mathworks.com/help/matlab/matlab_env/beta-new-desktop-for-matlab.html

To hedge against MATLAB removing support for Markup it is also
recommended to generate the `.mlx` and `html` files.
@simmsa simmsa requested a review from MShabara January 21, 2025 20:58
@simmsa simmsa marked this pull request as ready for review January 21, 2025 20:59
@simmsa simmsa requested a review from akeeste January 21, 2025 21:00
@simmsa
Copy link
Contributor Author

simmsa commented Jan 21, 2025

@MShabara and @akeeste this is ready for review. Right now this just mimics the functionality from the MHKiT-Python Strain Example: https://github.com/MHKiT-Software/MHKiT-Python/blob/main/examples/strain_measurement_example.ipynb

Copy link

@akeeste akeeste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simmsa a couple minor fixes:

  • The images "resulting_loads_resized.png" and "global_cs_resized.png" have their names swapped. Once the names are switched, the images will match the filenames and they will be referenced correctly in the .mlx and .m files
  • some subtitles from the python notebook are included in the mlx but don't format quite right
    • "90 degree rosettes"
    • "Alternate equations for 120 degree rosettes"
    • "Define equations for normal force, moment, and torsion"

Otherwise all the calculations and plots look good and match the python example.

On file formats--A diffable livescript would be great, but it seems like MATLAB is a few releases away before that's widely supported in the MATLAB GUI itself. Though publishing the .m file straight to html is easy and can give the same advantage. I don't ever use the publish functionality, but it was pretty easy to click through and get a nicely formatted HTML file. Could the publishable .m file replace the mlx files entirely? A user could quickly publish the .m file (or view the documentation) to see plots and comments in line, while also having the code readily accessible in a familiar format.

@simmsa
Copy link
Contributor Author

simmsa commented Jan 28, 2025

@akeeste, thanks for taking a look at this. I fixed the images and formatting and I think this is good to go.

On file formats--A diffable livescript would be great, but it seems like MATLAB is a few releases away before that's widely supported in the MATLAB GUI itself. Though publishing the .m file straight to html is easy and can give the same advantage. I don't ever use the publish functionality, but it was pretty easy to click through and get a nicely formatted HTML file. Could the publishable .m file replace the mlx files entirely? A user could quickly publish the .m file (or view the documentation) to see plots and comments in line, while also having the code readily accessible in a familiar format.

A publishable .m file would me a great end goal for all examples in this project, but yes we need to be cautious about past versions of MATLAB. On my current version of MATLAB (2024a) I am able to perform these conversions, but it would wise to verify this functionality across multiple versions. For now I think a reasonable strategy is to build new notebooks using Markup, but always render to .mlx and then html via right clicking on the .m file, clicking on "Open as Livescript" and then running and rendering that to html. I tried to automate this, but I was unsuccessful. Maybe matlab will support this conversion to mlx and html in future versions.

Screenshot 2025-01-27 at 6 07 22 PM

@akeeste akeeste self-requested a review January 28, 2025 16:27
Copy link

@akeeste akeeste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simmsa that sounds like a good plan. With those latest changes, this looks good to merge

@MShabara
Copy link

MShabara commented Jan 28, 2025

@simmsa I agree with @akeeste that the PR is ready to be merged.

@akeeste I have a couple of theory questions related to the calculate_normal function.
1-the cross section used is where the blade enters the cube. Why not the cross section at which the strain gauges are placed?
2- To my understanding is axial_strain_1 + axial_strain_2 are the measurements from the opposite sides of the cube, one is tension and the other is in compression, their sum should be close to zero. Why isn't it the case in the example?

@akeeste
Copy link

akeeste commented Jan 28, 2025

@MShabara
1 - The normal calculation is using the cross-section at the strain gauge (square with an internal hole). Is there somewhere in the text that contradicts this? If so it would be incorrect or unclear and should be updated.
2 - That is accurate and is intentional. calculate_normal averages the axial strain in the normal direction to remove the contribution of the bending moment on the normal force so that the normal force applied directly to the blade is isolated and returned. This normal force could be an intentional load on the blade or as a result of experimental set-up.
calculate_moment is similarly set-up to remove the contribution of a normal force to the bending moment at the root and isolate the perpendicular load on the blade tip

Maybe we could make this more clear by breaking out the calculations into, e.g.:

  • calculate_normal(strain, area, modulus)
  • average normals to isolate the effects of the normal load

similarly for the bending moment calculation.

@simmsa simmsa merged commit d8ba5b5 into MHKiT-Software:develop Jan 28, 2025
68 checks passed
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