Skip to content

Commit

Permalink
Merge pull request #20 from ankushaggarwal/name-change
Browse files Browse the repository at this point in the history
Changed UniformAxisymmetricTubeInflationExtension to TubeInflation
  • Loading branch information
ankushaggarwal authored Dec 12, 2023
2 parents 8f59a4d + ab317f5 commit 2d8b695
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
8 changes: 4 additions & 4 deletions Examples/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def validate_tube():
material = MatModel('goh','nh')
mm = material.models
mm[0].fiber_dirs = [np.array([0,cos(0.1),sin(0.1)]),np.array([0,cos(-0.1),sin(-0.1)])]
sample = UniformAxisymmetricTubeInflationExtension(material,force_measure='pressure')
sample = TubeInflation(material,force_measure='pressure')
force_sol = sample.force_controlled(np.array([-0.29167718]),sample.parameters)
print(force_sol)

Expand Down Expand Up @@ -106,7 +106,7 @@ def von_mises(sigma_list):
mm = material.models
mm[0].fiber_dirs = [np.array([0,cos(0.1),sin(0.1)]),np.array([0,cos(-0.1),sin(-0.1)])]

sample = UniformAxisymmetricTubeInflationExtension(material,force_measure='pressure')
sample = TubeInflation(material,force_measure='pressure')
params = sample.parameters
params['k1_0']=5.
params['k2_0']=15.
Expand All @@ -124,8 +124,8 @@ def von_mises(sigma_list):
plt.ylabel('von-Mises stress')
plt.show()

intima = UniformAxisymmetricTubeInflationExtension(material)
media = UniformAxisymmetricTubeInflationExtension(material)
intima = TubeInflation(material)
media = TubeInflation(material)
artery = LayeredTube(intima,media)
combined_parameters = artery.parameters
combined_parameters[0]['Ri']=1.0
Expand Down
4 changes: 2 additions & 2 deletions Examples/test2.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def DOEobs(npoints,theta):


mm[0].fiber_dirs = [np.array([0,cos(0.1),sin(0.1)]),np.array([0,cos(-0.1),sin(-0.1)])]
sample = UniformAxisymmetricTubeInflationExtension(material,force_measure='pressure')
sample = TubeInflation(material,force_measure='pressure')
print(sample.disp_controlled([1.1],sample.parameters))
print(sample.force_controlled(np.array([-0.29167718]),sample.parameters))

Expand All @@ -61,5 +61,5 @@ def DOEobs(npoints,theta):
print((result(l2)-result(l))*parameters['mu_1'])

#material = MatModel('nh')
sample = UniformAxisymmetricTubeInflationExtension(material,force_measure='pressure')
sample = TubeInflation(material,force_measure='pressure')
print(sample.disp_controlled([1.1],parameters))
2 changes: 1 addition & 1 deletion Examples/tube-model-prob.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def cal_output(params):
material = MatModel('yeoh')
mm = material.models

sample = UniformAxisymmetricTubeInflationExtension(material,force_measure='pressure')
sample = TubeInflation(material,force_measure='pressure')
#params = sample.parameters
Theta = RandomParameters(*sample.parameters_wbounds())
#Theta.add('phi',0.1,0,pi/2.,'uniform')
Expand Down
6 changes: 3 additions & 3 deletions Tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

mat_model_list = ['nh','yeoh','ls','mn','expI1','goh','Holzapfel','hgo','hy','volPenalty','polyI4','ArrudaBoyce','Gent','splineI1I4','StructModel']
samples_list = [UniaxialExtension,PlanarBiaxialExtension,UniformAxisymmetricTubeInflationExtension, LinearSpring]
samples_list = [UniaxialExtension,PlanarBiaxialExtension,TubeInflation, LinearSpring]

