Hi,
I am using LAMMPS (29 Sep 2021 - Update 3)
Is there a way to access a variable using fix addforce every time step, given that this variable is averaged over the last 1000 time steps using fix ave/time?
Example:
variable energyAtom atom ${massAtom}*vx*vx*1e10
compute energy_in group_fluid reduce/region inlet sum v_energyAtom
variable energy_density_in equal c_energy_in/(0.03*lx*ly*v_thickness_div)
variable Fin equal v_energy_density_in*(ly*v_thickness_div)/count(group_inlet)
compute energy_out group_fluid reduce/region outlet sum v_energyAtom
variable energy_density_out equal c_energy_out/(0.03*lx*ly*v_thickness)
variable Fout equal v_energy_density_out*(ly*v_thickness)/count(group_outlet)
## Average the momentum flux forxes (Fin and Fout) every 1000 time steps
fix mom_flux_forces group_fluid ave/time 10 100 1000 v_Fin v_Fout
variable net_mom_flux_force equal f_mom_flux_forces[1]-f_mom_flux_forces[2]
## And impose the net force every time step
fix mom_flux_force group_pump_dyn addforce v_net_mom_flux 0.0 0.0
This gives the error of time incompatibility
"ERROR: Variable net_mom_flux: Fix in variable not computed at a compatible time (../variable.cpp:1676)"
because “the variable attempts to access the fix on non-allowed timesteps”.
Indeed the first time-average will only be produced on the 1000th timestep and I can use:
fix .. addforce v_net_mom_flux 0.0 0.0 every 1000
but that is not what i want.
I simply want to access the time average of the variable in 0-1000 steps and use it in the fix addforce on the 1001th step, then average the 1-1001 steps and use it on the 1002nd step and so on. i.e. a moving average of the last N timesteps that is accessible every timestep. I would appreciate any help.
Thanks,
Mohamed Tarek ELEWA, M.Sc.
Karlsruhe Institute of Technology (KIT)
Institute for Applied Materials -
Reliability and Microstructure (IAM-ZM)