From 2da2af60bae650319d05c1cd0738b3844eab30a3 Mon Sep 17 00:00:00 2001 From: Ankush Aggarwal Date: Thu, 22 Aug 2024 18:20:23 +0100 Subject: [PATCH 1/2] Added the check for disp_measure to be length for layered_uniax and layered_biax, also changed the warnings to errors to avoid these being misused --- pymecht/SampleExperiment.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pymecht/SampleExperiment.py b/pymecht/SampleExperiment.py index 46eba69..78a8541 100644 --- a/pymecht/SampleExperiment.py +++ b/pymecht/SampleExperiment.py @@ -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): ''' @@ -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): ''' From d8bc7612ef16bac4e5a2ab44a1e0062211d58c16 Mon Sep 17 00:00:00 2001 From: Ankush Aggarwal Date: Thu, 22 Aug 2024 18:23:05 +0100 Subject: [PATCH 2/2] Fixed the settings for layered tests --- Tests/test_examples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/test_examples.py b/Tests/test_examples.py index 395710a..3b7145f 100644 --- a/Tests/test_examples.py +++ b/Tests/test_examples.py @@ -73,7 +73,7 @@ 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 @@ -81,7 +81,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) - 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