def test_mat_creation():
#Test creating all individual material models
Expand Down Expand Up @@ -89,7 +89,7 @@ def test_layered_samples():
assert sample.disp_controlled(sample._samples[0]._x0, sample.parameters) == pytest.approx(0.0)
assert sample.force_controlled(np.zeros_like(sample._samples[0]._x0), sample.parameters) == pytest.approx(sample._samples[0]._x0, 1e-3)

sample = LayeredTube(UniformAxisymmetricTubeInflationExtension(material),UniformAxisymmetricTubeInflationExtension(material))
sample = LayeredTube(TubeInflation(material),TubeInflation(material))
assert isinstance(sample, LayeredSamples)
assert len(sample._samples) == 2
assert sample._samples[0]._mat_model == material
Expand Down Expand Up @@ -160,4 +160,4 @@ def test_validate_tube():
# assert artery0Dmodel() == None

def test_randomex():
assert randomex() == None
assert randomex() == None
6 changes: 3 additions & 3 deletions docs/source/theory_tube.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=========================================================
UniformAxisymmetricTubeInflationExtension and LayeredTube
TubeInflation and LayeredTube
=========================================================


Expand Down Expand Up @@ -62,10 +62,10 @@ where :math:`\bar{\sigma}_{rr}(R)` is the Cauchy normal stress in the
(first) radial direction without the Lagrange multiplier term. Once
:math:`{p}(R)` is known, all components of stresse tensors at any radius
can be calculated using the usual definition of Cauchy stress via
:py:meth:`SampleExperiment.UniformAxisymmetricTubeInflationExtension.cauchy_stress`
:py:meth:`SampleExperiment.TubeInflation.cauchy_stress`
function.

:py:class:`UniformAxisymmetricTubeInflationExtension` samples can be “layered” via
:py:class:`TubeInflation` samples can be “layered” via
:py:class:`LayeredTube`. Such a setup can be used for representing, for example,
tissues that have multiple layers with different material models and
possibly even incompatible reference radius. The result would be that
Expand Down
33 changes: 18 additions & 15 deletions pymecht/SampleExperiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@ def _observe(self,stress):
return np.array([s1,s2])*self._thick
return np.array([s1,s2])

class UniformAxisymmetricTubeInflationExtension(SampleExperiment):
def UniformAxisymmetricTubeInflationExtension(*margs, **args):
raise ValueError("The name has changed from UniformAxisymmetricTubeInflationExtension to TubeInflation. Please use TubeInflation instead")

