Re: [Yade-dev] : Add damping coefficient to material
On 23/01/12 00:12, Klaus Thoeni wrote: Hi Bruno, hi Anton, I think density scaling is not what I am looking for since I am interested in real dynamic simulations. I need different damping parameters in NewtonIntegrator for the block and the mesh. I have to consider free flight under gravity so damping=0 (and I am interested in the real flight time). For the mesh I have to consider additional energy absorption which is not considered in my model via damping. If you are not after any density scaling, why damping in NewtonIntegrator should be acceptable in a realistic dynamic situation? Would not be easier/more meaningful for you to implement damping inside your contact model? Sorry, just curious. Chiara It is similar to b_damp() in PFC which is used to remove damping for certain particle. I implemented it the same way now. The state has a member which is true by default which means that damping is used. It can be set to false and damping=0 will be used for this particle. So basically damping in NewtonIntegrator can be activated and deactivated for individual particles. @Anton: It has to be checked for all particles. Here is the diff of my latest implementation, tell me what you think: === modified file core/State.hpp --- core/State.hpp 2011-02-14 08:05:09 + +++ core/State.hpp 2012-01-22 23:56:31 + @@ -59,7 +59,8 @@ ((Vector3r,inertia,Vector3r::Zero(),,Inertia of associated body, in local coordinate system.)) ((Vector3r,refPos,Vector3r::Zero(),,Reference position)) ((Quaternionr,refOri,Quaternionr::Identity(),,Reference orientation)) - ((unsigned,blockedDOFs,,,[Will be overridden])), + ((unsigned,blockedDOFs,,,[Will be overridden])) + ((bool,isDamped,true,,Damping in :yref:`Newtonintegrator` can be deactivated for individual particles by setting this variable to FALSE. E.g. damping is inappropriate for particles in free flight under gravity but it might still be applicable to other particles in the same simulation.)), /* additional initializers */ ((pos,se3.position)) ((ori,se3.orientation)), === modified file pkg/dem/NewtonIntegrator.cpp --- pkg/dem/NewtonIntegrator.cpp2011-11-30 17:39:33 + +++ pkg/dem/NewtonIntegrator.cpp2012-01-22 23:56:31 + @@ -11,17 +11,18 @@ #includeyade/pkg/dem/Clump.hpp #includeyade/pkg/common/VelocityBins.hpp #includeyade/lib/base/Math.hpp YADE_PLUGIN((NewtonIntegrator)); CREATE_LOGGER(NewtonIntegrator); // 1st order numerical damping -void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel){ - for(int i=0; i3; i++) force[i]*=1-damping*Mathr::Sign(force[i]*vel[i]); +void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel, const Real dampcoeff){ + for(int i=0; i3; i++) force[i]*=1-dampcoeff*Mathr::Sign(force[i]*vel[i]); } // 2nd order numerical damping -void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel){ - for(int i=0; i3; i++) accel[i]*= 1 - damping*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); +void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel, const Real dampcoeff){ + for(int i=0; i3; i++) accel[i]*= 1 - dampcoeff*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); } Vector3r NewtonIntegrator::computeAccel(const Vector3r force, const Real mass, int blockedDOFs){ @@ -39,11 +40,13 @@ void NewtonIntegrator::updateEnergy(const shared_ptrBody b, const State* state, const Vector3r fluctVel, const Vector3r f, const Vector3r m){ assert(b-isStandalone() || b-isClump()); - // always positive dissipation, by-component: |F_i|*|v_i|*damping*dt (| T_i|*|ω_i|*damping*dt for rotations) - if(damping!=0.){ - scene-energy- add(fluctVel.cwise().abs().dot(f.cwise().abs())*damping*scene- dt,nonviscDamp,nonviscDampIx,/*non-incremental*/false); + // check if damping for this body is activated + Real dampcoeff=(state-isDamped ? damping : 0); + // always positive dissipation, by-component: |F_i|*|v_i|*dampcoeff*dt (| T_i|*|ω_i|*dampcoeff*dt for rotations) + if(dampcoeff!=0.){ + scene-energy- add(fluctVel.cwise().abs().dot(f.cwise().abs())*dampcoeff*scene- dt,nonviscDamp,nonviscDampIx,/*non-incremental*/false); // when the aspherical integrator is used, torque is damped instead of ang acceleration; this code is only approximate - scene-energy-add(state- angVel.cwise().abs().dot(m.cwise().abs())*damping*scene- dt,nonviscDamp,nonviscDampIx,false); + scene-energy-add(state- angVel.cwise().abs().dot(m.cwise().abs())*dampcoeff*scene- dt,nonviscDamp,nonviscDampIx,false); } // kinetic energy Real
Re: [Yade-dev] : Add damping coefficient to material
Hi Chiara, thanks for your comment. I am not after viscous damping either. But I think the current implementation does exactly what I want, it's the same as the PFC option b_damp(). So I can deactivate the damping coefficient for individual bodies. I can commit the code if anyone is interested , after the diff has been approved ;-) Klaus On Mon, 23 Jan 2012 08:44:02 PM Chiara wrote: On 23/01/12 00:12, Klaus Thoeni wrote: Hi Bruno, hi Anton, I think density scaling is not what I am looking for since I am interested in real dynamic simulations. I need different damping parameters in NewtonIntegrator for the block and the mesh. I have to consider free flight under gravity so damping=0 (and I am interested in the real flight time). For the mesh I have to consider additional energy absorption which is not considered in my model via damping. If you are not after any density scaling, why damping in NewtonIntegrator should be acceptable in a realistic dynamic situation? Would not be easier/more meaningful for you to implement damping inside your contact model? Sorry, just curious. Chiara It is similar to b_damp() in PFC which is used to remove damping for certain particle. I implemented it the same way now. The state has a member which is true by default which means that damping is used. It can be set to false and damping=0 will be used for this particle. So basically damping in NewtonIntegrator can be activated and deactivated for individual particles. @Anton: It has to be checked for all particles. Here is the diff of my latest implementation, tell me what you think: === modified file core/State.hpp --- core/State.hpp 2011-02-14 08:05:09 + +++ core/State.hpp 2012-01-22 23:56:31 + @@ -59,7 +59,8 @@ ((Vector3r,inertia,Vector3r::Zero(),,Inertia of associated body, in local coordinate system.)) ((Vector3r,refPos,Vector3r::Zero(),,Reference position)) ((Quaternionr,refOri,Quaternionr::Identity(),,Reference orientation)) - ((unsigned,blockedDOFs,,,[Will be overridden])), + ((unsigned,blockedDOFs,,,[Will be overridden])) + ((bool,isDamped,true,,Damping in :yref:`Newtonintegrator` can be deactivated for individual particles by setting this variable to FALSE. E.g. damping is inappropriate for particles in free flight under gravity but it might still be applicable to other particles in the same simulation.)), /* additional initializers */ ((pos,se3.position)) ((ori,se3.orientation)), === modified file pkg/dem/NewtonIntegrator.cpp --- pkg/dem/NewtonIntegrator.cpp2011-11-30 17:39:33 + +++ pkg/dem/NewtonIntegrator.cpp2012-01-22 23:56:31 + @@ -11,17 +11,18 @@ #includeyade/pkg/dem/Clump.hpp #includeyade/pkg/common/VelocityBins.hpp #includeyade/lib/base/Math.hpp YADE_PLUGIN((NewtonIntegrator)); CREATE_LOGGER(NewtonIntegrator); // 1st order numerical damping -void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel){ - for(int i=0; i3; i++) force[i]*=1-damping*Mathr::Sign(force[i]*vel[i]); +void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel, const Real dampcoeff){ + for(int i=0; i3; i++) force[i]*=1-dampcoeff*Mathr::Sign(force[i]*vel[i]); } // 2nd order numerical damping -void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel){ - for(int i=0; i3; i++) accel[i]*= 1 - damping*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); +void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel, const Real dampcoeff){ + for(int i=0; i3; i++) accel[i]*= 1 - dampcoeff*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); } Vector3r NewtonIntegrator::computeAccel(const Vector3r force, const Real mass, int blockedDOFs){ @@ -39,11 +40,13 @@ void NewtonIntegrator::updateEnergy(const shared_ptrBody b, const State* state, const Vector3r fluctVel, const Vector3r f, const Vector3r m){ assert(b-isStandalone() || b-isClump()); - // always positive dissipation, by-component: |F_i|*|v_i|*damping*dt (| T_i|*|ω_i|*damping*dt for rotations) - if(damping!=0.){ - scene-energy- add(fluctVel.cwise().abs().dot(f.cwise().abs())*damping*scene- dt,nonviscDamp,nonviscDampIx,/*non-incremental*/false); + // check if damping for this body is activated + Real dampcoeff=(state-isDamped ? damping : 0); + // always positive dissipation, by-component: |F_i|*|v_i|*dampcoeff*dt (| T_i|*|ω_i|*dampcoeff*dt for rotations) + if(dampcoeff!=0.){ + scene-energy-
Re: [Yade-dev] : Add damping coefficient to material
Ok, I understand. I like your diff more than the previous one. :) Still one suggestion: this additional parameter in the damping functions is useless: + cundallDamp2nd(dt,m,state-angVel,angAccel,dampcoeff); In your code, dampCoeff will be either Newton::damping or zero. So, it would be better to just write this, avoiding the function call and additional parameter: if (state-isDamped) cundallDamp2nd(dt,m,state-angVel,angAccel) Then I agree to commit. Bruno On 23/01/12 11:48, Klaus Thoeni wrote: Hi Chiara, thanks for your comment. I am not after viscous damping either. But I think the current implementation does exactly what I want, it's the same as the PFC option b_damp(). So I can deactivate the damping coefficient for individual bodies. I can commit the code if anyone is interested , after the diff has been approved ;-) Klaus On Mon, 23 Jan 2012 08:44:02 PM Chiara wrote: On 23/01/12 00:12, Klaus Thoeni wrote: Hi Bruno, hi Anton, I think density scaling is not what I am looking for since I am interested in real dynamic simulations. I need different damping parameters in NewtonIntegrator for the block and the mesh. I have to consider free flight under gravity so damping=0 (and I am interested in the real flight time). For the mesh I have to consider additional energy absorption which is not considered in my model via damping. If you are not after any density scaling, why damping in NewtonIntegrator should be acceptable in a realistic dynamic situation? Would not be easier/more meaningful for you to implement damping inside your contact model? Sorry, just curious. Chiara It is similar to b_damp() in PFC which is used to remove damping for certain particle. I implemented it the same way now. The state has a member which is true by default which means that damping is used. It can be set to false and damping=0 will be used for this particle. So basically damping in NewtonIntegrator can be activated and deactivated for individual particles. @Anton: It has to be checked for all particles. Here is the diff of my latest implementation, tell me what you think: === modified file core/State.hpp --- core/State.hpp 2011-02-14 08:05:09 + +++ core/State.hpp 2012-01-22 23:56:31 + @@ -59,7 +59,8 @@ ((Vector3r,inertia,Vector3r::Zero(),,Inertia of associated body, in local coordinate system.)) ((Vector3r,refPos,Vector3r::Zero(),,Reference position)) ((Quaternionr,refOri,Quaternionr::Identity(),,Reference orientation)) - ((unsigned,blockedDOFs,,,[Will be overridden])), + ((unsigned,blockedDOFs,,,[Will be overridden])) + ((bool,isDamped,true,,Damping in :yref:`Newtonintegrator` can be deactivated for individual particles by setting this variable to FALSE. E.g. damping is inappropriate for particles in free flight under gravity but it might still be applicable to other particles in the same simulation.)), /* additional initializers */ ((pos,se3.position)) ((ori,se3.orientation)), === modified file pkg/dem/NewtonIntegrator.cpp --- pkg/dem/NewtonIntegrator.cpp2011-11-30 17:39:33 + +++ pkg/dem/NewtonIntegrator.cpp2012-01-22 23:56:31 + @@ -11,17 +11,18 @@ #includeyade/pkg/dem/Clump.hpp #includeyade/pkg/common/VelocityBins.hpp #includeyade/lib/base/Math.hpp YADE_PLUGIN((NewtonIntegrator)); CREATE_LOGGER(NewtonIntegrator); // 1st order numerical damping -void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel){ - for(int i=0; i3; i++) force[i]*=1-damping*Mathr::Sign(force[i]*vel[i]); +void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel, const Real dampcoeff){ + for(int i=0; i3; i++) force[i]*=1-dampcoeff*Mathr::Sign(force[i]*vel[i]); } // 2nd order numerical damping -void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel){ - for(int i=0; i3; i++) accel[i]*= 1 - damping*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); +void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel, const Real dampcoeff){ + for(int i=0; i3; i++) accel[i]*= 1 - dampcoeff*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); } Vector3r NewtonIntegrator::computeAccel(const Vector3r force, const Real mass, int blockedDOFs){ @@ -39,11 +40,13 @@ void NewtonIntegrator::updateEnergy(const shared_ptrBody b, const State* state, const Vector3r fluctVel, const Vector3r f, const Vector3r m){ assert(b-isStandalone() || b-isClump()); - // always positive dissipation, by-component: |F_i|*|v_i|*damping*dt (| T_i|*|ω_i|*damping*dt for rotations) - if(damping!=0.){ - scene-energy-
Re: [Yade-dev] : Add damping coefficient to material
On Mon, Jan 23, 2012 at 10:44 AM, Chiara c.moden...@gmail.com wrote: ... If you are not after any density scaling, why damping in NewtonIntegrator should be acceptable in a realistic dynamic situation? Would not be easier/more meaningful for you to implement damping inside your contact model? ... The bodies, which are not interact at the moment, will be skipped in this case, I think. Agree with Bruno, This diff looks better. Anton. ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Hi guys, thanks a lot for your suggestions. I just committed the code and I think it looks very good now. Klaus On Mon, 23 Jan 2012 11:08:59 PM Bruno Chareyre wrote: Ok, I understand. I like your diff more than the previous one. :) Still one suggestion: this additional parameter in the damping functions is useless: + cundallDamp2nd(dt,m,state-angVel,angAccel,dampcoeff); In your code, dampCoeff will be either Newton::damping or zero. So, it would be better to just write this, avoiding the function call and additional parameter: if (state-isDamped) cundallDamp2nd(dt,m,state-angVel,angAccel) Then I agree to commit. Bruno On 23/01/12 11:48, Klaus Thoeni wrote: Hi Chiara, thanks for your comment. I am not after viscous damping either. But I think the current implementation does exactly what I want, it's the same as the PFC option b_damp(). So I can deactivate the damping coefficient for individual bodies. I can commit the code if anyone is interested , after the diff has been approved ;-) Klaus On Mon, 23 Jan 2012 08:44:02 PM Chiara wrote: On 23/01/12 00:12, Klaus Thoeni wrote: Hi Bruno, hi Anton, I think density scaling is not what I am looking for since I am interested in real dynamic simulations. I need different damping parameters in NewtonIntegrator for the block and the mesh. I have to consider free flight under gravity so damping=0 (and I am interested in the real flight time). For the mesh I have to consider additional energy absorption which is not considered in my model via damping. If you are not after any density scaling, why damping in NewtonIntegrator should be acceptable in a realistic dynamic situation? Would not be easier/more meaningful for you to implement damping inside your contact model? Sorry, just curious. Chiara It is similar to b_damp() in PFC which is used to remove damping for certain particle. I implemented it the same way now. The state has a member which is true by default which means that damping is used. It can be set to false and damping=0 will be used for this particle. So basically damping in NewtonIntegrator can be activated and deactivated for individual particles. @Anton: It has to be checked for all particles. Here is the diff of my latest implementation, tell me what you think: === modified file core/State.hpp --- core/State.hpp2011-02-14 08:05:09 + +++ core/State.hpp2012-01-22 23:56:31 + @@ -59,7 +59,8 @@ ((Vector3r,inertia,Vector3r::Zero(),,Inertia of associated body, in local coordinate system.)) ((Vector3r,refPos,Vector3r::Zero(),,Reference position)) ((Quaternionr,refOri,Quaternionr::Identity(),,Reference orientation)) - ((unsigned,blockedDOFs,,,[Will be overridden])), + ((unsigned,blockedDOFs,,,[Will be overridden])) + ((bool,isDamped,true,,Damping in :yref:`Newtonintegrator` can be deactivated for individual particles by setting this variable to FALSE. E.g. damping is inappropriate for particles in free flight under gravity but it might still be applicable to other particles in the same simulation.)), /* additional initializers */ ((pos,se3.position)) ((ori,se3.orientation)), === modified file pkg/dem/NewtonIntegrator.cpp --- pkg/dem/NewtonIntegrator.cpp 2011-11-30 17:39:33 + +++ pkg/dem/NewtonIntegrator.cpp 2012-01-22 23:56:31 + @@ -11,17 +11,18 @@ #includeyade/pkg/dem/Clump.hpp #includeyade/pkg/common/VelocityBins.hpp #includeyade/lib/base/Math.hpp YADE_PLUGIN((NewtonIntegrator)); CREATE_LOGGER(NewtonIntegrator); // 1st order numerical damping -void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel){ - for(int i=0; i3; i++) force[i]*=1-damping*Mathr::Sign(force[i]*vel[i]); +void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel, const Real dampcoeff){ + for(int i=0; i3; i++) force[i]*=1-dampcoeff*Mathr::Sign(force[i]*vel[i]); } // 2nd order numerical damping -void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel){ - for(int i=0; i3; i++) accel[i]*= 1 - damping*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); +void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel, const Real dampcoeff){ + for(int i=0; i3; i++) accel[i]*= 1 - dampcoeff*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); } Vector3r NewtonIntegrator::computeAccel(const Vector3r force, const Real mass, int blockedDOFs){ @@ -39,11 +40,13 @@ void
Re: [Yade-dev] : Add damping coefficient to material
Hi Bruno, hi Anton, I think density scaling is not what I am looking for since I am interested in real dynamic simulations. I need different damping parameters in NewtonIntegrator for the block and the mesh. I have to consider free flight under gravity so damping=0 (and I am interested in the real flight time). For the mesh I have to consider additional energy absorption which is not considered in my model via damping. It is similar to b_damp() in PFC which is used to remove damping for certain particle. I implemented it the same way now. The state has a member which is true by default which means that damping is used. It can be set to false and damping=0 will be used for this particle. So basically damping in NewtonIntegrator can be activated and deactivated for individual particles. @Anton: It has to be checked for all particles. Here is the diff of my latest implementation, tell me what you think: === modified file core/State.hpp --- core/State.hpp 2011-02-14 08:05:09 + +++ core/State.hpp 2012-01-22 23:56:31 + @@ -59,7 +59,8 @@ ((Vector3r,inertia,Vector3r::Zero(),,Inertia of associated body, in local coordinate system.)) ((Vector3r,refPos,Vector3r::Zero(),,Reference position)) ((Quaternionr,refOri,Quaternionr::Identity(),,Reference orientation)) - ((unsigned,blockedDOFs,,,[Will be overridden])), + ((unsigned,blockedDOFs,,,[Will be overridden])) + ((bool,isDamped,true,,Damping in :yref:`Newtonintegrator` can be deactivated for individual particles by setting this variable to FALSE. E.g. damping is inappropriate for particles in free flight under gravity but it might still be applicable to other particles in the same simulation.)), /* additional initializers */ ((pos,se3.position)) ((ori,se3.orientation)), === modified file pkg/dem/NewtonIntegrator.cpp --- pkg/dem/NewtonIntegrator.cpp2011-11-30 17:39:33 + +++ pkg/dem/NewtonIntegrator.cpp2012-01-22 23:56:31 + @@ -11,17 +11,18 @@ #includeyade/pkg/dem/Clump.hpp #includeyade/pkg/common/VelocityBins.hpp #includeyade/lib/base/Math.hpp YADE_PLUGIN((NewtonIntegrator)); CREATE_LOGGER(NewtonIntegrator); // 1st order numerical damping -void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel){ - for(int i=0; i3; i++) force[i]*=1-damping*Mathr::Sign(force[i]*vel[i]); +void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel, const Real dampcoeff){ + for(int i=0; i3; i++) force[i]*=1-dampcoeff*Mathr::Sign(force[i]*vel[i]); } // 2nd order numerical damping -void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel){ - for(int i=0; i3; i++) accel[i]*= 1 - damping*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); +void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel, const Real dampcoeff){ + for(int i=0; i3; i++) accel[i]*= 1 - dampcoeff*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); } Vector3r NewtonIntegrator::computeAccel(const Vector3r force, const Real mass, int blockedDOFs){ @@ -39,11 +40,13 @@ void NewtonIntegrator::updateEnergy(const shared_ptrBody b, const State* state, const Vector3r fluctVel, const Vector3r f, const Vector3r m){ assert(b-isStandalone() || b-isClump()); - // always positive dissipation, by-component: |F_i|*|v_i|*damping*dt (| T_i|*|ω_i|*damping*dt for rotations) - if(damping!=0.){ - scene-energy- add(fluctVel.cwise().abs().dot(f.cwise().abs())*damping*scene- dt,nonviscDamp,nonviscDampIx,/*non-incremental*/false); + // check if damping for this body is activated + Real dampcoeff=(state-isDamped ? damping : 0); + // always positive dissipation, by-component: |F_i|*|v_i|*dampcoeff*dt (| T_i|*|ω_i|*dampcoeff*dt for rotations) + if(dampcoeff!=0.){ + scene-energy- add(fluctVel.cwise().abs().dot(f.cwise().abs())*dampcoeff*scene- dt,nonviscDamp,nonviscDampIx,/*non-incremental*/false); // when the aspherical integrator is used, torque is damped instead of ang acceleration; this code is only approximate - scene-energy-add(state- angVel.cwise().abs().dot(m.cwise().abs())*damping*scene- dt,nonviscDamp,nonviscDampIx,false); + scene-energy-add(state- angVel.cwise().abs().dot(m.cwise().abs())*dampcoeff*scene- dt,nonviscDamp,nonviscDampIx,false); } // kinetic energy Real Etrans=.5*state-mass*fluctVel.squaredNorm(); @@ -106,9 +109,13 @@ YADE_PARALLEL_FOREACH_BODY_BEGIN(const shared_ptrBody b, scene-bodies) { // clump members are handled inside clumps if(unlikely(b-isClumpMember())) continue; - + State*
Re: [Yade-dev] : Add damping coefficient to material
Hi Anton, I just had a look at py/tests/clump.py, that's the test which fails. I added this after line 60 (before NewtonIntegrator is called): for b in O.bodies: print b.material and that's what I get: FrictMat instance at 0x1014c10 None So the second body has no material. I think it's more a problem in the test. In a, lets say, real simulation the material always exists (or not?), so I am not sure if checking for the material makes sense and it would be quit inefficient. However, I am not familiar with the testing stuff. Is there anyone who knows why the second body gives 'None' for the material? Klaus On Thu, 19 Jan 2012 06:31:09 PM Anton Gladky wrote: Real getDampCoeff() { return material-damping; }; Can you check here a material existence? Anton On Thu, Jan 19, 2012 at 8:14 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Hi Anton, actually it is the third body and it's a clump (isClump=True). Clumps should have a material too, shouldn't they? Klaus On Thu, 19 Jan 2012 06:31:09 PM Anton Gladky wrote: Real getDampCoeff() { return material-damping; }; Can you check here a material existence? Anton On Thu, Jan 19, 2012 at 8:14 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Hmm, good question. Maybe not. They consist of real spheres and those spheres should have a material, I think. Anton On Thu, Jan 19, 2012 at 11:35 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi Anton, actually it is the third body and it's a clump (isClump=True). Clumps should have a material too, shouldn't they? Klaus On Thu, 19 Jan 2012 06:31:09 PM Anton Gladky wrote: Real getDampCoeff() { return material-damping; }; Can you check here a material existence? Anton On Thu, Jan 19, 2012 at 8:14 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
I just creeated a clump in a real simulation , and indeed, material gives 'None'. So clumps have no material. Anyone knows why? Makes no sense to me. Klaus On Thu, 19 Jan 2012 09:51:38 PM Anton Gladky wrote: Hmm, good question. Maybe not. They consist of real spheres and those spheres should have a material, I think. Anton On Thu, Jan 19, 2012 at 11:35 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi Anton, actually it is the third body and it's a clump (isClump=True). Clumps should have a material too, shouldn't they? Klaus On Thu, 19 Jan 2012 06:31:09 PM Anton Gladky wrote: Real getDampCoeff() { return material-damping; }; Can you check here a material existence? Anton On Thu, Jan 19, 2012 at 8:14 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Solved the problem by checking if it is a clump: Real getDampCoeff() { return (!Body::isClump) ? material-damping : NaN; }; However, I think we still have to sort out why clumps don't have a material! I will commit the code, it might be useful to have different non-viscous damping coefficients, or what do you think? Klaus On Thu, 19 Jan 2012 09:51:38 PM Anton Gladky wrote: Hmm, good question. Maybe not. They consist of real spheres and those spheres should have a material, I think. Anton On Thu, Jan 19, 2012 at 11:35 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi Anton, actually it is the third body and it's a clump (isClump=True). Clumps should have a material too, shouldn't they? Klaus On Thu, 19 Jan 2012 06:31:09 PM Anton Gladky wrote: Real getDampCoeff() { return material-damping; }; Can you check here a material existence? Anton On Thu, Jan 19, 2012 at 8:14 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Could you, please, attach a diff first? Thanks Anton On Thu, Jan 19, 2012 at 1:03 PM, Klaus Thoeni klaus.tho...@gmail.com wrote: Solved the problem by checking if it is a clump: Real getDampCoeff() { return (!Body::isClump) ? material-damping : NaN; }; However, I think we still have to sort out why clumps don't have a material! I will commit the code, it might be useful to have different non-viscous damping coefficients, or what do you think? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Here is the diff, effected classes Body, Material, NewtonIntegrator. Let me know if you are happy! === modified file core/Body.hpp --- core/Body.hpp 2010-12-22 10:55:23 + +++ core/Body.hpp 2012-01-19 11:40:50 + @@ -68,6 +68,8 @@ int getGroupMask() {return groupMask; }; bool maskOk(int mask){return (mask==0 || (groupMaskmask));} + + Real getDampCoeff() { return (!Body::isClump) ? material-damping : NaN; }; // only BodyContainer can set the id of a body friend class BodyContainer; === modified file core/Material.hpp --- core/Material.hpp 2010-11-07 11:46:20 + +++ core/Material.hpp 2012-01-12 05:50:12 + @@ -39,7 +39,8 @@ YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Material,Serializable,Material properties of a :yref:`bodyBody`., ((int,id,((void)not shared,-1),Attr::readonly,Numeric id of this material; is non-negative only if this Material is shared (i.e. in O.materials), -1 otherwise. This value is set automatically when the material is inserted to the simulation via :yref:`O.materials.appendMaterialContainer.append`. (This id was necessary since before boost::serialization was used, shared pointers were not tracked properly; it might disappear in the future))) ((string,label,,,Textual identifier for this material; can be used for shared materials lookup in :yref:`MaterialContainer`.)) - ((Real,density,1000,,Density of the material [kg/m³])), + ((Real,density,1000,,Density of the material [kg/m³])) + ((Real,damping,NaN,,Local damping coefficient associated with the material [-]. If this value is given :yref:`Newtonintegrator` uses this value instead of :yref:`dampingNewtonIntegrator.damping` and it allows to use different damping coefficients for different materials.)), /* ctor */, /*py*/ .def(newAssocState,Material::newAssocState,Return new :yref:`State` instance, which is associated with this :yref:`Material`. Some materials have special requirement on :yref:`Body::state` type and calling this function when the body is created will ensure that they match. (This is done automatically if you use utils.sphere, … functions from python).) === modified file pkg/dem/NewtonIntegrator.cpp --- pkg/dem/NewtonIntegrator.cpp2011-11-30 17:39:33 + +++ pkg/dem/NewtonIntegrator.cpp2012-01-19 11:56:41 + @@ -11,17 +11,18 @@ #includeyade/pkg/dem/Clump.hpp #includeyade/pkg/common/VelocityBins.hpp #includeyade/lib/base/Math.hpp +#include ../../lib/base/Logging.hpp YADE_PLUGIN((NewtonIntegrator)); CREATE_LOGGER(NewtonIntegrator); // 1st order numerical damping -void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel){ - for(int i=0; i3; i++) force[i]*=1-damping*Mathr::Sign(force[i]*vel[i]); +void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel, const Real dampcoeff){ + for(int i=0; i3; i++) force[i]*=1-dampcoeff*Mathr::Sign(force[i]*vel[i]); } // 2nd order numerical damping -void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel){ - for(int i=0; i3; i++) accel[i]*= 1 - damping*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); +void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel, const Real dampcoeff){ + for(int i=0; i3; i++) accel[i]*= 1 - dampcoeff*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); } Vector3r NewtonIntegrator::computeAccel(const Vector3r force, const Real mass, int blockedDOFs){ @@ -39,11 +40,14 @@ void NewtonIntegrator::updateEnergy(const shared_ptrBody b, const State* state, const Vector3r fluctVel, const Vector3r f, const Vector3r m){ assert(b-isStandalone() || b-isClump()); - // always positive dissipation, by-component: |F_i|*|v_i|*damping*dt (| T_i|*|ω_i|*damping*dt for rotations) - if(damping!=0.){ - scene-energy- add(fluctVel.cwise().abs().dot(f.cwise().abs())*damping*scene- dt,nonviscDamp,nonviscDampIx,/*non-incremental*/false); + // check which damping coefficient to use + Real dampcoeff=damping; + if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); + // always positive dissipation, by-component: |F_i|*|v_i|*dampcoeff*dt (| T_i|*|ω_i|*dampcoeff*dt for rotations) + if(dampcoeff!=0.){ + scene-energy- add(fluctVel.cwise().abs().dot(f.cwise().abs())*dampcoeff*scene- dt,nonviscDamp,nonviscDampIx,/*non-incremental*/false); // when the aspherical integrator is used, torque is damped instead of ang acceleration; this code is only approximate - scene-energy-add(state- angVel.cwise().abs().dot(m.cwise().abs())*damping*scene- dt,nonviscDamp,nonviscDampIx,false); + scene-energy-add(state-
Re: [Yade-dev] : Add damping coefficient to material
Hi Klaus, 1/ I don't really understand what you did and what the problem is. I know what density scaling is (what we discussed in Barcelona iirc), but it is not a form of damping and doesn't need anything new in materials. Instead, it uses the per-body timestep. 2/ In order to be sure where the crash is, you should test in debug mode. Bruno On 19/01/12 08:14, Klaus Thoeni wrote: Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp -- ___ Bruno Chareyre Associate Professor ENSE³ - Grenoble INP 11, rue des Mathématiques BP 46 38402 St Martin d'Hères, France Tél : +33 4 56 52 86 21 Fax : +33 4 76 82 70 43 ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
(sorry for previous message, I didnt see the full discussion) As Anton says, a clump is a collection of bodies (not only spheres), and each of them have a material. At the clump's scale, material properties would be useless. Bruno On 19/01/12 11:56, Klaus Thoeni wrote: I just creeated a clump in a real simulation , and indeed, material gives 'None'. So clumps have no material. Anyone knows why? Makes no sense to me. Klaus On Thu, 19 Jan 2012 09:51:38 PM Anton Gladky wrote: Hmm, good question. Maybe not. They consist of real spheres and those spheres should have a material, I think. Anton On Thu, Jan 19, 2012 at 11:35 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi Anton, actually it is the third body and it's a clump (isClump=True). Clumps should have a material too, shouldn't they? Klaus On Thu, 19 Jan 2012 06:31:09 PM Anton Gladky wrote: Real getDampCoeff() { return material-damping; }; Can you check here a material existence? Anton On Thu, Jan 19, 2012 at 8:14 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp -- ___ Bruno Chareyre Associate Professor ENSE³ - Grenoble INP 11, rue des Mathématiques BP 46 38402 St Martin d'Hères, France Tél : +33 4 56 52 86 21 Fax : +33 4 76 82 70 43 ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Still not good Klaus sorry. Bodies without material are allowed. Your change should not crash yade in that case. Solved the problem by checking if it is a clump: ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
One note: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); I think it is not optimal to check (if(!isnan(b-getDampCoeff( on _every_ interaction on _each_ step (performance!!!). As I understand, you do not use damping-variable of Newtonintegrator at all, so just set it to -1 and use it as flag. So you will check it 1 time per step. But it needs to be documented. I dont see any large problems with this commit. If you really need it, you can do it after fixing this issue. Anton On Thu, Jan 19, 2012 at 1:48 PM, Klaus Thoeni klaus.tho...@gmail.com wrote: Here is the diff, effected classes Body, Material, NewtonIntegrator. Let me know if you are happy! === modified file core/Body.hpp --- core/Body.hpp 2010-12-22 10:55:23 + +++ core/Body.hpp 2012-01-19 11:40:50 + @@ -68,6 +68,8 @@ int getGroupMask() {return groupMask; }; bool maskOk(int mask){return (mask==0 || (groupMaskmask));} + + Real getDampCoeff() { return (!Body::isClump) ? material-damping : NaN; }; // only BodyContainer can set the id of a body friend class BodyContainer; === modified file core/Material.hpp --- core/Material.hpp 2010-11-07 11:46:20 + +++ core/Material.hpp 2012-01-12 05:50:12 + @@ -39,7 +39,8 @@ YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Material,Serializable,Material properties of a :yref:`bodyBody`., ((int,id,((void)not shared,-1),Attr::readonly,Numeric id of this material; is non-negative only if this Material is shared (i.e. in O.materials), -1 otherwise. This value is set automatically when the material is inserted to the simulation via :yref:`O.materials.appendMaterialContainer.append`. (This id was necessary since before boost::serialization was used, shared pointers were not tracked properly; it might disappear in the future))) ((string,label,,,Textual identifier for this material; can be used for shared materials lookup in :yref:`MaterialContainer`.)) - ((Real,density,1000,,Density of the material [kg/m³])), + ((Real,density,1000,,Density of the material [kg/m³])) + ((Real,damping,NaN,,Local damping coefficient associated with the material [-]. If this value is given :yref:`Newtonintegrator` uses this value instead of :yref:`dampingNewtonIntegrator.damping` and it allows to use different damping coefficients for different materials.)), /* ctor */, /*py*/ .def(newAssocState,Material::newAssocState,Return new :yref:`State` instance, which is associated with this :yref:`Material`. Some materials have special requirement on :yref:`Body::state` type and calling this function when the body is created will ensure that they match. (This is done automatically if you use utils.sphere, … functions from python).) === modified file pkg/dem/NewtonIntegrator.cpp --- pkg/dem/NewtonIntegrator.cpp 2011-11-30 17:39:33 + +++ pkg/dem/NewtonIntegrator.cpp 2012-01-19 11:56:41 + @@ -11,17 +11,18 @@ #includeyade/pkg/dem/Clump.hpp #includeyade/pkg/common/VelocityBins.hpp #includeyade/lib/base/Math.hpp +#include ../../lib/base/Logging.hpp YADE_PLUGIN((NewtonIntegrator)); CREATE_LOGGER(NewtonIntegrator); // 1st order numerical damping -void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel){ - for(int i=0; i3; i++) force[i]*=1-damping*Mathr::Sign(force[i]*vel[i]); +void NewtonIntegrator::cundallDamp1st(Vector3r force, const Vector3r vel, const Real dampcoeff){ + for(int i=0; i3; i++) force[i]*=1-dampcoeff*Mathr::Sign(force[i]*vel[i]); } // 2nd order numerical damping -void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel){ - for(int i=0; i3; i++) accel[i]*= 1 - damping*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); +void NewtonIntegrator::cundallDamp2nd(const Real dt, const Vector3r force, const Vector3r vel, Vector3r accel, const Real dampcoeff){ + for(int i=0; i3; i++) accel[i]*= 1 - dampcoeff*Mathr::Sign ( force[i]*(vel[i] + 0.5*dt*accel[i]) ); } Vector3r NewtonIntegrator::computeAccel(const Vector3r force, const Real mass, int blockedDOFs){ @@ -39,11 +40,14 @@ void NewtonIntegrator::updateEnergy(const shared_ptrBody b, const State* state, const Vector3r fluctVel, const Vector3r f, const Vector3r m){ assert(b-isStandalone() || b-isClump()); - // always positive dissipation, by-component: |F_i|*|v_i|*damping*dt (| T_i|*|ω_i|*damping*dt for rotations) - if(damping!=0.){ - scene-energy- add(fluctVel.cwise().abs().dot(f.cwise().abs())*damping*scene- dt,nonviscDamp,nonviscDampIx,/*non-incremental*/false); + // check which damping coefficient to use + Real dampcoeff=damping; + if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff();
Re: [Yade-dev] : Add damping coefficient to material
Klaus, If what you want is to increase the timestep (because your steel-net induces very small dt, right?), this change will not work. You need to modify density in the good place in Newton, not damping. It can be done by adding dscale parameter in the material class (hence no need to check if it exists), which would be 1 by default, hence no need to check if it is NaN. isnan is not in C++ standard, by the way. I know it is used in many places but we should avoid it if possible. I'm also not sure of the cost of this function, it may be more expensive than comparing two doubles. Bruno ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] : Add damping coefficient to material
Real getDampCoeff() { return material-damping; }; Can you check here a material existence? Anton On Thu, Jan 19, 2012 at 8:14 AM, Klaus Thoeni klaus.tho...@gmail.com wrote: Hi guys, can anyone help me on this? Klaus On Thu, 12 Jan 2012 06:03:16 PM Klaus Thoeni wrote: Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
[Yade-dev] : Add damping coefficient to material
Hi guys, as discussed with Bruno in Barcelona I need different non-viscous damping coefficients for different materials. I introduced this capability by adding a variable damping to the base class material which is initialised with NaN. The body class has a function getDampCoeff() and in NewtonIntegrator I use this function in order to change the damping coefficients. When running some examples it seems that everything works fine. However, I just run 'yade --test' and it gives me a seg fault: testVelocity (yade.TestSimpleClump) Clump: velocities of member assigned by NewtonIntegrator ... Segmentation fault I think I now where the problem is. In NewtonIntegrator I call something like: if(!isnan(b-getDampCoeff())) dampcoeff=b-getDampCoeff(); where getDampCoeff() is defined in body.hpp as: Real getDampCoeff() { return material-damping; }; I think the test doesn't have a material and therefore I get the seg fault. Right? How can we fix this so that I can commit the code? Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp