How to define V2 bond creation time in custom factory?
Best Answers
-
Hi Qin,
You need to create a CREATIONTIME Custom Particle Property in your API factory, the details are in the Help:
Also the particle replacement tutorial has an API factory which uses this custom property. The tutorial contains the CReplacementFactory.cpp where this custom property is defined:
Regards
Stephen
0 -
Hi,
The Bond Creation Time is a Custom Property, so it has to be defined and then used.
Using the example, for the definition:
- In CReplacementFactory.h specify the name as a string, this is the name of the property in the code
static const std::string CREATIONTIME;
- In CReplacementFactory.cpp specify the name that will show up in the EDEM Creator and Analyst:
const string CReplacementFactory::CREATIONTIME = "Bond Creation Time";
- Also in CReplacementFactory.cpp define the number of custom properties (1) and the type. This is specifying that its a Particle custom property with 1 element and unit of time.
unsigned int CReplacementFactory::getNumberOfRequiredProperties(
const NApi::EPluginPropertyCategory category)
{
if (eParticle == category)
{
return 1;
}
else
{
return 0;
}
} bool CReplacementFactory::getDetailsForProperty(
unsigned int propertyIndex,
NApi::EPluginPropertyCategory category,
char name[NApi::CUSTOM_PROP_MAX_NAME_LENGTH],
NApi::EPluginPropertyDataTypes& dataType,
unsigned int& numberOfElements,
NApi::EPluginPropertyUnitTypes& unitType,
char initValBuff[NApi::BUFF_SIZE])
{
if (0 == propertyIndex &&
eParticle == category)
{
strncpy(name, CREATIONTIME.c_str(), NApi::CUSTOM_PROP_MAX_NAME_LENGTH);
dataType = eDouble;
numberOfElements = 1;
unitType = eTime;
return true;
}
else
{
return false;
}
}The above is all the definition of the property and you should not change this, as the definition needs to match what is set in the internal EDEM models.
We then need to set the value of the property. The particles will bond when they are in contact and both particles in contact have the same value of CREATIONTIME property and that value also matches the current simulation time.
So to change the code here instead of += time you can set it to += 10 if you wanted the particles to bond at 10 s, or add in a variable you can read from a text file.
double* m_bond_creation_time = propData->getDelta(CREATIONTIME.c_str());
m_bond_creation_time[0] += time;Regards
Stephen
0 -
You may also need to add the usesCustomProperties if this is not set to true:
For the .cpp:
bool CReplacementFactory::usesCustomProperties()
{
return true;
}for the .h
virtual bool usesCustomProperties();
0 -
The bonding method works by setting this as a particle property, by default once it's set on creation of a particle it remains the property of this particle. Changing the bonding time after particles have been created would only impact new particles, which maybe what is happening in your case.
Regards
Stephen
1
Answers
-
Hi Qin,
You need to create a CREATIONTIME Custom Particle Property in your API factory, the details are in the Help:
Also the particle replacement tutorial has an API factory which uses this custom property. The tutorial contains the CReplacementFactory.cpp where this custom property is defined:
Regards
Stephen
0 -
Thank you, this should be the right direction.
But I still has few confusion.
bond creation time appears three times in the code, which one is decided one?
why does bond creation time in string form, not double?
0 -
If I only need a constant bonding creation time, which part should I change?
0 -
double* m_bond_creation_time = propData->getDelta(CREATIONTIME.c_str());
m_bond_creation_time[0] += time;static const std::string CREATIONTIME;
I do not understand how these two parts are connected, and the exact value of bonding time.
0 -
Hi,
The Bond Creation Time is a Custom Property, so it has to be defined and then used.
Using the example, for the definition:
- In CReplacementFactory.h specify the name as a string, this is the name of the property in the code
static const std::string CREATIONTIME;
- In CReplacementFactory.cpp specify the name that will show up in the EDEM Creator and Analyst:
const string CReplacementFactory::CREATIONTIME = "Bond Creation Time";
- Also in CReplacementFactory.cpp define the number of custom properties (1) and the type. This is specifying that its a Particle custom property with 1 element and unit of time.
unsigned int CReplacementFactory::getNumberOfRequiredProperties(
const NApi::EPluginPropertyCategory category)
{
if (eParticle == category)
{
return 1;
}
else
{
return 0;
}
} bool CReplacementFactory::getDetailsForProperty(
unsigned int propertyIndex,
NApi::EPluginPropertyCategory category,
char name[NApi::CUSTOM_PROP_MAX_NAME_LENGTH],
NApi::EPluginPropertyDataTypes& dataType,
unsigned int& numberOfElements,
NApi::EPluginPropertyUnitTypes& unitType,
char initValBuff[NApi::BUFF_SIZE])
{
if (0 == propertyIndex &&
eParticle == category)
{
strncpy(name, CREATIONTIME.c_str(), NApi::CUSTOM_PROP_MAX_NAME_LENGTH);
dataType = eDouble;
numberOfElements = 1;
unitType = eTime;
return true;
}
else
{
return false;
}
}The above is all the definition of the property and you should not change this, as the definition needs to match what is set in the internal EDEM models.
We then need to set the value of the property. The particles will bond when they are in contact and both particles in contact have the same value of CREATIONTIME property and that value also matches the current simulation time.
So to change the code here instead of += time you can set it to += 10 if you wanted the particles to bond at 10 s, or add in a variable you can read from a text file.
double* m_bond_creation_time = propData->getDelta(CREATIONTIME.c_str());
m_bond_creation_time[0] += time;Regards
Stephen
0 -
The packing goes smoothly, but EDEM flash quit.
0 -
You may also need to add the usesCustomProperties if this is not set to true:
For the .cpp:
bool CReplacementFactory::usesCustomProperties()
{
return true;
}for the .h
virtual bool usesCustomProperties();
0 -
yes, it works well now.
Thank you sir.
0 -
something's wrong with this method, the bonding is no longer created after I change the bonding time few times.
0 -
any more clear and simple way to define bonding time? those twists and turns makes it fragile and easy to error.
0 -
The bonding method works by setting this as a particle property, by default once it's set on creation of a particle it remains the property of this particle. Changing the bonding time after particles have been created would only impact new particles, which maybe what is happening in your case.
Regards
Stephen
1