-
Notifications
You must be signed in to change notification settings - Fork 111
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
Dev poisson ratio warning #26
Changes from 1 commit
52a0bcc
90d94a1
c44951f
2d3653b
9718e6c
5fd7c85
cd81c90
0e25e24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
__doc__ = """ Factory function to allocate variables for Cosserat Rod""" | ||
__all__ = ["allocate"] | ||
import warnings | ||
import numpy as np | ||
from numpy.testing import assert_allclose | ||
|
||
from elastica.utils import MaxDimension, Tolerance | ||
|
||
from elastica._linalg import _batch_cross, _batch_norm, _batch_dot | ||
|
||
|
||
|
@@ -18,8 +17,8 @@ def allocate( | |
density, | ||
nu, | ||
youngs_modulus, | ||
poisson_ratio, | ||
alpha_c=4.0 / 3.0, | ||
# poisson_ratio, | ||
# alpha_c=4.0 / 3.0, | ||
*args, | ||
**kwargs | ||
): | ||
|
@@ -216,7 +215,43 @@ def allocate( | |
) | ||
|
||
# Shear/Stretch matrix | ||
shear_modulus = youngs_modulus / (poisson_ratio + 1.0) | ||
if kwargs.__contains__("shear_modulus"): | ||
shear_modulus = kwargs.get("shear_modulus") | ||
if kwargs.__contains__("poisson_ratio"): | ||
poisson_ratio = kwargs.get("poisson_ratio") | ||
message = ( | ||
" Poisson ratio ( " | ||
+ str(poisson_ratio) | ||
+ " ) given in kwargs is not used. \n" | ||
+ "Since shear modulus ( " | ||
+ str(shear_modulus) | ||
+ " ) is given in kwargs. \n" | ||
) | ||
warnings.warn(message, category=UserWarning) | ||
else: | ||
if kwargs.__contains__("poisson_ratio"): | ||
poisson_ratio = kwargs.get("poisson_ratio") | ||
else: | ||
message = "Shear modulus or poisson ratio cannot be found in kwargs. Poisson ratio is taken as 0.5" | ||
warnings.warn(message, category=UserWarning) | ||
poisson_ratio = 0.5 | ||
|
||
shear_modulus = youngs_modulus / (poisson_ratio + 1.0) | ||
|
||
message = ( | ||
"Shear modulus cannot be found in kwargs. \n" | ||
"Poisson ratio " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest the warning being: |
||
+ str(poisson_ratio) | ||
+ " is used to compute shear modulus " | ||
+ str(shear_modulus) | ||
+ ", " | ||
"using the equation: shear_modulus = youngs_modulus / (poisson_ratio + 1.0)" | ||
) | ||
|
||
warnings.warn(message, category=UserWarning) | ||
|
||
alpha_c = kwargs.get("alpha_c", 4.0 / 3.0) | ||
|
||
shear_matrix = np.zeros( | ||
(MaxDimension.value(), MaxDimension.value(), n_elements), np.float64 | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest:
"Both a Poisson ratio and a shear modulus are provided. The Poisson ratio is only used to compute a shear modulus so the provided Poisson ratio of ( "+ str(poisson_ratio)+ " ) is being ignored in favor of the provided shear modulus ( "+ str(shear_modulus)+ " ) \n"