# Modify the contact model in source code

47 views

### Qihan Xuan

Jun 14, 2022, 1:59:22 PMJun 14
to ProjectChrono
Hi all,

I have a question about changing the contact model in the Chrono. By the way, I am using (the core module of) Chrono.
The viscoelastic model shows the damping term is proportional to velocity. Can we change it?

We are studying fish motion on mud, which is shear-thinning interaction. For example, we hope the damping term is proportional to the square root of the velocity. Can it be tuned by ourselves?

Thanks,
Qihan

### Luning Fang

Jun 14, 2022, 3:08:03 PMJun 14
to ProjectChrono

In the core module of Chrono, you can modify your contact force model in this file, src/chrono/physics/ChContactSMC.h

The function you need to look at is CalculateForce()

ChVector<> CalculateForce(

double delta,                      ///< overlap in normal direction

const ChVector<>& normal_dir,      ///< normal contact direction (expressed in global frame)

const ChVector<>& vel1,            ///< velocity of contact point on objA (expressed in global frame)

const ChVector<>& vel2,            ///< velocity of contact point on objB (expressed in global frame)

const ChMaterialCompositeSMC& mat  ///< composite material for contact pair

)

The following two lines match the equations you screenshotted. Note that kn, gn, kt, gt are computed differently depending on the contact force model you choose. forceN and forceT are normal and tangential force magnitude.

// Calculate the magnitudes of the normal and tangential contact forces

double forceN = kn * delta - gn * relvel_n_mag;

double forceT = kt * delta_t + gt * relvel_t_mag;

You can implement the model however you want.

Thank you,

Luning

### Qihan Xuan

Jun 14, 2022, 10:03:33 PMJun 14
to ProjectChrono
Thanks! It works.

By the way, I find I have to compile Chrono after modifying the source code.
If you want want to check whether your Chrono is updated, you can check this file: D:/Chrono_v7_build/lib/Release/ChronoEngine.lib

Thanks,
Qihan

Jun 18, 2022, 7:53:04 AMJun 18
to ProjectChrono

Qihan,

Indeed, if you change any of the Chrono sources, you will obviously have to rebuild.

I have somewhere code that allows changing the contact force calculation in user code only (which would not require rebuilding the Chrono libraries).  That uses a mechanism similar to what I implemented for overriding the default composite material combination laws (which Luning also mentioned in another reply).  I will consider pushing that to the Chrono repository one of these days.

Hi all,

We are studying fish motion on mud, which is shear-thinning interaction. For example, we hope the damping term is proportional to the square root of the velocity. Can it be tuned by ourselves?

Thanks,

Qihan

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.

Jun 26, 2022, 3:16:48 AMJun 26
to ProjectChrono

Qihan,

I pushed code to allow overriding the default SMC contact force calculation with a user-defined function.