Hi. I am trying to write a plugin in particle property that will contain water content in the particle. In the viscoplastic material model I will initialize the water content of each composition. For initialization of water content in each particle it will check the volume fractions of the compositions in it and their initial water content. In subsequent time steps, it will:
a) Ensure that it is not first time step,
b) Check the water content from previous time step for each composition in that particle,
c) Check the pressure and temperature information of the particle in current time step,
d) Input text files for each composition where the maximum water content allowed for that composition is stated for given pressure temperature and,
e) Check whether previous time step value is greater or less than this and update the current water content for that composition in the particle accordingly, then finally update the water content of the particle based on volume fractions of the compositions present.
f) After this I intend to use this water content of the particle for calculation of viscosity and density by including a water content dependence.
I understand accessing the time step as this->get_timestep().
This is how I intend to make the update work.
std::vector initial_water_capacity; // to include water content of compositions from previous time step
std::vector water_capacity; // to update water content of compositions
double pressure = solution[this->introspection().component_indices.pressure];
double temperature = solution[this->introspection().component_indices.temperature]
for (unsigned int j = 0; j < this->n_compositional_fields(); j++)
{ std::vector vecT, vecP, vecw;
double Tm, Pr, wa;
std::ifstream inputFile("composition_j_water.txt");
while(inputFile >> Tm >> Pr >> wa)
{
vecT.push_back(Tm);
vecP.push_back(Pr);
vecw.push_back(wa);
}
double Tmax = *max_element(vecT.begin(), vecT.end());
double Pmax = *max_element(vecP.begin(), vecP.end());
double distance[vecT.size()];
for(int i(0); i < vecT.size(); i++)
{
distance[i] = sqrt(pow((vecT[i]-temperature)/Tmax,2.0)+pow((vecP[i]-pressure)/Pmax,2.0));
}
double dist_min(distance[0]);
for(int i(0); i < vecT.size(); i++)
{
if(distance[i] < dist_min)
dist_min = distance[i];
}
double wnew;
for(int i(0); i < vecT.size(); i++)
{
if(distance[i] == dist_min)
{
if(initial_water_capacity[j] >= vecw[i])
wnew = vecw[i];
else
wnew = initial_water_capacity[j];
}
}
water_capacity[j]= wnew;
}
I don’t understand how I can access previous time step information for the particles, if taking text file inputs is going to work, and how I can include a water content dependence in viscoplastic plugin for viscosity and density for the particles from this plugin.
I am new to ASPECT and would appreciate the help very much.
Regards,
Mainak