diff --git a/tools/Makefile b/tools/Makefile index 599184471b..6e4c93e925 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -25,8 +25,12 @@ micelle2d: micelle2d.o data2xmovie: data2xmovie.o g++ -g data2xmovie.o -o data2xmovie +thermo_extract: thermo_extract.o + gcc -g thermo_extract.o -o thermo_extract + clean: rm binary2txt replicate restart2data chain micelle2d data2xmovie + rm thermo_extract rm *.o # diff --git a/tools/thermo_extract.c b/tools/thermo_extract.c new file mode 100644 index 0000000000..f79da3aca9 --- /dev/null +++ b/tools/thermo_extract.c @@ -0,0 +1,238 @@ +/* Written by Vikas Varshney + Dated Feb 22, 2007 + Contact Info: vikas.varshney@gmail.com + +The main purpose of this simple code is to extract thermodynamic +information such as Temperature, Pressure, Energy, etc from LAMMPS log +files, to plot them as a function of timestep in a simple plotting +programs such as xmgrace. + +Such plots are useful at initial stages of a simulation to make sure +the system is equilibrated. + +To run this program please compile it as + gcc -O3 thermo_extract.c -lm -o thermo_extract + +To extract temperature as a function of timestep, run the code as + +thermo_extract -p Temp -s/-m logfile1 logfile2 ... (all the log files) + +Time and temperature is output as 2 columns of data. It can +be re-directed to a file for plotting. + + -p for thermo parameter to extract + -s if the output format is single line, or + -m is the output format is multi line + +Few points + +1. The log file must contain a "thermo N" command where N is the + frequency of the thermo output. + +2. The name of the property "Temp" (in previous example) has to match + the thermo property in the logfile. + +3. The log file(s) can contain thermo info for multiple runs. + +4. Currently, you can only use one parameter as input, so for extracting + multiple properties, you have to run the code again. + +5. The Program uses the following keywords to keep track of the data in + the file. In general, these keywords are not used in input script (which + in turn get printed in log file) but are worth mentioning. + + PLEASE avoid using + "Dangerous", "Memory", "Step" and "Loop" in the input script + + "thermo" and "run" except when they are used to specify frequency of + thermo output and total number of steps to be run, respectively. + +*/ + +#include +#include +#include +#include +#include + +FILE *input; +char filename_input[100]; +char string1[100],*string2; +char temp[80]; +int j,k,check,timestep; +double datapoint; +int thermostylecounter,thermocounter,runcounter,totalsteps; +int narg1; +char *token; +char templl[80]; +int thermo[100]; +int run[100]; + +void scan_first_part() +{ + while(strcmp(temp,"Memory")) + fscanf(input,"%s ",&temp); +} + +void scan_data_multi(int temp1,char* chartemp) +{ + totalsteps=run[temp1]/thermo[temp1]+1; + for(j=0;j0) + {} + else + { + printf("Couldn't recognize parameter\n"); + exit(1); + } + + totalsteps=run[temp1]/thermo[temp1]+1; + for(j=0;j