EDEM API: Particle Body Force - Field Data Coupling – Choice of Drag Models with Lift Force

Stephen Cole
Stephen Cole
Altair Employee
edited May 2023 in Altair Exchange

Overview

Attached to this post you will find the compiled dll file for a EDEM Field Data case for multiple drag models in fieldDataMultipleDragModels_3_4.zip.

Model includes three different drag models, alongside models for Magnus and Saffman lift forces.

Also includes scaling of the forces acting on particles, implemented in a similar way to what is seen within the EDEM-CFD 2-way coupling, to be used if you have scaled your particles.

The choice of drag model is controlled by the preference file, which is commented so it should be clear which model you are using. Included the models of: Schiller & Naumann; Alexander & Morsi; and Haider & Levensipel.

The model uses two fields: ‘Velocity’ and ‘Vorticity’.

Included an example used for testing that demonstrates the lift models changing a rotating particle’s behaviour in a shear flow. The model is set up to have a particle falling in a very viscous fluid, rotating at 100 rad/s. Run the simulation as it is initially, notice how the particle moves in the Y direction, then change the angular velocity to 0 rad/s and see the difference in behaviour. 

This model has been updated from the previous version to API 3.4 to support CUDA GPU.  API 3.4 also allows additional functionality:

Field data ID is passed from CPU to GPU so order of the field is no longer relevant.

Gravity is read from the EDEM Creator instead of passed via Prefs file.

Legacy model using API 3.1 and OpenCL GPU also included.

 

 

Usage/Installation Instructions

Instructions are for the latest version only, not legacy:

Download and unzip fieldDataMultipleDragModels_3_4.zip

The settings for the model are applied in field_query_prefs.txt which include the fluid density, viscosity and choice of drag models.  The inputs also contain the scale factor if the particle size has been increased the model will scale the drag laws accordingly.

On opening the simulation .dem file the library fieldDataMultipleDragModels.dll is loaded as it is applied to the particle body force area.  The velocity and vorticity fields (from the CGNS files) have also been setup.

On simulating the model will run and apply the drag forces to the particles.