class TubeInflation(SampleExperiment):
'''
For simulating uniform axisymmetric inflation of a tube
Expand Down Expand Up @@ -528,10 +531,10 @@ def __init__(self,mat_model,disp_measure='radius',force_measure='force'):
warnings.warn("Even number of fiber families are expected. The results may be spurious")
for f in F:
if f[0]!=0:
warnings.warn("The UniformAxisymmetricTubeInflationExtension assumes that fibers are aligned in a helical direction. This is not satisfied and the results may be spurious.")
warnings.warn("The TubeInflation assumes that fibers are aligned in a helical direction. This is not satisfied and the results may be spurious.")
for f1, f2 in zip(*[iter(F)]*2):
if (f1+f2)[1] != 0. and (f1+f2)[2] != 0.:
warnings.warn("The UniformAxisymmetricTubeInflationExtension assumes that fibers are symmetric. This is not satisfied and the results may be spurious.")
warnings.warn("The TubeInflation assumes that fibers are symmetric. This is not satisfied and the results may be spurious.")
print(f1,f2)
self._compute = partial(self._mat_model.stress,stresstype='cauchy',incomp=False,Fdiag=True)
if self._inp == 'stretch':
Expand Down Expand Up @@ -936,21 +939,21 @@ class LayeredTube(LayeredSamples):
Parameters
----------
*samplesList: list of UniformAxisymmetricTubeInflationExtension
Any number of UniformAxisymmetricTubeInflationExtension objects constituting the layers
*samplesList: list of TubeInflation
Any number of TubeInflation objects constituting the layers
Examples
--------
>>> import pymecht as pmt
>>> mat_model = pmt.MatModel('nh')
>>> s1 = pmt.UniformAxisymmetricTubeInflationExtension(mat_model)
>>> s2 = pmt.UniformAxisymmetricTubeInflationExtension(mat_model)
>>> s3 = pmt.UniformAxisymmetricTubeInflationExtension(mat_model)
>>> s1 = pmt.TubeInflation(mat_model)
>>> s2 = pmt.TubeInflation(mat_model)
>>> s3 = pmt.TubeInflation(mat_model)
>>> layered_sample = pmt.LayeredPlanarBiaxial(s1,s2,s3)
'''
def __init__(self,*samplesList):
super().__init__(*samplesList)
if not all([isinstance(s,UniformAxisymmetricTubeInflationExtension) or isinstance(s,LinearSpring) for s in self._samples]):
if not all([isinstance(s,TubeInflation) or isinstance(s,LinearSpring) for s in self._samples]):
raise ValueError("The class only accepts objects of type SampleExperiment")
for i,s in enumerate(samplesList):
if i==0:
Expand Down Expand Up @@ -1064,7 +1067,7 @@ def specify_single_fiber(sample,angle=0, degrees=True, verbose=True):
for UniaxialExtension or PlanarBiaxialExtension
with respect to the x-axis and in the xy plane
for UniformAxisymmetricTubeInflationExtension
for TubeInflation
with respect to the theta-axis and in the theta-z plane
degrees: bool
Expand All @@ -1077,12 +1080,12 @@ def specify_single_fiber(sample,angle=0, degrees=True, verbose=True):
if degrees:
angle_rad = np.deg2rad(angle)
models = sample._mat_model.models
if isinstance(sample,UniformAxisymmetricTubeInflationExtension):
if isinstance(sample,TubeInflation):
vec = np.array([0,np.cos(angle_rad), np.sin(angle_rad)])
elif isinstance(sample,PlanarBiaxialExtension) or isinstance(sample,UniaxialExtension):
vec = np.array([np.cos(angle_rad), np.sin(angle_rad),0])
else:
raise ValueError("The helper function is only implemented for UniaxialExtension, PlanarBiaxialExtension, and UniformAxisymmetricTubeInflationExtension")
raise ValueError("The helper function is only implemented for UniaxialExtension, PlanarBiaxialExtension, and TubeInflation")
for m in models:
m.fiber_dirs = vec
if verbose:
Expand All @@ -1104,7 +1107,7 @@ def specify_two_fibers(sample,angle, degrees = True, verbose=True):
for UniaxialExtension or PlanarBiaxialExtension
with respect to the x-axis and in the xy plane
for UniformAxisymmetricTubeInflationExtension
for TubeInflation
with respect to the theta-axis and in the theta-z plane
degrees: bool
Expand All @@ -1117,12 +1120,12 @@ def specify_two_fibers(sample,angle, degrees = True, verbose=True):
if degrees:
angle_rad = np.deg2rad(angle)
models = sample._mat_model.models
if isinstance(sample,UniformAxisymmetricTubeInflationExtension):
if isinstance(sample,TubeInflation):
vec = [np.array([0,np.cos(angle_rad), np.sin(angle_rad)]), np.array([0,np.cos(-angle_rad), np.sin(-angle_rad)])]
elif isinstance(sample,PlanarBiaxialExtension) or isinstance(sample,UniaxialExtension):
vec = [np.array([np.cos(angle_rad), np.sin(angle_rad),0]), np.array([np.cos(-angle_rad), np.sin(-angle_rad),0])]
else:
raise ValueError("The helper function is only implemented for UniaxialExtension, PlanarBiaxialExtension, and UniformAxisymmetricTubeInflationExtension")
raise ValueError("The helper function is only implemented for UniaxialExtension, PlanarBiaxialExtension, and TubeInflation")
for m in models:
m.fiber_dirs = vec
if verbose:
Expand Down

0 comments on commit 2d8b695

Please sign in to comment.