How to use the particle temperature in an API ?

Yangyang_Shen
Yangyang_Shen Altair Community Member
edited November 2023 in Community Q&A

Hi. My EDEM simulation uses the Heat Conduction model in Particle-to-Particle Physics and the Temperature Update model in Particle-Body-Force Interaction. Now I want add an API that uses the particle temperature to calculate some additional property (I have created a new particle property). How can I retrieve the value of particle temperature from my simulation or from the Heat Conduction model and include it in the new API?

In fact I took the EDEM heat conduction API tutorial and tried to modify the c++ codes. I created a new particle property by replacing the particle temperature property. Also I added some statements i.e. "double elem1Temp" and "double elem2Temp". Please see the screenshot below. But I got the 2 compilation errors: 1) declaration is incompatible and 2) cannot instantiate abstract class. Please advise me how to fix the problem. Thanks so much! 

image

 

Tagged:

Answers

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited November 2023

    Hi,


    It looks like from the screenshot you are using an older version of the API.

    I'd recommend making sure the API code you have is updated to the latest version - https://youtu.be/Bweffts_4qM

    You shouldn't add anything to the calculateForce function as this is a fixed list of inputs from EDEM and information you can pass back, it isn't possible to change this.

     

    However creating a custom particle property for temperature and heat flux as defined here:

    https://community.altair.com/community/en/edem-api-contact-model-example-heat-conduction?id=kb_article&sysparm_article=KB0121824

     

    And then using the temperature Custom Property in your model, it will pickup the current temperature of the particle so long as the custom properties match.


    Regards

    Stephen

  • Yangyang_Shen
    Yangyang_Shen Altair Community Member
    edited November 2023

    Hi,


    It looks like from the screenshot you are using an older version of the API.

    I'd recommend making sure the API code you have is updated to the latest version - https://youtu.be/Bweffts_4qM

    You shouldn't add anything to the calculateForce function as this is a fixed list of inputs from EDEM and information you can pass back, it isn't possible to change this.

     

    However creating a custom particle property for temperature and heat flux as defined here:

    https://community.altair.com/community/en/edem-api-contact-model-example-heat-conduction?id=kb_article&sysparm_article=KB0121824

     

    And then using the temperature Custom Property in your model, it will pickup the current temperature of the particle so long as the custom properties match.


    Regards

    Stephen

    Hi Stephen,

    Thank you so much for your reply! It makes sense the calculateForce function is a fixed list of inputs from EDEM, so I shouldn't change anything. 

    Also thanks for pointing me to the Heat Conduction and Temperature Update model using API v3.3. I have looked into the source code and have some additional questions:

    1) I noticed the new version source code didn't have the custom property for Geometry Temperature. If my simulation needs a geometry as the heat source, I should create the custom property for Geometry Temperature (just like in the old version) and calculate the temperature change and heat flux between particle and geometry, correct?  And I should add the thermal conductivity and initial temperature of the geometry in the preference file, correct? 

    2) It seems the new model has the Contact Model and Particle Body Force (temperature update). Shall I compile the Contact Model and Particle Body Force separately, making 2 library files, one for each? I’m a little confused because the source code for temperature update also needs the heat capacity data which is passed from the contact model. While in the old model, the temperature change is calculated in the contact model. Why is the difference and can you please provide instructions on compiling the new model?

    3) If I want to run my simulations on CPU only, can I just ignore the .cl and .cu files? And I can remove (or comment out) any statement related to GPU in the source code, right? 

    Thanks again for your help!

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited November 2023

    Hi Stephen,

    Thank you so much for your reply! It makes sense the calculateForce function is a fixed list of inputs from EDEM, so I shouldn't change anything. 

    Also thanks for pointing me to the Heat Conduction and Temperature Update model using API v3.3. I have looked into the source code and have some additional questions:

    1) I noticed the new version source code didn't have the custom property for Geometry Temperature. If my simulation needs a geometry as the heat source, I should create the custom property for Geometry Temperature (just like in the old version) and calculate the temperature change and heat flux between particle and geometry, correct?  And I should add the thermal conductivity and initial temperature of the geometry in the preference file, correct? 

    2) It seems the new model has the Contact Model and Particle Body Force (temperature update). Shall I compile the Contact Model and Particle Body Force separately, making 2 library files, one for each? I’m a little confused because the source code for temperature update also needs the heat capacity data which is passed from the contact model. While in the old model, the temperature change is calculated in the contact model. Why is the difference and can you please provide instructions on compiling the new model?

    3) If I want to run my simulations on CPU only, can I just ignore the .cl and .cu files? And I can remove (or comment out) any statement related to GPU in the source code, right? 

    Thanks again for your help!

    Hi,


    The link has an additional zip attached 'HeatConductionForGeometry_29July2014 (1).zip'  This is an older version of the code but it shows use of the geometry as a heat source.

     

    You don't need to create a custom property for the geometry as this would be assigned per geometry element, and there isn't any geometry-geometry physics interaction in EDEM so it's best to consider the geometry as a constant heat source rather than anything that can be varied.

     

    You can compile the Body Force and Contact Model all into 1 .dll or two separate ones, it shouldn't make a difference when loading into EDEM.  EDEM looks for the 'GETCMINTERFACEVERSION' or 'GETEFINTERFACEVERSION' in the code if it is loaded as a Contact Model (CM interface) or Body Force (EF interface).  So long as the .dll contains either of those when loaded into the appropriate area it is OK, it doesn't matter if it contains both.

    There is an advantage of having both in 1 library file as you can then share data between the two using the computer memory directly, however it's not necessary in this case as all the data is shared via the Custom Properties that are sent to EDEM.

     

    If you want to run on CPU only you can ignore the GPU parts of the code or comment them out., EDEM only actually reads the .cu file on runtime so it can still exist as a blank file and doesn't impact the simulation.


    Regards

    Stephen

  • Yangyang_Shen
    Yangyang_Shen Altair Community Member
    edited November 2023

    Hi,


    The link has an additional zip attached 'HeatConductionForGeometry_29July2014 (1).zip'  This is an older version of the code but it shows use of the geometry as a heat source.

     

    You don't need to create a custom property for the geometry as this would be assigned per geometry element, and there isn't any geometry-geometry physics interaction in EDEM so it's best to consider the geometry as a constant heat source rather than anything that can be varied.

     

    You can compile the Body Force and Contact Model all into 1 .dll or two separate ones, it shouldn't make a difference when loading into EDEM.  EDEM looks for the 'GETCMINTERFACEVERSION' or 'GETEFINTERFACEVERSION' in the code if it is loaded as a Contact Model (CM interface) or Body Force (EF interface).  So long as the .dll contains either of those when loaded into the appropriate area it is OK, it doesn't matter if it contains both.

    There is an advantage of having both in 1 library file as you can then share data between the two using the computer memory directly, however it's not necessary in this case as all the data is shared via the Custom Properties that are sent to EDEM.

     

    If you want to run on CPU only you can ignore the GPU parts of the code or comment them out., EDEM only actually reads the .cu file on runtime so it can still exist as a blank file and doesn't impact the simulation.


    Regards

    Stephen

    Hi Stephen,

    Thank you so much for the detailed explanation! I’m now a lot clearer on what to do.

    In fact I was able to get the example and source code in 'HeatConductionForGeometry_29July2014.zip' which has the geometry as a heat source. Also I was able to modify the code and create a new Particle Custom Property that uses the current temperature of the particle (retrieved from the temperature Custom Property).  After compiling the code (into one .dll file), when I tried to load the model in EDEM, I got an error message (see the screenshot below). For the particle-to-particle interaction, I selected the base Hertz-Mindlin (no slip), Standard Rolling Friction, and the plug-in model I compiled myself. Why is the error? I want my particles to have an initial temperature (298K), so I defined it in the Factory. Does this clash with the particle temperature Custom Property? Please advise. 

    image

    Thank you and best regards!

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited November 2023

    Hi Stephen,

    Thank you so much for the detailed explanation! I’m now a lot clearer on what to do.

    In fact I was able to get the example and source code in 'HeatConductionForGeometry_29July2014.zip' which has the geometry as a heat source. Also I was able to modify the code and create a new Particle Custom Property that uses the current temperature of the particle (retrieved from the temperature Custom Property).  After compiling the code (into one .dll file), when I tried to load the model in EDEM, I got an error message (see the screenshot below). For the particle-to-particle interaction, I selected the base Hertz-Mindlin (no slip), Standard Rolling Friction, and the plug-in model I compiled myself. Why is the error? I want my particles to have an initial temperature (298K), so I defined it in the Factory. Does this clash with the particle temperature Custom Property? Please advise. 

    image

    Thank you and best regards!

    Hi, do you have any other physics models loaded, like the in-built heat transfer model?

     

    It's OK to combine the in-built model with the API models just the custom properties have to be the same, defined identically in all areas.

     

    It believe the in-built custom property is called 'Temperature' and the error is related to a clash with 'Particle Temperature'.  It maybe just the name of the property has to be 'Temperature' not particle temperature to make it match.


    Regards

    Stephen

  • Yangyang_Shen
    Yangyang_Shen Altair Community Member
    edited November 2023

    Hi, do you have any other physics models loaded, like the in-built heat transfer model?

     

    It's OK to combine the in-built model with the API models just the custom properties have to be the same, defined identically in all areas.

     

    It believe the in-built custom property is called 'Temperature' and the error is related to a clash with 'Particle Temperature'.  It maybe just the name of the property has to be 'Temperature' not particle temperature to make it match.


    Regards

    Stephen

    Hi Stephen, 

    Thanks for your reply. But I don't have any other physics models loaded. I only selected the base Hertz-Mindlin (no slip), Standard Rolling Friction, and the plug-in model I compiled myself. 

    I just tried to change the name of the property from "Particle Temperature" to "Temperature" , and recompiled the code. I still couldn't load the model, and got the same error message. The clashing custom property has changed to "Temperature" now.

    image

    I have also tried to run my simulation without the plug-in model, and everything seemed fine. And I noticed no temperature setup in the Factory without loading the plug-in model. 

    I'm really stuck. Any hints will be appreciated! 

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited November 2023

    Hi Stephen, 

    Thanks for your reply. But I don't have any other physics models loaded. I only selected the base Hertz-Mindlin (no slip), Standard Rolling Friction, and the plug-in model I compiled myself. 

    I just tried to change the name of the property from "Particle Temperature" to "Temperature" , and recompiled the code. I still couldn't load the model, and got the same error message. The clashing custom property has changed to "Temperature" now.

    image

    I have also tried to run my simulation without the plug-in model, and everything seemed fine. And I noticed no temperature setup in the Factory without loading the plug-in model. 

    I'm really stuck. Any hints will be appreciated! 

    Hi,

    EDEM does keep a track in the simulation file of all previously used custom properties with that file.  It maybe that in the past it had different properties loaded.


    If at t=0 you go to the EDEM Analyst > File > Export Simulation Deck.  Choose a file name and then de-select the Export Custom Properties tick-box:

     

    image

     

    The new file created should not have any custom properties in it, so you should be able to open that and load in your model.


    Regards

    Stephen