Hi all. I am writing a fix that creates a pe_atom compute which it needs the information from at every time step and during the fix init stage. In modify::init() this is called before the compute list is initially created. I am concerned however that since it is called before verlet::init() which calls the ev_setup() function that I can't get it to set the eflag to the correct value during verlet::setup(). Is there a way to get this functionality? Currently, the code segfaults during my fix's setup call when it the compute tries to access the pair::eatom array which is still NULL.
As an alternative, I can rewrite the code to take as an input the name of a previously registered computed. This is suboptimal (requires more of the user) but doable... although I'd rather know that will work first before I do a rewrite.
Thanks in advance,
Conceptually, I don't think it makes sense to try to invoke any
compute during the init() stage.
In this case, I don't see how it could possibly work. You are asking
a compute pe/atom to
have information about the energy of each atom which only comes from the
pair (bond, etc) styles having done their computation. But that computation
has not been done yet. It won't happen for the first time until the
The setup() method of each fix is called at the end of verlet::setup().
All of this logic applies whether the fix creates the compute or the
user passes the
fix a compute previously defined in the input script.
Hi Steve, sorry, I don't think I explained what I'd like very well. I agree, I don't need the information until the fix:setup phase, which is after the initial force calculation has been performed. My concern is that the fix can't create the necessary compute until the fix::init phase, which comes after verlet::init and ev_setup. Without the PE compute instantiated before ev_setup, I can't figure out how to get the eflag = 3 during the initial force calculation. Despite me trying a few things, it is always 0 then. My question is then: how do I get eflag = 3 during verlet::setup if my fix can't create the PE compute until after ev_setup is called prior to the first timestep? I hope this makes more sense.
Can your fix create the compute in its constructor? That is what
other fixes that creates computes do, e.g. fix nvt/npt create temp and pressure
computes when constructed. I believe all fixes are passed vflag with
their setup() call, and the pair styles have computed energy/virial, so
they should be good to go at the setup phase.
Hi Steve, so the fix could but it only needs it in response to some user input so it could be inefficient. Perhaps what I'll try is creating the compute on construction and then deleting it during init if it's not needed. I'll let you know how that works. Thanks for your help.
If a compute is never invoked, it is not inefficient.