Accessing temperature in new normal model

Submitted by jtvanlew on Thu, 10/20/2016 - 22:18

Hello all,

disclaimer: i've only just begun learning c++ so please correct me when I use the wrong syntax...

I'm trying to build a new normal model that has temperature dependence on the normal force. I created a new normal_model_etc based on the standard hertz file. I've done the first few modifications and tested that up to this point i can actually compile LIGGGHTS without error. But now I'm trying to access temperature and am not sure how to proceed.

As far as I can tell, there's only a few files that are accessing the per/atom temperature property. So in my naivete I just went to fix_heat_gran_conduction.cpp and see that it seems to have automatic access to Temp[i] and Temp[j]. I guessed this came from including fix_heat_gran_conduction.h which, itself, includes fix_heat_gran.h where *Temp is a protected property.

Thus my best guess was to #include "fix_heat_gran_conduction.h". Then inside the surfacesIntersect method, i tried to declare a variable as being equal to Temp[1] just to see if I was able to access that property. But (probably obviously) get the error that "'Temp" was not declared in this scope.

Any suggestions?

ckloss's picture

ckloss | Fri, 10/21/2016 - 15:38

Hi jtvanlew ,

you'll have to implement a look-up for the fix which internally stores "Temp". Have a look at the code in fix_heat_gran.cpp and fix_scalar_transport_equation.cpp for how this is done!

Christoph

JohLoh | Thu, 10/27/2016 - 18:37

Hallo,
I try the same and I integrated the code linie:
fix_temp = static_cast(modify->find_fix_property("Temp","property/atom","scalar",0,0,style));
But I get the message that the variable style is not defined in this scope.
Cheers
Johannes

jtvanlew | Fri, 10/28/2016 - 03:25

Hi Johannes,

I've been trying loads of different things and actually just tried this same exact line of code tonight. The issue, i think, is that the "style" is a "Fix style" when in the fix_heat_gran.cpp. Actually, I never see "style" explicitly defined in the scope of fix_heat_gran.cpp but there is, on line 90, a reference to "this->style"

Unfortunately, I have no idea what 'type' style is in order to define one inside the scope of the new normal model and feed it into that static_cast.

Though I am glad to hear there is someone else working on a similar problem. If I make any progress I will for sure post about it on here.

Regards,
Jon

jon

jtvanlew | Fri, 10/28/2016 - 05:30

In "modify_liggghts.cpp" you can find the method

Fix* Modify::find_fix_property(const char *varname,const char *style,const char *svmstyle,int len1,int len2,const char *caller)

which shows that "style" needs to be of a type "const char *caller".

so that's a step at least

jon

jtvanlew | Mon, 10/31/2016 - 21:40

Hi Johannes,

I was able to get it working with the following:

fix_quantity=static_cast<FixPropertyAtom*>(modify->find_fix_property("Temp","property/atom","scalar",0,0,"heat/gran"));
Temp = fix_quantity->vector_atom;

note that the style is "heat/gran". Hope this gets what you're looking for!

Jon

jon

nasser225 | Fri, 10/28/2016 - 10:06

Hi jtvanlew ,

How did you compile liggghts with your new contact model? What procedure did you follow?

Thanks,

jtvanlew | Fri, 10/28/2016 - 22:05

i copied normal_model_hertz.h into a file like normal_model_hertz_newmodel.h

then in the preamble the normal model is given such as

#ifdef NORMAL_MODEL
NORMAL_MODEL(HERTZ_NEWMODEL,hertz/newmodel,5)
#else
#ifndef NORMAL_MODEL_HERTZ_NEWMODEL_H_
#define NORMAL_MODEL_HERTZ_NEWMODEL_H_

Note that if you have fewer/more normal models, that integer "5" would be different. Just look at all the different normal_model_*.h files and see how far they count up. Then lastly inside the class declaration, the new model must be noted...

namespace ContactModels
{
template<>
class NormalModel<HERTZ_NEWMODEL> : protected Pointers
{
public:
static const int MASK = CM_REGISTER_SETTINGS | CM_CONNECT_TO_PROPERTIES | CM_SURFACES_INTERSECT;
...
...
...
}
}

in the connectToProperties method there's also some changes so if you're making new material properties fixes that your normal model can get them from global_properties.cpp/h

LAMMPS/LIGGGHTS is smart enough that when you "make" in the src directory, it sees the new normal model and automatically adds it to the available normal model styles.

Hope that helps

jon

nasser225 | Sun, 10/30/2016 - 15:06

I have actually gone as far as you describe but Liggghts fails to compile source...I use 'Make fedora_fpic' and another alternative and both fail. Errors include 'class definition changed...' new model etc.

This happens as soon as I add my new model file to the source directory and try to compile...

Did you need to edit any other files at all? There seems to be references to properties and fixes used. I have analysed the model file down to each colon and seem to have understood the way the formulas and maths are being calculated etc. but I cannot get my new model script to compile with Liggghts and run!

Any help?