Example for EDEM API_ particle removal

Bharath Rangavittal
Bharath Rangavittal Altair Community Member
edited March 2023 in Community Q&A

Hi,

I am looking for code snippets of EDEM API custom models for removing particles from simulation, once they reach a particular temperature value. It will be helpful if anyone could point me in the direction of a few examples for removing particles from simulation based on their temperature.

Tagged:

Answers

  • RWood
    RWood
    Altair Employee
    edited September 2021

    Hi,

    https://community.altair.com/community?id=kb_article_view&sysparm_article=KB0113663

    The above example uses the markForRemoval() function within the particle manager, which is the standard way to do this.

    Cheers,

    Richard

  • Bharath Rangavittal
    Bharath Rangavittal Altair Community Member
    edited March 2023

    Hi Richard,

    Your suggestion has helped me a lot in my modelling work. I have been using markforRemoval() function successfully to remove particles from the simulation based on the position of particle or its contact with a surface.  However, now I would like to remove particles based on its temperature. I have gone through the different API files, but could not find the way to access temperature of a particle. The structure variables "Particle" and "DiscreteElement" contains information like position, velocity and other particle parameters except temperature. Am I missing something or am I looking in the wrong API files? Can you please tell me where I can access temperature of each particle?

    Thanks,

    Bharath

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited March 2023

    Hi Richard,

    Your suggestion has helped me a lot in my modelling work. I have been using markforRemoval() function successfully to remove particles from the simulation based on the position of particle or its contact with a surface.  However, now I would like to remove particles based on its temperature. I have gone through the different API files, but could not find the way to access temperature of a particle. The structure variables "Particle" and "DiscreteElement" contains information like position, velocity and other particle parameters except temperature. Am I missing something or am I looking in the wrong API files? Can you please tell me where I can access temperature of each particle?

    Thanks,

    Bharath

    Hi Bharath,


    Temperature is a 'custom property' and has to be specified using this method as it isn't something that is shown as standard.

    This API tutorial goes over usage of custom properties:

    https://community.altair.com/csm?id=kb_article_view&sysparm_article=KB0037694

     

    And an example API model using temperature as a custom property (custom property defined for particles only):

    https://community.altair.com/community?id=kb_article_view&sysparm_article=KB0113636

    Once you specify the custom property for temperature you can access the Value of this to use in your code.


    Regards

    Stephen

     

  • Bharath Rangavittal
    Bharath Rangavittal Altair Community Member
    edited March 2023

    Hi Bharath,


    Temperature is a 'custom property' and has to be specified using this method as it isn't something that is shown as standard.

    This API tutorial goes over usage of custom properties:

    https://community.altair.com/csm?id=kb_article_view&sysparm_article=KB0037694

     

    And an example API model using temperature as a custom property (custom property defined for particles only):

    https://community.altair.com/community?id=kb_article_view&sysparm_article=KB0113636

    Once you specify the custom property for temperature you can access the Value of this to use in your code.


    Regards

    Stephen

     

    Hi Stephen,

    Thanks for your reply. Yes! I had come across this example which you had shared. So, if I understood the example correctly, I will also need to create a custom contact model for Heat conduction for specifying a custom property for temperature, which can later be used by other custom physics models. Is my understanding right? Is it possible to access temperature as a custom property directly from the inbuilt Heat conduction model?

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited March 2023

    Hi Stephen,

    Thanks for your reply. Yes! I had come across this example which you had shared. So, if I understood the example correctly, I will also need to create a custom contact model for Heat conduction for specifying a custom property for temperature, which can later be used by other custom physics models. Is my understanding right? Is it possible to access temperature as a custom property directly from the inbuilt Heat conduction model?

    Hi Bharath,


    Yes, you can access Custom Properties that are defined in the in-built models also. You just need to make sure the names and setup is the same.  This should be same as what is set in the API model. Name is "Temperature"

    const std::string CHeatConduction::PARTICLE_TEMPERATURE = "Temperature";

    And it's defined as a particle property with 1 element and eTemperature units:

        if(eParticle == category &&         0 == propertyIndex)     {         strncpy(name, PARTICLE_TEMPERATURE.c_str(), NApi::CUSTOM_PROP_MAX_NAME_LENGTH);         dataType        = eDouble;         numberOfElements= 1;         unitType        = eTemperature;         return true;     }

     

    You should then be able to call the temperature and write to a variable (like elem1Temp)

            const double* elem1Temp = elem1CustomProperties->getValue(PARTICLE_TEMPERATURE.c_str());         const double* elem2Temp = elem2CustomProperties->getValue(PARTICLE_TEMPERATURE.c_str());

     

    Above is coped from the Contact Model but you can call via a Particle Body Force.  Note that elem2Temp is temperature of element 2.  Element 2 could be a particle or a geometry element and if you call it for a geometry it will crash EDEM as temperature is a particle custom property only, so will need to either apply only as p-p or PBF contact model or add in a condition to check if element 2 is particle or geometry.