Using result from fix ave/chunk in user built code

Hi all,

I am seeking to use the average density in my code. I know that you can get the average of the density of the system by using fix ave/chunk and defining the entire system as a chunk to get the system average. I am also fairly confident that you can get the calculated average density by doing fix->which[index][m] where m corresponds to the type of average that you are using.

How do you ensure that the fix is first calculated before using its result in a kspace package/step?
Christian

Hi all,

I am seeking to use the average density in my code.

what kind of average: spatial? time? both? what kind of density: number? mass? charge? neither?

below, i am guessing that you are asking about the mass density for the entire system.

I know that you can get the average of the density of the system by using fix ave/chunk and defining the entire system as a chunk to get the system average. I am also fairly confident that you can get the calculated average density by doing fix->which[index][m] where m corresponds to the type of average that you are using.

why so overly complex and complicated?

there is already thermo keyword that computes the density of the system.
since thermo keywords are exposed to variables, you can easily look up in variable.cpp, that something like:

double value;
output->thermo->evaluate_keyword(“density”,&value);

will give you the current (mass) density straight away in the proper units assigned to “value”.

or you can dig into what kind of low-level methods are called to access the data more directly and adjust to what specific settings you are looking for.

averaging fixes are called much later in the time step progression than force computing styles, so going through a fix would only make sense, if you need the time average, and then it should not matter much, that you are missing one step.

How do you ensure that the fix is first calculated before using its result in a kspace package/step?

you would have to modify the fix class so that is called earlier in the time step progression. it would work for some properties, but not others, as this fix would violate expected behavior.

axel.