How to count the number of broken bond in bonding V2?

Raheem Sterling_22160
Raheem Sterling_22160 Altair Community Member
edited September 2023 in Community Q&A

Hi,

Now I output the bondstatus of each contact and count the broken bonds in the third software. But I want to show the results in the EDEM->analyst tree, which kind of custom property should I use to achieve the function?

Thanks

Tagged:

Answers

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited August 2023

    Hi Raheem,


    You should have a Contact property called BondStatus

    BondStatus 1 means a particle is bonded, status 0 means it never had a bond and status = 2 means that the contact was bonded but has broken.

    It can be tricky to measure because if you have particle 1 and particle 2 in contact and their bonds break the bond status will change from 0 to 1 and then to 2 when the bond breaks.  If these two particles then loose contact and gain contact again, then this is a new contact and will show bond status 0.  So the broken bond status 2 only exists as long as the original contact exists.


    Regards

    Stephen

     

     

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited September 2023

    Hi Raheem,


    You should have a Contact property called BondStatus

    BondStatus 1 means a particle is bonded, status 0 means it never had a bond and status = 2 means that the contact was bonded but has broken.

    It can be tricky to measure because if you have particle 1 and particle 2 in contact and their bonds break the bond status will change from 0 to 1 and then to 2 when the bond breaks.  If these two particles then loose contact and gain contact again, then this is a new contact and will show bond status 0.  So the broken bond status 2 only exists as long as the original contact exists.


    Regards

    Stephen

     

     

    Hi Stephen,

    Sorry I missed your reply, until now, I defined the bond status in the way you said. And I count the number of bond status for each contact in Matlab. 

    But I am searching a way to defined a property to summarise the total number of broken bond in each step, I don't know if there is a interface to do it in EDEM directly, maybe simulation property. Beacuse my bond was broken in different type, I want to count the total number of them respectively in every step.

    Regard!

    Raheem

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited September 2023

    Hi Stephen,

    Sorry I missed your reply, until now, I defined the bond status in the way you said. And I count the number of bond status for each contact in Matlab. 

    But I am searching a way to defined a property to summarise the total number of broken bond in each step, I don't know if there is a interface to do it in EDEM directly, maybe simulation property. Beacuse my bond was broken in different type, I want to count the total number of them respectively in every step.

    Regard!

    Raheem

    Hi Raheem,


    It's not possible in the current physics models but you could implement it in the API.

     

    You would have to create a custom Simulation Property.  The Simulation Property is a global property that you could add +1 to each time a bond is broken, it would give a cumulative count of total broken bonds. 

    Regards

    Stephen

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited September 2023

    Hi Raheem,


    It's not possible in the current physics models but you could implement it in the API.

     

    You would have to create a custom Simulation Property.  The Simulation Property is a global property that you could add +1 to each time a bond is broken, it would give a cumulative count of total broken bonds. 

    Regards

    Stephen

    Hi stephen,

    Yes, I have used the simulationCustomPropertyManager to store this value, but in the analyst->simulation, there is no attribute of my own defined value. It was still in the "contact".

    First, I defined the manager in the starting():

    bool CBonded::starting(NApiCore::IApiManager_1_0& apiManager, int numThreads) {     NApiCore::ICustomPropertyManagerApi_1_0* simulationCustomPropertyManager         = static_cast<NApiCore::ICustomPropertyManagerApi_1_0*>(apiManager.getApi(eSimulationCustomPropertyManager, 1, 0));     iBROKEN_TYPE = simulationCustomPropertyManager->getPropertyIndex(BROKEN_TYPE.c_str());     return true; }

    Then I defined value to store the broken bonds: 

    NApi::ECalculateResult CBonded::calculateForce() {     const double* m_type = simulationCustomProperties->getValue(iBROKEN_TYPE);     double* m_typeDelta = simulationCustomProperties->getDelta(iBROKEN_TYPE);     if(bondbroken){      m_BondStatusDelta[0] += 1.0;             F_n = CSimple3DVector();             F_t = CSimple3DVector();             m_typeDelta[0] += 1; } }

    Finally, I added this custom property to the getDetailsForProperty with category esimulation. Did I missed or understood something?

    Best Regards!

    Raheem

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited September 2023

    Hi stephen,

    Yes, I have used the simulationCustomPropertyManager to store this value, but in the analyst->simulation, there is no attribute of my own defined value. It was still in the "contact".

    First, I defined the manager in the starting():

    bool CBonded::starting(NApiCore::IApiManager_1_0& apiManager, int numThreads) {     NApiCore::ICustomPropertyManagerApi_1_0* simulationCustomPropertyManager         = static_cast<NApiCore::ICustomPropertyManagerApi_1_0*>(apiManager.getApi(eSimulationCustomPropertyManager, 1, 0));     iBROKEN_TYPE = simulationCustomPropertyManager->getPropertyIndex(BROKEN_TYPE.c_str());     return true; }

    Then I defined value to store the broken bonds: 

    NApi::ECalculateResult CBonded::calculateForce() {     const double* m_type = simulationCustomProperties->getValue(iBROKEN_TYPE);     double* m_typeDelta = simulationCustomProperties->getDelta(iBROKEN_TYPE);     if(bondbroken){      m_BondStatusDelta[0] += 1.0;             F_n = CSimple3DVector();             F_t = CSimple3DVector();             m_typeDelta[0] += 1; } }

    Finally, I added this custom property to the getDetailsForProperty with category esimulation. Did I missed or understood something?

    Best Regards!

    Raheem

    Hi Raheem,


    That looks correct, so long as the property is also defined in the get number of properties and get details of property functions.

    For simulation properties post-processing you should be able to query it in the data export or graphing tools.


    Regards

    Stephen

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited September 2023

    Hi Raheem,


    That looks correct, so long as the property is also defined in the get number of properties and get details of property functions.

    For simulation properties post-processing you should be able to query it in the data export or graphing tools.


    Regards

    Stephen

    Hi Stephen,

    I have seen the custom property in the post-processing with some change in the get number of properties and get details of property functions.

    In the get number of properties, I missed the eSimulation first.

    unsigned int CBonded::getNumberOfRequiredProperties(const EPluginPropertyCategory category) {     if (eContact == category)     {         return 6;     }     if (eSimulation == category)      {         return 1;     }     else     {         return 0;     } } bool CBonded::getDetailsForProperty(){ if (6 == propertyIndex &&         eSimulation == category)     {         strncpy(name, BROKEN_TYPE.c_str(), NApi::CUSTOM_PROP_MAX_NAME_LENGTH);         dataType = eDouble;         numberOfElements = 3; // m_typeDelta has three elements         unitType = eNone;         std::ostringstream oss;         oss << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0;         strncpy(initValBuff, oss.str().c_str(), NApi::BUFF_SIZE);         return true;     } }

    But with these setting, I got the nullptr of "m_typeDelta[n]" and EDEM crashed, Am I  missed something?  Or are there any example of simulationProperty?

    Regards!

    Raheem

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited September 2023

    Hi Stephen,

    I have seen the custom property in the post-processing with some change in the get number of properties and get details of property functions.

    In the get number of properties, I missed the eSimulation first.

    unsigned int CBonded::getNumberOfRequiredProperties(const EPluginPropertyCategory category) {     if (eContact == category)     {         return 6;     }     if (eSimulation == category)      {         return 1;     }     else     {         return 0;     } } bool CBonded::getDetailsForProperty(){ if (6 == propertyIndex &&         eSimulation == category)     {         strncpy(name, BROKEN_TYPE.c_str(), NApi::CUSTOM_PROP_MAX_NAME_LENGTH);         dataType = eDouble;         numberOfElements = 3; // m_typeDelta has three elements         unitType = eNone;         std::ostringstream oss;         oss << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0;         strncpy(initValBuff, oss.str().c_str(), NApi::BUFF_SIZE);         return true;     } }

    But with these setting, I got the nullptr of "m_typeDelta[n]" and EDEM crashed, Am I  missed something?  Or are there any example of simulationProperty?

    Regards!

    Raheem

    Hi Raheem,

    For getNumberOfRequiredProperties it should be 1 for the Simulation properties (assuming you just have 1 and no others) as you have set, so that looks correct.

    For  getDetailsForProperty should be property index 0 for the simulation property.  these are per property so you would have 6 contact properties index 0-5 and 1 simulation property index 0. Adding particle properties or similar would then start these properties from index 0.  I don't tend to include the ostringstream part as this is setting the initial values and they default to 0.0 anyway. 

    bool CBonded::getDetailsForProperty() { 	if (0 == propertyIndex && 		eSimulation == category) 	{ 		strncpy(name, BROKEN_TYPE.c_str()); 		dataType = eDouble; 		numberOfElements = 3; // m_typeDelta has three elements 		unitType = eNone; 		return true; 	} }

    So long as you are querying m_typeDelta[n] where n is 0, 1 or 2 for your 3 element property then that looks OK.

    To add there is a usesCustomProperties() bool that should be in the code to return true. If you have started from an existing model with custom properties in i'd expect that is already set.

    Regards

    Stephen

     

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited September 2023

    Hi Raheem,

    For getNumberOfRequiredProperties it should be 1 for the Simulation properties (assuming you just have 1 and no others) as you have set, so that looks correct.

    For  getDetailsForProperty should be property index 0 for the simulation property.  these are per property so you would have 6 contact properties index 0-5 and 1 simulation property index 0. Adding particle properties or similar would then start these properties from index 0.  I don't tend to include the ostringstream part as this is setting the initial values and they default to 0.0 anyway. 

    bool CBonded::getDetailsForProperty() { 	if (0 == propertyIndex && 		eSimulation == category) 	{ 		strncpy(name, BROKEN_TYPE.c_str()); 		dataType = eDouble; 		numberOfElements = 3; // m_typeDelta has three elements 		unitType = eNone; 		return true; 	} }

    So long as you are querying m_typeDelta[n] where n is 0, 1 or 2 for your 3 element property then that looks OK.

    To add there is a usesCustomProperties() bool that should be in the code to return true. If you have started from an existing model with custom properties in i'd expect that is already set.

    Regards

    Stephen

     

    Thanks for your patience, Stephen. 

    1. As you said, if I set the property index 0 for the simulation property, it seems had conflict with the contact custom property property index 0. Because in the setting with 3 elements, in query is only one element. But if I assign the property index 6, it had 3 components. image

    2. All the simulation decks were exported without custom property.

    Regards!

    Raheem