Comments

  • satri
    satri Altair Community Member
    edited July 2023

    suppose i get the field data from a solver like ansys when i export the data i will export the CGNS file should I export just the components? and what is the format in which i should export X,Y,Z,Vx,Vy,Vz or X,Vx,Y,Vy,Z,Vz, and should i include magnitude too? Please let me know

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited July 2023

    suppose i get the field data from a solver like ansys when i export the data i will export the CGNS file should I export just the components? and what is the format in which i should export X,Y,Z,Vx,Vy,Vz or X,Vx,Y,Vy,Z,Vz, and should i include magnitude too? Please let me know

    hi Shyam,

    If you export 'Velocity' as CGNS Ansys should format the file according to the CGNS standard, so I believe you don't have to choose the order yourself, just ensuring you have a velocity vector exported.

    Alternatively you can import it as a .txt file where you can specify the format:

    https://2022.help.altair.com/2022.2/EDEM/Creator/Physics/Field_Data_Manager/new_topic.htm

     

    Regards

    Stephen

     

  • satri
    satri Altair Community Member
    edited July 2023

    Hello ..

    I am trying to import body force from fluent and when i go to the particle body force section in physics section of create, i do not see the imported body force from the field data. please let me know how to fix this issue.

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited July 2023

    Hello ..

    I am trying to import body force from fluent and when i go to the particle body force section in physics section of create, i do not see the imported body force from the field data. please let me know how to fix this issue.

    Hi Shyam,

     

    Are you importing a flow field from Fluent, is this CGNS format?  Are there any errors shown when importing the file?  

     

    You can also import a custom flow field as a text file: https://2022.help.altair.com/2022.2/EDEM/Creator/Physics/Field_Data_Manager/Importing_Field_Data.htm?rhhlterm=cgns&rhsearch=cgns

     

    Regards

    Stephen

  • 康 振
    康 振 New Altair Community Member
    edited June 26

    Hello, I am loading the Volume Force API and compiling a. DLL file myself. However, I encountered the following error while loading: External Force: Preference File Error. Could you please help me answer what may be causing this?

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited June 26
    康 振 said:

    Hello, I am loading the Volume Force API and compiling a. DLL file myself. However, I encountered the following error while loading: External Force: Preference File Error. Could you please help me answer what may be causing this?

    Hi, typially the models have a 'setup' function.  For example in CFieldQuery.cpp the CFieldQuery::setup function reads "prefFile" which gets the name of the file from CFieldQuery::getPreferenceFileName.  The start of the code has the string:

    const string CFieldQuery::PREFS_FILE = "field_query_prefs.txt";

    Which defines the preference .txt file.  When loading a .dll into EDEM, which happens when adding it to the Creator Physics section or when opening a simulation which already has it added, EDEM will run the setup function and check if this file exists.  It checks to see if the file exists in the same location as the simulation .dem file is saved to.

    So you need to make sure the .txt file has the correct name and exits in the correct folder.  Otherwise the code will run:

     

        if (!prefsFile)
        {
            return false;
        }

    and you get the error.


    Regards

    Stephen

     

  • Community Guest
    Community Guest New Altair Community Member
    edited June 26

    Hi, typially the models have a 'setup' function.  For example in CFieldQuery.cpp the CFieldQuery::setup function reads "prefFile" which gets the name of the file from CFieldQuery::getPreferenceFileName.  The start of the code has the string:

    const string CFieldQuery::PREFS_FILE = "field_query_prefs.txt";

    Which defines the preference .txt file.  When loading a .dll into EDEM, which happens when adding it to the Creator Physics section or when opening a simulation which already has it added, EDEM will run the setup function and check if this file exists.  It checks to see if the file exists in the same location as the simulation .dem file is saved to.

    So you need to make sure the .txt file has the correct name and exits in the correct folder.  Otherwise the code will run:

     

        if (!prefsFile)
        {
            return false;
        }

    and you get the error.


    Regards

    Stephen

     

    Thank you for your answer. It has been very helpful to me. I overlooked this file and now the problem has been resolved. Thank you again.

  • Community Guest
    Community Guest New Altair Community Member
    edited June 26

    Sorry to bother you again, but after solving the previous problem, it reported an error again when calculating:WARNING : External Force : test1 - Particle Body Force Plugin indicated it is not ready to start processing at this time.Could you please help answer what may be causing this

     

  • 康 振
    康 振 New Altair Community Member
    edited June 26

    Sorry to bother you again, but after solving the previous problem, it reported an error again when calculating:WARNING : External Force : test1 - Particle Body Force Plugin indicated it is not ready to start processing at this time.Could you please help answer what may be causing this.

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited June 26
    康 振 said:

    Sorry to bother you again, but after solving the previous problem, it reported an error again when calculating:WARNING : External Force : test1 - Particle Body Force Plugin indicated it is not ready to start processing at this time.Could you please help answer what may be causing this.

    Hi,

    No problem, this is a similar issue in some ways to the previous case.  When you setup a case with a field you will typically import a field into the EDEM Creator > Physics > Field Data Manager section and this field is assigned a name.  You can change the name and it's this name which the API code is looking for to be able to differentiate between fields.

    In the CFieldQuery.cpp there is a CFieldQuery::starting function.  This is called on pressing play in the EDEM Simulator.  One thing this does is check the field name and if it' doesn't exist it returns false:

     

        //Acquire the required field data with respect to its specific name
        m_velocityField     = dynamic_cast<IFieldApi_1_1*>(m_fieldManager->getApi(eField, 1, 0, velocityFieldDataName));
        m_vorticityField    = dynamic_cast<IFieldApi_1_1*>(m_fieldManager->getApi(eField, 1, 0, vorticityFieldDataName));
        


        if (nullptr == m_velocityField)
        {
            return false;
        }
        if (nullptr == m_vorticityField)
        {
            return false;
        }

     

    There are two fields expected above and these names are defined in the code, these must match exactly what is set in the EDEM Creator:

     

    char velocityFieldDataName[NApi::API_BASIC_STRING_LENGTH] = "Velocity";
    char vorticityFieldDataName[NApi::API_BASIC_STRING_LENGTH] = "Vorticity";

     

    Regards

    Stephen