/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ #include "dump_vac.h" #include "stdlib.h" #include "string.h" #include "atom.h" #include "force.h" #include "domain.h" #include "region.h" #include "group.h" #include "update.h" #include "modify.h" #include "compute.h" #include "memory.h" #include "error.h" #include "output.h" #include "thermo.h" #include "comm.h" #include "integrate.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ DumpVAC::DumpVAC(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) { if (narg != 5) error->all("Illegal dump atom command"); // one-time file open if (multifile == 0) openfile(); } /* ---------------------------------------------------------------------- */ void DumpVAC::init() { size_one = 4; } /* ---------------------------------------------------------------------- */ int DumpVAC::count() { if (igroup == 0) return atom->nlocal; int *mask = atom->mask; int nlocal = atom->nlocal; int m = 0; for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) m++; return m; } /* ---------------------------------------------------------------------- */ void DumpVAC::write_header(int ndump) { double epot,ekin,temp,vol,press; output->thermo->compute_pe(); epot = output->thermo->potential_energy; temp = output->thermo->temperature->compute_scalar(); press = output->thermo->pressure->compute_scalar(); ekin = temp * 0.5 * output->thermo->temperature->dof * force->boltz; vol = (boxxhi-boxxlo)*(boxyhi-boxylo)*(boxzhi-boxzlo); fprintf(fp,"ITEM: TIMESTEP\n"); fprintf(fp,"%d\n",update->ntimestep); fprintf(fp,"ITEM: NUMBER OF ATOMS\n"); fprintf(fp,"%d\n",ndump); fprintf(fp,"ITEM: THERMODYNAMICS\n"); fprintf(fp,"%.2f %.2f %.2f %.2f %.2f %.2f\n",(epot+ekin),epot,ekin,temp,vol,press); fprintf(fp,"ITEM: ATOMS\n"); } /* ---------------------------------------------------------------------- */ int DumpVAC::pack() { int *tag = atom->tag; int *type = atom->type; int *mask = atom->mask; double **v = atom->v; int nlocal = atom->nlocal; int m = 0; for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { buf[m++] = tag[i]; buf[m++] = v[i][0]; buf[m++] = v[i][1]; buf[m++] = v[i][2]; } return m; } /* ---------------------------------------------------------------------- */ void DumpVAC::write_data(int n, double *buf) { int m = 0; for (int i = 0; i < n; i++) { fprintf(fp,"%d %g %g %g\n", static_cast (buf[m]), buf[m+1], buf[m+2],buf[m+3]); m += size_one; } }