Skip to content

Commit

Permalink
Merge pull request #35 from ankushaggarwal/warnings-update
Browse files Browse the repository at this point in the history
Warnings update
  • Loading branch information
ankushaggarwal authored Aug 23, 2024
2 parents 1b9f41d + d8bc761 commit 4c75a9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ def test_layered_samples():
material = MatModel('goh','nh')
mm = material.models
mm[0].fiber_dirs = [np.array([cos(0.),sin(0.),0])]
sample = LayeredUniaxial(UniaxialExtension(material),UniaxialExtension(material))
sample = LayeredUniaxial(UniaxialExtension(material, disp_measure='length', force_measure='force'),UniaxialExtension(material,disp_measure='length', force_measure='force'))
assert isinstance(sample, LayeredSamples)
assert len(sample._samples) == 2
assert sample._samples[0]._mat_model == material
assert sample._samples[1]._mat_model == material
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)

sample = LayeredPlanarBiaxial(PlanarBiaxialExtension(material,force_measure='force'),PlanarBiaxialExtension(material,force_measure='force'))
sample = LayeredPlanarBiaxial(PlanarBiaxialExtension(material,disp_measure='length',force_measure='force'),PlanarBiaxialExtension(material,disp_measure='length',force_measure='force'))
assert isinstance(sample, LayeredSamples)
assert len(sample._samples) == 2
assert sample._samples[0]._mat_model == material
Expand Down
8 changes: 6 additions & 2 deletions pymecht/SampleExperiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,10 @@ def __init__(self,*samplesList):
super().__init__(*samplesList)
if not all([isinstance(s,UniaxialExtension) for s in self._samples]):
raise ValueError("The class only accepts objects of type UniaxialExtension")
if self._inp != 'length':
raise ValueError("The input of all layers in LayeredUniaxial should be length to remove ambiguity about the reference length")
if self._output != 'force':
warnings.warn("The output of the LayeredUniaxial should be force, as stresses are not additive. The results may be spurious")
raise ValueError("The output of the LayeredUniaxial should be force, as stresses are not additive. The results may be spurious")

class LayeredPlanarBiaxial(LayeredSamples):
'''
Expand All @@ -929,8 +931,10 @@ def __init__(self,*samplesList):
super().__init__(*samplesList)
if not all([isinstance(s,PlanarBiaxialExtension) for s in self._samples]):
raise ValueError("The class only accepts objects of type PlanarBiaxialExtension")
if self._inp != 'length':
raise ValueError("The input of all layers in LayeredPlanarBiaxial should be length to remove ambiguity about the reference length")
if self._output != 'force':
warnings.warn("The output of the LayeredPlanarBiaxial should be force, as stresses are not additive. The results may be spurious")
raise ValueError("The output of the LayeredPlanarBiaxial should be force, as stresses are not additive. The results may be spurious")

class LayeredTube(LayeredSamples):
'''
Expand Down

0 comments on commit 4c75a9e

Please sign in to comment.