New question #706221 on Yade:
https://answers.launchpad.net/yade/+question/706221

Hello to everyone,

I thought about trying ChatGPT 4 for writing new material laws and physics into 
YADE DEM, 

as I have little experience with the YADE code, it would be helpful if someone 
can give me a feedback.

Here is a code for temperature dependent cohesive burgers model written by 
ChatGPT 4:

HEADER:

#pragma once
#include<yade/pkg/dem/CohesiveFrictionalContactLaw.hpp>
#include<yade/pkg/dem/ScGeom.hpp>
#include<yade/pkg/dem/FrictPhys.hpp>

class TempDependentCohesiveBurgersViscoElasticModel: public CohFrictMat {
public:
    TempDependentCohesiveBurgersViscoElasticModel(Real young, Real poisson, 
Real frictionAngle, Real density, Real cohesion, Real viscousDamping, Real 
viscosity, Real tempRef);
    virtual ~TempDependentCohesiveBurgersViscoElasticModel();

    // Temperature reference for the model
    Real tempRef;

    // Viscosity for the viscoelastic component of the model
    Real viscosity;

    
YADE_CLASS_BASE_DOC_ATTRS_CTOR(TempDependentCohesiveBurgersViscoElasticModel, 
CohFrictMat, "Temperature-dependent cohesive Burger's viscoelastic model 
inheriting from CohFrictMat",
        ((Real, viscousDamping, 0, ,"Viscous damping for the viscoelastic 
component of the model"))
        ((Real, tempRef, 298.15, ,"Reference temperature for the model"))
        ((Real, viscosity, 0, ,"Viscosity for the viscoelastic component of the 
model")),
        /* ctor */ TempDependentCohesiveBurgersViscoElasticModel(young, 
poisson, frictionAngle, density, cohesion, viscousDamping, viscosity, tempRef); 
);
};
REGISTER_SERIALIZABLE(TempDependentCohesiveBurgersViscoElasticModel);

class TempDependentCohesiveBurgersViscoElasticContactLaw: public 
Law2_ScGeom_FrictPhys_CundallStrack {
public:
    virtual void go(shared_ptr<IGeom>& ig, shared_ptr<IPhys>& ip, Interaction* 
contact);
    YADE_CLASS_BASE_DOC(TempDependentCohesiveBurgersViscoElasticContactLaw, 
Law2_ScGeom_FrictPhys_CundallStrack, "Contact law for the temperature-dependent 
cohesive Burger's viscoelastic model");
};
REGISTER_SERIALIZABLE(TempDependentCohesiveBurgersViscoElasticContactLaw);


CCP File:

#include "TempDependentCohesiveBurgersViscoElastic.hpp"

TempDependentCohesiveBurgersViscoElasticModel::TempDependentCohesiveBurgersViscoElasticModel(Real
 young, Real poisson, Real frictionAngle, Real density, Real cohesion, Real 
viscousDamping, Real viscosity, Real tempRef)
    : CohFrictMat(young, poisson, frictionAngle, density, cohesion)
    , viscousDamping(viscousDamping)
    , viscosity(viscosity)
    , tempRef(tempRef) {
}

TempDependentCohesiveBurgersViscoElasticModel::~TempDependentCohesiveBurgersViscoElasticModel()
 {
}

YADE_PLUGIN((TempDependentCohesiveBurgersViscoElasticModel));

void TempDependentCohesiveBurgersViscoElasticContactLaw::go(shared_ptr<IGeom>& 
ig, shared_ptr<IPhys>& ip, Interaction* contact) {
    // Cast the geometry and physical parameters to the correct types
    ScGeom* geom = static_cast<ScGeom*>(ig.get());
    FrictPhys* phys = static_cast<FrictPhys*>(ip.get());

    // Get the associated bodies and materials
    Body* b1 = Body::byId(contact->getId1(), scene);
    Body* b2 = Body::byId(contact->getId2(), scene);
    TempDependentCohesiveBurgersViscoElasticModel* mat1 = 
static_cast<TempDependentCohesiveBurgersViscoElasticModel*>(b1->material.get());
    TempDependentCohesiveBurgersViscoElasticModel* mat2 = 
static_cast<TempDependentCohesiveBurgersViscoElasticModel*>(b2->material.get());

    // Compute the normal and tangential forces based on the 
temperature-dependent cohesive Burger's viscoelastic model
    // Note: You will need to implement the specific calculations for the model
    Vector3r normalForce, tangentialForce;
    // ...

    // Apply the forces to the bodies
    scene->forces.addForce(contact->getId1(), normalForce + tangentialForce);
    scene->forces.addForce(contact->getId2(), -(normalForce + tangentialForce));

    // Update the interaction geometry
    // ...
}

YADE_PLUGIN((TempDependentCohesiveBurgersViscoElasticContactLaw));


It is not fully completed but does this look fine? what is the best IDE to be 
used debugging such model? thanks.



-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to