Adding an attribute to a material

Asked by Roxana Saghafian Larijani

 I added the 'eta' attribute in ViscolasticCapillarPM (hpp. and cpp.) just like the way for example gamma was introduced in the code, then I tried to run my code containing eta as an input (just like gamma or en or...) as below:

mat=O.materials.append(
        ViscElCapMat(frictionAngle=fr, density=rho, poisson=poi, young= yoM, Vb=vB, gamma=Gamma, eta=Eta, theta=Theta, Capillar=True, ...)

but it gives me the error:
No such attribute: eta.

​So I think I have to introduce this attribute also in another place where the ViscElCapMat is introduced but I could not find it. Could you please help me with this?

Regards,
Roxana Saghafian

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Robert Caulk (rcaulk) said :
#1

Hey Roxana,

You would need to add eta to this line of the ViscElCapMat class:

https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/ViscoelasticCapillarPM.hpp#L21

Then it should be accessible elsewhere in c++ and python.

Let me know if it helps,

Robert

Revision history for this message
Roxana Saghafian Larijani (r-saghafian) said :
#2

Hi Robert,

Thanks for yours response. However, I had already added the line you mentioned in the .hpp file but got the error:(

Regards,
Roxana Saghafian

Revision history for this message
Karol Brzezinski (kbrzezinski) said :
#3

Hi Roxana,

could you please tell us a little bit more about your workflow?

I did exactly as Robert said. Next, I compiled the code and launched the yade from the install location. I added the material:

> mat=O.materials.append( ViscElCapMat(eta =10) )

And it has the property, which I can verify by:

> O.materials[mat].eta

Please note that 'mat' is now just a material id. Hence, if you run
> O.materials[mat].eta
you can get information that 'int' object has no attribute 'eta'.

Cheers,
Karol

Revision history for this message
Robert Caulk (rcaulk) said :
#4

>> Thanks for yours response. However, I had already added the line you mentioned in the .hpp file but got the error:(

Can you provide the full error message?

Thank you,

robert

Revision history for this message
Roxana Saghafian Larijani (r-saghafian) said :
#5

This is the full error:

Running script eta.py
Traceback (most recent call last):
  File "../yade-2022-03-05.git-656906f", line 343, in runScript
    execfile(script,globals())
  File "/usr/lib/python3/dist-packages/past/builtins/misc.py", line 87, in execfile
    exec_(code, myglobals, mylocals)
  File "eta.py", line 51, in <module>
    ViscElCapMat(frictionAngle=fr, density=rho, poisson=poi, young= yoM, Vb=vB, gamma=Gamma, eta=Eta, theta=Theta, Capillar=True, CapillarType=CapType, tc=Tc, en=En, et=Et)
AttributeError: No such attribute: eta.
[[ ^L clears screen, ^U kills line. F8 plot. ]]

Regards,
Roxana Saghafian

Revision history for this message
Roxana Saghafian Larijani (r-saghafian) said :
#6

Hi Karol,
Thank you for your response. I added eta just like the way gamma is defined in cpp and hpp files of viscoelasticCapillarPM. Then I used it in
VisForceCoefficient= ((3/2)* M_PI * phys.eta * pow(phys.R,2))/(delta);
then I recompiled and tried to define a material in my script with a specific eta as ViscElCapMat(frictionAngle=fr, density=rho, poisson=poi, young= yoM, Vb=vB, gamma=Gamma, eta=Eta, theta=Theta, Capillar=True, ...)

But I received the error.

Regards,
Roxana Saghfian

Revision history for this message
Robert Caulk (rcaulk) said :
#7

Hey Roxana,

Seems you may be using the incorrect executable file. Please copy and paste the final 20-30 lines of your compiler output here.

Cheers,

Robert

Revision history for this message
Roxana Saghafian Larijani (r-saghafian) said :
#8

Hi Robert,
please find it below:

Scanning dependencies of target _gts

[ 66%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/cleanup.cpp.o

[ 66%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/edge.cpp.o

[ 66%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/face.cpp.o

[ 67%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/object.cpp.o

[ 67%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/point.cpp.o

[ 68%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/pygts.cpp.o

[ 68%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/segment.cpp.o

[ 68%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/surface.cpp.o

[ 69%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/triangle.cpp.o

[ 69%] Building CXX object py/CMakeFiles/_gts.dir/3rd-party/pygts-0.3.1/vertex.cpp.o

[ 70%] Linking CXX shared library lib/x86_64-linux-gnu/_gts.so

[ 70%] Built target _gts

[ 71%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity.cpp.o

Scanning dependencies of target _libVersions

[ 71%] Building CXX object py/CMakeFiles/_libVersions.dir/_libVersions.cpp.o

[ 71%] Linking CXX shared library lib/x86_64-linux-gnu/_libVersions.so

[ 71%] Built target _libVersions

[ 71%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/Law2_ScGeom_CapillaryPhys_Capillarity1.cpp.o

Scanning dependencies of target _polyhedra_utils

[ 71%] Building CXX object py/CMakeFiles/_polyhedra_utils.dir/_polyhedra_utils.cpp.o

In file included from /usr/include/python3.8/numpy/ndarraytypes.h:1830,

                 from /home/Roxana/trunk/py/_polyhedra_utils.cpp:15:

/usr/include/python3.8/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

   17 | #warning "Using deprecated NumPy API, disable it with " \

      | ^~~~~~~

[ 71%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/Lubrication.cpp.o

[ 72%] Linking CXX shared library lib/x86_64-linux-gnu/_polyhedra_utils.so

[ 72%] Built target _polyhedra_utils

[ 73%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/LubricationWithPotential.cpp.o

Scanning dependencies of target _packObb

[ 74%] Building CXX object py/CMakeFiles/_packObb.dir/pack/_packObb.cpp.o

[ 74%] Linking CXX shared library lib/x86_64-linux-gnu/_packObb.so

[ 74%] Built target _packObb

Scanning dependencies of target _log

[ 75%] Building CXX object py/CMakeFiles/_log.dir/_log.cpp.o

[ 75%] Linking CXX shared library lib/x86_64-linux-gnu/_log.so

[ 75%] Built target _log

[ 75%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/LudingPM.cpp.o

Scanning dependencies of target _minieigenHP

[ 76%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_minieigenHP.cpp.o

[ 76%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeBoxes.cpp.o

[ 77%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/MeasureCapStress.cpp.o

[ 77%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeComplex1.cpp.o

[ 78%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeComplex2.cpp.o

[ 78%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/MicroMacroAnalyser.cpp.o

[ 78%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeConverters.cpp.o

[ 79%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeMatrices1.cpp.o

[ 79%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeMatrices2.cpp.o

[ 79%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/MortarMat.cpp.o

[ 79%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeQuaternion.cpp.o

[ 80%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeStorageOrdering.cpp.o

[ 81%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/NewtonIntegrator.cpp.o

[ 81%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeVectors1.cpp.o

[ 82%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_ExposeVectors2.cpp.o

[ 82%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/PDFEngine.cpp.o

[ 82%] Building CXX object py/CMakeFiles/_minieigenHP.dir/high-precision/_RealHPDiagnostics.cpp.o

[ 82%] Linking CXX shared library lib/x86_64-linux-gnu/_minieigenHP.so

[ 82%] Built target _minieigenHP

Scanning dependencies of target _packPredicates

[ 83%] Building CXX object py/CMakeFiles/_packPredicates.dir/pack/_packPredicates.cpp.o

[ 84%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/PeriIsoCompressor.cpp.o

[ 84%] Linking CXX shared library lib/x86_64-linux-gnu/_packPredicates.so

[ 84%] Built target _packPredicates

[ 84%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/RungeKuttaCashKarp54Integrator.cpp.o

Scanning dependencies of target _math

[ 85%] Building CXX object py/CMakeFiles/_math.dir/high-precision/_math.cpp.o

[ 85%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/STLImporter.cpp.o

[ 86%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/SampleCapillaryPressureEngine.cpp.o

[ 86%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/ScGeom.cpp.o

[ 86%] Building CXX object py/CMakeFiles/_math.dir/high-precision/_ExposeStorageOrdering.cpp.o

[ 86%] Linking CXX shared library lib/x86_64-linux-gnu/_math.so

[ 86%] Built target _math

Scanning dependencies of target WeightedAverage2d

[ 86%] Building CXX object py/CMakeFiles/WeightedAverage2d.dir/WeightedAverage2d.cpp.o

[ 86%] Linking CXX shared library lib/x86_64-linux-gnu/WeightedAverage2d.so

[ 86%] Built target WeightedAverage2d

Scanning dependencies of target _utils

[ 86%] Building CXX object py/CMakeFiles/_utils.dir/_utils.cpp.o

[ 86%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/SpheresFactory.cpp.o

In file included from /usr/include/python3.8/numpy/ndarraytypes.h:1830,

                 from /usr/include/python3.8/numpy/ndarrayobject.h:12,

                 from /usr/include/python3.8/numpy/arrayobject.h:4,

                 from /home/Roxana/trunk/py/_utils.cpp:13:

/usr/include/python3.8/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

   17 | #warning "Using deprecated NumPy API, disable it with " \

      | ^~~~~~~

[ 87%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/TesselationWrapper.cpp.o

In file included from /usr/include/python3.8/numpy/ndarraytypes.h:1830,

                 from /usr/include/python3.8/numpy/ndarrayobject.h:12,

                 from /usr/include/python3.8/numpy/arrayobject.h:4,

                 from /home/Roxana/trunk/lib/pyutil/numpy_boost.hpp:45,

                 from /home/Roxana/trunk/pkg/dem/TesselationWrapper.cpp:23:

/usr/include/python3.8/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

   17 | #warning "Using deprecated NumPy API, disable it with " \

      | ^~~~~~~

[ 87%] Linking CXX shared library lib/x86_64-linux-gnu/_utils.so

[ 87%] Built target _utils

Scanning dependencies of target _packSpheres

[ 87%] Building CXX object py/CMakeFiles/_packSpheres.dir/pack/_packSpheres.cpp.o

[ 88%] Linking CXX shared library lib/x86_64-linux-gnu/_packSpheres.so

[ 88%] Built target _packSpheres

Scanning dependencies of target wrapper

[ 88%] Building CXX object py/CMakeFiles/wrapper.dir/wrapper/yadeWrapper.cpp.o

[ 88%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/Tetra.cpp.o

[ 89%] Linking CXX shared library lib/x86_64-linux-gnu/wrapper.so

[ 89%] Built target wrapper

Scanning dependencies of target _customConverters

[ 90%] Building CXX object py/CMakeFiles/_customConverters.dir/wrapper/customConverters.cpp.o

[ 91%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/ThreeDTriaxialEngine.cpp.o

[ 91%] Linking CXX shared library lib/x86_64-linux-gnu/_customConverters.so

[ 91%] Built target _customConverters

[ 91%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/TriaxialCompressionEngine.cpp.o

Scanning dependencies of target _GLViewer

[ 92%] Building CXX object gui/CMakeFiles/_GLViewer.dir/_GLViewer_autogen/mocs_compilation.cpp.o

[ 92%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/TriaxialStateRecorder.cpp.o

[ 92%] Building CXX object gui/CMakeFiles/_GLViewer.dir/qt5/GLViewer.cpp.o

[ 93%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/TriaxialStressController.cpp.o

[ 93%] Building CXX object gui/CMakeFiles/_GLViewer.dir/qt5/_GLViewer.cpp.o

[ 94%] Building CXX object gui/CMakeFiles/_GLViewer.dir/qt5/OpenGLManager.cpp.o

[ 94%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/UnbalancedForceCallbacks.cpp.o

[ 94%] Building CXX object gui/CMakeFiles/_GLViewer.dir/qt5/GLViewerDisplay.cpp.o

[ 95%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/UniaxialStrainer.cpp.o

[ 95%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/ViscoelasticCapillarPM.cpp.o

[ 96%] Building CXX object gui/CMakeFiles/_GLViewer.dir/qt5/GLViewerMouse.cpp.o

In file included from /home/Roxana/trunk/pkg/dem/ViscoelasticCapillarPM.cpp:1:

/home/Roxana/trunk/pkg/dem/ViscoelasticCapillarPM.hpp: In member function 'virtual void yade::Law2_ScGeom_ViscElCapPhys_Basic::pySetAttr(const string&, const boost::python::api::object&)':

/home/Roxana/trunk/pkg/dem/ViscoelasticCapillarPM.hpp:91:1254: warning: '*((void*)&<anonymous> +32)' may be used uninitialized in this function [-Wmaybe-uninitialized]

   91 | YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Law2_ScGeom_ViscElCapPhys_Basic,LawFunctor,"Extended version of Linear viscoelastic model with capillary parameters.",

      | ^

/home/Roxana/trunk/pkg/dem/ViscoelasticCapillarPM.hpp:91:1356: warning: '*((void*)&<anonymous> +32)' may be used uninitialized in this function [-Wmaybe-uninitialized]

   91 | YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Law2_ScGeom_ViscElCapPhys_Basic,LawFunctor,"Extended version of Linear viscoelastic model with capillary parameters.",

      | ^

[ 96%] Linking CXX shared library lib/x86_64-linux-gnu/_GLViewer.so

[ 96%] Built target _GLViewer

[ 96%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/ViscoelasticPM.cpp.o

[ 97%] Building CXX object CMakeFiles/pkg_dem.dir/pkg/dem/WirePM.cpp.o

[ 97%] Linking CXX shared library lib/x86_64-linux-gnu/libpkg_dem.so

[ 99%] Built target pkg_dem

Scanning dependencies of target boot

[ 99%] Building CXX object CMakeFiles/boot.dir/core/main/pyboot.cpp.o

[100%] Linking CXX shared library lib/x86_64-linux-gnu/boot.so

[100%] Built target boot

Regards,
Roxana Saghafian

________________________________
From: <email address hidden> <email address hidden> on behalf of Robert Caulk <email address hidden>
Sent: Wednesday, June 29, 2022 12:01 PM
To: Saghafian Larijani, Roxana (UT-ET) <email address hidden>
Subject: Re: [Question #702276]: Adding an attribute to a material

Your question #702276 on Yade changed:
https://answers.launchpad.net/yade/+question/702276

    Status: Open => Needs information

Robert Caulk requested more information:
Hey Roxana,

Seems you may be using the incorrect executable file. Please copy and
paste the final 20-30 lines of your compiler output here.

Cheers,

Robert

--
To answer this request for more information, you can either reply to
this email or enter your reply at the following page:
https://answers.launchpad.net/yade/+question/702276

You received this question notification because you asked the question.

Revision history for this message
Robert Caulk (rcaulk) said :
#9

Hello, these are not the final lines of installation. Please attach the final lines of make install

Thank you,

Robert

Revision history for this message
Roxana Saghafian Larijani (r-saghafian) said :
#10

Hi Robert,

I figured out the problem was because of the skew clock of my docker, and it is solved now!
Thank you!

Regards,
Roxana

________________________________
From: <email address hidden> <email address hidden> on behalf of Robert Caulk <email address hidden>
Sent: Friday, July 1, 2022 1:11 PM
To: Saghafian Larijani, Roxana (UT-ET) <email address hidden>
Subject: Re: [Question #702276]: Adding an attribute to a material

Your question #702276 on Yade changed:
https://answers.launchpad.net/yade/+question/702276

    Status: Open => Needs information

Robert Caulk requested more information:
Hello, these are not the final lines of installation. Please attach the
final lines of make install

Thank you,

Robert

--
To answer this request for more information, you can either reply to
this email or enter your reply at the following page:
https://answers.launchpad.net/yade/+question/702276

You received this question notification because you asked the question.

Revision history for this message
Robert Caulk (rcaulk) said (last edit ):
#11

User solved question.