# output a compute calculated in loop

Dear lammps users,
In a part of my input file I divide my simulation box to multiple regions (number of regions are {bini}) and for reach region use a different temperature ({tmp}.

label thermostatloop

variable ithermostat loop \${bini}

variable boundary1 equal ({ithermostat}-1)*({binwidth}+\${binspace})

variable boundary2 equal ({ithermostat}-1)*({binwidth}+{binspace})+{binwidth}

region region\${ithermostat} block EDGE EDGE EDGE EDGE {boundary1} {boundary2} units box

compute temp\${ithermostat} nonboundary temp/region region\${ithermostat}

variable tmp equal {T_sl}+({ithermostat}-1-{bin_melt})*{G}({binwidth}+{binspace})-{G}*{Vp}({istep}-1)*{n_step}*0.002

fix thermostat\${ithermostat} nonboundary temp/rescale 1 {tmp} {tmp} 1.0 1.0

fix_modify thermostat\${ithermostat} temp temp\${ithermostat}

next ithermostat

jump SELF thermostatloop

The temperatures of all regions will change every few time steps which we is not the subject of this email ( this part is related to change of all temperatures by time : -{G}*{Vp}({istep}-1)*{n_step}0.002. Now I have two questions:
1- In my code I first wanted to define a variable for the temperature of each region as
variable T_ {ithermostat} equal {T_sl}+({ithermostat}-1-{bin_melt})
{G}*({binwidth}+{binspace})-{G}
{Vp}*({istep}-1)*{n_step}*0.002 but in that case in code I had to write fix thermostat{ithermostat} nonboundary temp/rescale 1 { T_ {ithermostat}} { T_ {ithermostat}} 1.0 1.0

That I had problem because I guess lammps did not understand { T_ {ithermostat}}. an it gives the following error:

ERROR on proc 7: Substitution for illegal variable T_\${ithermostat (src/input.cpp:545)

Last command: fix thermostat\${ithermostat} nonboundary temp/rescale 1 {T_{ithermostat}} {T_{ithermostat}} 1.0 1.0

That’s why I update the variable tmp to set the temperature of each region. Can you think of another way to save the temperature of each region in a separate variable?

2- I would like to output the temperature each region calculated by compute temp\${ithermostat} . and in thermo I do not want to manually output the computes as c_temp1 c_temp2 and etc., is there any way to output the computes in a loop?

Thanks,
Sepideh