2006-09-28 03:51:49 +08:00
|
|
|
/* -----------------------------------------------------------------------
|
|
|
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
|
|
|
www.cs.sandia.gov/~sjplimp/lammps.html
|
|
|
|
Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
|
|
|
|
|
|
|
|
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.
|
|
|
|
------------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
// Convert a LAMMPS binary restart file into an ASCII text data file
|
|
|
|
//
|
|
|
|
// Syntax: restart2data restart-file data-file
|
|
|
|
//
|
|
|
|
// this serial code must be compiled on a platform that can read the binary
|
|
|
|
// restart file since binary formats are not compatible across all platforms
|
|
|
|
// restart-file can have a '%' character to indicate a multiproc restart
|
|
|
|
// file as written by LAMMPS
|
|
|
|
|
2007-06-21 02:39:21 +08:00
|
|
|
#include "math.h"
|
2006-09-28 03:51:49 +08:00
|
|
|
#include "stdio.h"
|
|
|
|
#include "stdlib.h"
|
|
|
|
#include "string.h"
|
|
|
|
|
|
|
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
// same as write_restart.cpp
|
|
|
|
|
|
|
|
enum{VERSION,UNITS,NTIMESTEP,DIMENSION,NPROCS,PROCGRID_0,PROCGRID_1,PROCGRID_2,
|
|
|
|
NEWTON_PAIR,NEWTON_BOND,XPERIODIC,YPERIODIC,ZPERIODIC,
|
|
|
|
BOUNDARY_00,BOUNDARY_01,BOUNDARY_10,BOUNDARY_11,BOUNDARY_20,BOUNDARY_21,
|
|
|
|
ATOM_STYLE,NATOMS,NTYPES,
|
|
|
|
NBONDS,NBONDTYPES,BOND_PER_ATOM,
|
|
|
|
NANGLES,NANGLETYPES,ANGLE_PER_ATOM,
|
|
|
|
NDIHEDRALS,NDIHEDRALTYPES,DIHEDRAL_PER_ATOM,
|
|
|
|
NIMPROPERS,NIMPROPERTYPES,IMPROPER_PER_ATOM,
|
|
|
|
BOXLO_0,BOXHI_0,BOXLO_1,BOXHI_1,BOXLO_2,BOXHI_2,
|
|
|
|
SPECIAL_LJ_1,SPECIAL_LJ_2,SPECIAL_LJ_3,
|
|
|
|
SPECIAL_COUL_1,SPECIAL_COUL_2,SPECIAL_COUL_3,
|
|
|
|
XY,XZ,YZ};
|
|
|
|
enum{MASS,SHAPE,DIPOLE};
|
|
|
|
enum{PAIR,BOND,ANGLE,DIHEDRAL,IMPROPER};
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// Data class to hold problem
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
class Data {
|
|
|
|
public:
|
|
|
|
|
|
|
|
// global settings
|
|
|
|
|
|
|
|
char *version;
|
|
|
|
int ntimestep;
|
|
|
|
int nprocs;
|
|
|
|
char *unit_style;
|
|
|
|
int dimension;
|
|
|
|
int px,py,pz;
|
|
|
|
int newton_pair,newton_bond;
|
|
|
|
int xperiodic,yperiodic,zperiodic;
|
|
|
|
int boundary[3][2];
|
|
|
|
|
|
|
|
char *atom_style;
|
|
|
|
int style_angle,style_atomic,style_bond,style_charge,style_dipole;
|
2007-06-20 21:17:04 +08:00
|
|
|
int style_dpd,style_ellipsoid,style_full,style_granular;
|
|
|
|
int style_hybrid,style_molecular;
|
2006-09-28 03:51:49 +08:00
|
|
|
|
|
|
|
int natoms,nbonds,nangles,ndihedrals,nimpropers;
|
|
|
|
int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes;
|
|
|
|
int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom;
|
2007-03-08 08:59:28 +08:00
|
|
|
int triclinic;
|
|
|
|
double xlo,xhi,ylo,yhi,zlo,zhi,xy,xz,yz;
|
2006-09-28 03:51:49 +08:00
|
|
|
double special_lj[4],special_coul[4];
|
|
|
|
|
|
|
|
// force fields
|
|
|
|
|
|
|
|
char *pair_style,*bond_style,*angle_style,*dihedral_style,*improper_style;
|
|
|
|
|
|
|
|
double *pair_buck_A,*pair_buck_rho,*pair_buck_C;
|
2007-06-20 21:17:04 +08:00
|
|
|
double *pair_colloid_A12,*pair_colloid_sigma;
|
|
|
|
double *pair_colloid_d1,*pair_colloid_d2;
|
|
|
|
double *pair_dipole_epsilon,*pair_dipole_sigma;
|
2006-09-28 03:51:49 +08:00
|
|
|
double *pair_dpd_a0,*pair_dpd_gamma;
|
|
|
|
double *pair_charmm_epsilon,*pair_charmm_sigma;
|
|
|
|
double *pair_charmm_eps14,*pair_charmm_sigma14;
|
|
|
|
double *pair_class2_epsilon,*pair_class2_sigma;
|
2007-06-21 02:39:21 +08:00
|
|
|
double *pair_gb_epsilon,*pair_gb_sigma;
|
|
|
|
double *pair_gb_epsa,*pair_gb_epsb,*pair_gb_epsc;
|
2006-09-28 03:51:49 +08:00
|
|
|
double *pair_lj_epsilon,*pair_lj_sigma;
|
|
|
|
double *pair_ljexpand_epsilon,*pair_ljexpand_sigma,*pair_ljexpand_shift;
|
|
|
|
double *pair_morse_d0,*pair_morse_alpha,*pair_morse_r0;
|
|
|
|
double *pair_soft_start,*pair_soft_stop;
|
|
|
|
double *pair_yukawa_A;
|
|
|
|
|
|
|
|
double *bond_class2_r0,*bond_class2_k2,*bond_class2_k3,*bond_class2_k4;
|
|
|
|
double *bond_fene_k,*bond_fene_r0,*bond_fene_epsilon,*bond_fene_sigma;
|
|
|
|
double *bond_feneexpand_k,*bond_feneexpand_r0;
|
|
|
|
double *bond_feneexpand_epsilon,*bond_feneexpand_sigma;
|
|
|
|
double *bond_feneexpand_shift;
|
|
|
|
double *bond_harmonic_k,*bond_harmonic_r0;
|
|
|
|
double *bond_morse_d0,*bond_morse_alpha,*bond_morse_r0;
|
|
|
|
double *bond_nonlinear_epsilon,*bond_nonlinear_r0,*bond_nonlinear_lamda;
|
|
|
|
|
|
|
|
double *angle_charmm_k,*angle_charmm_theta0;
|
|
|
|
double *angle_charmm_k_ub,*angle_charmm_r_ub;
|
|
|
|
double *angle_class2_theta0;
|
|
|
|
double *angle_class2_k2,*angle_class2_k3,*angle_class2_k4;
|
|
|
|
double *angle_class2_bb_k,*angle_class2_bb_r1,*angle_class2_bb_r2;
|
|
|
|
double *angle_class2_ba_k1,*angle_class2_ba_k2;
|
|
|
|
double *angle_class2_ba_r1,*angle_class2_ba_r2;
|
|
|
|
double *angle_cosine_k;
|
|
|
|
double *angle_cosine_squared_k,*angle_cosine_squared_theta0;
|
|
|
|
double *angle_harmonic_k,*angle_harmonic_theta0;
|
|
|
|
|
|
|
|
double *dihedral_charmm_k,*dihedral_charmm_weight;
|
|
|
|
int *dihedral_charmm_multiplicity,*dihedral_charmm_sign;
|
|
|
|
double *dihedral_class2_k1,*dihedral_class2_k2,*dihedral_class2_k3;
|
|
|
|
double *dihedral_class2_phi1,*dihedral_class2_phi2,*dihedral_class2_phi3;
|
|
|
|
double *dihedral_class2_mbt_f1,*dihedral_class2_mbt_f2;
|
|
|
|
double *dihedral_class2_mbt_f3,*dihedral_class2_mbt_r0;
|
|
|
|
double *dihedral_class2_ebt_f1_1,*dihedral_class2_ebt_f2_1;
|
|
|
|
double *dihedral_class2_ebt_f3_1,*dihedral_class2_ebt_r0_1;
|
|
|
|
double *dihedral_class2_ebt_f1_2,*dihedral_class2_ebt_f2_2;
|
|
|
|
double *dihedral_class2_ebt_f3_2,*dihedral_class2_ebt_r0_2;
|
|
|
|
double *dihedral_class2_at_f1_1,*dihedral_class2_at_f2_1;
|
|
|
|
double *dihedral_class2_at_f3_1,*dihedral_class2_at_theta0_1;
|
|
|
|
double *dihedral_class2_at_f1_2,*dihedral_class2_at_f2_2;
|
|
|
|
double *dihedral_class2_at_f3_2,*dihedral_class2_at_theta0_2;
|
|
|
|
double *dihedral_class2_aat_k;
|
|
|
|
double *dihedral_class2_aat_theta0_1,*dihedral_class2_aat_theta0_2;
|
|
|
|
double *dihedral_class2_bb13_k;
|
|
|
|
double *dihedral_class2_bb13_r10,*dihedral_class2_bb13_r30;
|
|
|
|
double *dihedral_harmonic_k;
|
|
|
|
int *dihedral_harmonic_multiplicity,*dihedral_harmonic_sign;
|
|
|
|
double *dihedral_helix_aphi,*dihedral_helix_bphi,*dihedral_helix_cphi;
|
|
|
|
double *dihedral_multi_a1,*dihedral_multi_a2,*dihedral_multi_a3;
|
|
|
|
double *dihedral_multi_a4,*dihedral_multi_a5;
|
2006-09-29 00:35:11 +08:00
|
|
|
double *dihedral_opls_k1,*dihedral_opls_k2;
|
|
|
|
double *dihedral_opls_k3,*dihedral_opls_k4;
|
2006-09-28 03:51:49 +08:00
|
|
|
|
|
|
|
double *improper_class2_k0,*improper_class2_chi0;
|
|
|
|
double *improper_class2_aa_k1,*improper_class2_aa_k2,*improper_class2_aa_k3;
|
|
|
|
double *improper_class2_aa_theta0_1,*improper_class2_aa_theta0_2;
|
|
|
|
double *improper_class2_aa_theta0_3;
|
|
|
|
double *improper_cvff_k;
|
|
|
|
int *improper_cvff_sign,*improper_cvff_multiplicity;
|
|
|
|
double *improper_harmonic_k,*improper_harmonic_chi;
|
|
|
|
|
|
|
|
// atom quantities
|
|
|
|
|
|
|
|
int iatoms,ibonds,iangles,idihedrals,iimpropers;
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
double *mass,*shape,*dipole;
|
2006-09-28 03:51:49 +08:00
|
|
|
double *x,*y,*z,*vx,*vy,*vz;
|
2007-06-20 21:17:04 +08:00
|
|
|
double *xphix,*xphiy,*xphiz,*omegax,*omegay,*omegaz;
|
2006-09-28 03:51:49 +08:00
|
|
|
int *tag,*type,*mask,*image;
|
|
|
|
int *molecule;
|
|
|
|
double *q,*mux,*muy,*muz,*radius,*density;
|
2007-06-20 21:17:04 +08:00
|
|
|
double *quatw,*quati,*quatj,*quatk,*angmomx,*angmomy,*angmomz;
|
2006-09-28 03:51:49 +08:00
|
|
|
int *bond_type,*angle_type,*dihedral_type,*improper_type;
|
|
|
|
int *bond_atom1,*bond_atom2;
|
|
|
|
int *angle_atom1,*angle_atom2,*angle_atom3;
|
|
|
|
int *dihedral_atom1,*dihedral_atom2,*dihedral_atom3,*dihedral_atom4;
|
|
|
|
int *improper_atom1,*improper_atom2,*improper_atom3,*improper_atom4;
|
|
|
|
|
|
|
|
// functions
|
|
|
|
|
|
|
|
Data();
|
|
|
|
void stats();
|
|
|
|
void write(FILE *);
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
void write_atom_angle(FILE *, int, int, int, int);
|
|
|
|
void write_atom_atomic(FILE *, int, int, int, int);
|
|
|
|
void write_atom_bond(FILE *, int, int, int, int);
|
|
|
|
void write_atom_charge(FILE *, int, int, int, int);
|
|
|
|
void write_atom_dipole(FILE *, int, int, int, int);
|
|
|
|
void write_atom_dpd(FILE *, int, int, int, int);
|
|
|
|
void write_atom_ellipsoid(FILE *, int, int, int, int);
|
|
|
|
void write_atom_full(FILE *, int, int, int, int);
|
|
|
|
void write_atom_granular(FILE *, int, int, int, int);
|
|
|
|
void write_atom_molecular(FILE *, int, int, int, int);
|
|
|
|
|
|
|
|
void write_atom_angle_extra(FILE *, int);
|
|
|
|
void write_atom_atomic_extra(FILE *, int);
|
|
|
|
void write_atom_bond_extra(FILE *, int);
|
|
|
|
void write_atom_charge_extra(FILE *, int);
|
|
|
|
void write_atom_dipole_extra(FILE *, int);
|
|
|
|
void write_atom_dpd_extra(FILE *, int);
|
|
|
|
void write_atom_ellipsoid_extra(FILE *, int);
|
|
|
|
void write_atom_full_extra(FILE *, int);
|
|
|
|
void write_atom_granular_extra(FILE *, int);
|
|
|
|
void write_atom_molecular_extra(FILE *, int);
|
|
|
|
|
|
|
|
void write_vel_angle(FILE *, int);
|
|
|
|
void write_vel_atomic(FILE *, int);
|
|
|
|
void write_vel_bond(FILE *, int);
|
|
|
|
void write_vel_charge(FILE *, int);
|
|
|
|
void write_vel_dipole(FILE *, int);
|
|
|
|
void write_vel_dpd(FILE *, int);
|
|
|
|
void write_vel_ellipsoid(FILE *, int);
|
|
|
|
void write_vel_full(FILE *, int);
|
|
|
|
void write_vel_granular(FILE *, int);
|
|
|
|
void write_vel_molecular(FILE *, int);
|
|
|
|
|
|
|
|
void write_vel_angle_extra(FILE *, int);
|
|
|
|
void write_vel_atomic_extra(FILE *, int);
|
|
|
|
void write_vel_bond_extra(FILE *, int);
|
|
|
|
void write_vel_charge_extra(FILE *, int);
|
|
|
|
void write_vel_dipole_extra(FILE *, int);
|
|
|
|
void write_vel_dpd_extra(FILE *, int);
|
|
|
|
void write_vel_ellipsoid_extra(FILE *, int);
|
|
|
|
void write_vel_full_extra(FILE *, int);
|
|
|
|
void write_vel_granular_extra(FILE *, int);
|
|
|
|
void write_vel_molecular_extra(FILE *, int);
|
2006-09-28 03:51:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// function prototypes
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void header(FILE *, Data &);
|
2007-06-20 21:17:04 +08:00
|
|
|
void set_style(char *, Data &, int);
|
2006-09-28 03:51:49 +08:00
|
|
|
void groups(FILE *);
|
2007-06-20 21:17:04 +08:00
|
|
|
void type_arrays(FILE *, Data &);
|
2006-09-28 03:51:49 +08:00
|
|
|
void force_fields(FILE *, Data &);
|
|
|
|
void modify(FILE *);
|
|
|
|
void pair(FILE *fp, Data &data, char *style, int flag);
|
|
|
|
void bond(FILE *fp, Data &data);
|
|
|
|
void angle(FILE *fp, Data &data);
|
|
|
|
void dihedral(FILE *fp, Data &data);
|
|
|
|
void improper(FILE *fp, Data &data);
|
|
|
|
int atom(double *, Data &data);
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
void allocate_angle(Data &data);
|
|
|
|
void allocate_atomic(Data &data);
|
|
|
|
void allocate_bond(Data &data);
|
|
|
|
void allocate_charge(Data &data);
|
|
|
|
void allocate_dipole(Data &data);
|
|
|
|
void allocate_dpd(Data &data);
|
|
|
|
void allocate_ellipsoid(Data &data);
|
|
|
|
void allocate_full(Data &data);
|
|
|
|
void allocate_granular(Data &data);
|
|
|
|
void allocate_molecular(Data &data);
|
|
|
|
|
|
|
|
int atom_angle(double *, Data &, int);
|
|
|
|
int atom_atomic(double *, Data &, int);
|
|
|
|
int atom_bond(double *, Data &, int);
|
|
|
|
int atom_charge(double *, Data &, int);
|
|
|
|
int atom_dipole(double *, Data &, int);
|
|
|
|
int atom_dpd(double *, Data &, int);
|
|
|
|
int atom_ellipsoid(double *, Data &, int);
|
|
|
|
int atom_full(double *, Data &, int);
|
|
|
|
int atom_granular(double *, Data &, int);
|
|
|
|
int atom_molecular(double *, Data &, int);
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
int read_int(FILE *fp);
|
|
|
|
double read_double(FILE *fp);
|
|
|
|
char *read_char(FILE *fp);
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// main program
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
// syntax error check
|
|
|
|
|
|
|
|
if (argc != 3) {
|
|
|
|
printf("Syntax: restart2data restart-file data-file\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if restart file contains '%', file = filename with % replaced by "base"
|
|
|
|
// else file = single file
|
|
|
|
|
|
|
|
int multiproc;
|
|
|
|
char *file,*ptr;
|
|
|
|
|
|
|
|
if (ptr = strchr(argv[1],'%')) {
|
|
|
|
multiproc = 1;
|
|
|
|
file = new char[strlen(argv[1]) + 16];
|
|
|
|
*ptr = '\0';
|
|
|
|
sprintf(file,"%s%s%s",argv[1],"base",ptr+1);
|
|
|
|
} else {
|
|
|
|
multiproc = 0;
|
|
|
|
file = argv[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
// open single restart file or base file for multiproc case
|
|
|
|
|
|
|
|
printf("Reading restart file ...\n");
|
|
|
|
FILE *fp = fopen(file,"rb");
|
|
|
|
if (fp == NULL) {
|
|
|
|
printf("ERROR: Cannot open restart file %s\n",file);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// read beginning of restart file
|
|
|
|
|
|
|
|
Data data;
|
|
|
|
|
|
|
|
header(fp,data);
|
|
|
|
groups(fp);
|
2007-06-20 21:17:04 +08:00
|
|
|
type_arrays(fp,data);
|
2006-09-28 03:51:49 +08:00
|
|
|
force_fields(fp,data);
|
|
|
|
modify(fp);
|
|
|
|
|
|
|
|
// read atoms from single or multiple restart files
|
|
|
|
|
|
|
|
double *buf = NULL;
|
|
|
|
int n,m;
|
|
|
|
int maxbuf = 0;
|
|
|
|
data.iatoms = data.ibonds = data.iangles =
|
|
|
|
data.idihedrals = data.iimpropers = 0;
|
|
|
|
|
|
|
|
for (int iproc = 0; iproc < data.nprocs; iproc++) {
|
|
|
|
if (multiproc) {
|
|
|
|
fclose(fp);
|
|
|
|
sprintf(file,"%s%d%s",argv[1],iproc,ptr+1);
|
|
|
|
fp = fopen(file,"rb");
|
|
|
|
if (fp == NULL) {
|
|
|
|
printf("ERROR: Cannot open restart file %s\n",file);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
n = read_int(fp);
|
|
|
|
|
|
|
|
if (n > maxbuf) {
|
|
|
|
maxbuf = n;
|
|
|
|
delete [] buf;
|
|
|
|
buf = new double[maxbuf];
|
|
|
|
}
|
|
|
|
|
|
|
|
fread(buf,sizeof(double),n,fp);
|
|
|
|
|
|
|
|
m = 0;
|
|
|
|
while (m < n) m += atom(&buf[m],data);
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
// print out stats
|
|
|
|
|
|
|
|
data.stats();
|
|
|
|
|
|
|
|
// write out data file
|
|
|
|
|
|
|
|
printf("Writing data file ...\n");
|
|
|
|
fp = fopen(argv[2],"w");
|
|
|
|
if (fp == NULL) {
|
|
|
|
printf("ERROR: Cannot open data file %s\n",argv[2]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
data.write(fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// read header of restart file
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void header(FILE *fp, Data &data)
|
|
|
|
{
|
2007-10-06 01:56:13 +08:00
|
|
|
char *version = "5 Oct 2007";
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-03-08 08:59:28 +08:00
|
|
|
data.triclinic = 0;
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
int flag;
|
|
|
|
flag = read_int(fp);
|
|
|
|
|
|
|
|
while (flag >= 0) {
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
if (flag == VERSION) {
|
2006-09-28 03:51:49 +08:00
|
|
|
data.version = read_char(fp);
|
|
|
|
if (strcmp(version,data.version) != 0) {
|
|
|
|
char *str = "Restart file version does not match restart2data version";
|
|
|
|
printf("WARNING %s\n",str);
|
|
|
|
printf(" restart2data version = %s\n",version);
|
|
|
|
}
|
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
else if (flag == UNITS) data.unit_style = read_char(fp);
|
|
|
|
else if (flag == NTIMESTEP) data.ntimestep = read_int(fp);
|
|
|
|
else if (flag == DIMENSION) data.dimension = read_int(fp);
|
|
|
|
else if (flag == NPROCS) data.nprocs = read_int(fp);
|
|
|
|
else if (flag == PROCGRID_0) data.px = read_int(fp);
|
|
|
|
else if (flag == PROCGRID_1) data.py = read_int(fp);
|
|
|
|
else if (flag == PROCGRID_2) data.pz = read_int(fp);
|
|
|
|
else if (flag == NEWTON_PAIR) data.newton_pair = read_int(fp);
|
|
|
|
else if (flag == NEWTON_BOND) data.newton_bond = read_int(fp);
|
|
|
|
else if (flag == XPERIODIC) data.xperiodic = read_int(fp);
|
|
|
|
else if (flag == YPERIODIC) data.yperiodic = read_int(fp);
|
2007-06-25 22:55:47 +08:00
|
|
|
else if (flag == ZPERIODIC) data.zperiodic = read_int(fp);
|
2007-06-20 21:17:04 +08:00
|
|
|
else if (flag == BOUNDARY_00) data.boundary[0][0] = read_int(fp);
|
|
|
|
else if (flag == BOUNDARY_01) data.boundary[0][1] = read_int(fp);
|
|
|
|
else if (flag == BOUNDARY_10) data.boundary[1][0] = read_int(fp);
|
|
|
|
else if (flag == BOUNDARY_11) data.boundary[1][1] = read_int(fp);
|
|
|
|
else if (flag == BOUNDARY_20) data.boundary[2][0] = read_int(fp);
|
|
|
|
else if (flag == BOUNDARY_21) data.boundary[2][1] = read_int(fp);
|
|
|
|
|
|
|
|
// if atom_style = hybrid:
|
|
|
|
// set data_style_hybrid to # of sub-styles
|
|
|
|
// read additional sub-class arguments
|
|
|
|
// set sub-styles to 1 to N
|
|
|
|
|
|
|
|
else if (flag == ATOM_STYLE) {
|
2006-09-28 03:51:49 +08:00
|
|
|
data.style_angle = data.style_atomic = data.style_bond =
|
|
|
|
data.style_charge = data.style_dipole = data.style_dpd =
|
2007-06-20 21:17:04 +08:00
|
|
|
data.style_ellipsoid = data.style_full = data.style_granular =
|
2006-09-28 03:51:49 +08:00
|
|
|
data.style_hybrid = data.style_molecular = 0;
|
|
|
|
|
|
|
|
data.atom_style = read_char(fp);
|
2007-06-20 21:17:04 +08:00
|
|
|
set_style(data.atom_style,data,1);
|
2006-09-28 03:51:49 +08:00
|
|
|
|
|
|
|
if (strcmp(data.atom_style,"hybrid") == 0) {
|
|
|
|
int nwords = read_int(fp);
|
2007-06-20 21:17:04 +08:00
|
|
|
set_style(data.atom_style,data,nwords);
|
2006-09-28 03:51:49 +08:00
|
|
|
char *substyle;
|
2007-06-20 21:17:04 +08:00
|
|
|
for (int i = 1; i <= nwords; i++) {
|
2006-09-28 03:51:49 +08:00
|
|
|
substyle = read_char(fp);
|
2007-06-20 21:17:04 +08:00
|
|
|
set_style(substyle,data,i);
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
else if (flag == NATOMS) data.natoms = static_cast<int> (read_double(fp));
|
|
|
|
else if (flag == NTYPES) data.ntypes = read_int(fp);
|
|
|
|
else if (flag == NBONDS) data.nbonds = read_int(fp);
|
|
|
|
else if (flag == NBONDTYPES) data.nbondtypes = read_int(fp);
|
|
|
|
else if (flag == BOND_PER_ATOM) data.bond_per_atom = read_int(fp);
|
|
|
|
else if (flag == NANGLES) data.nangles = read_int(fp);
|
|
|
|
else if (flag == NANGLETYPES) data.nangletypes = read_int(fp);
|
|
|
|
else if (flag == ANGLE_PER_ATOM) data.angle_per_atom = read_int(fp);
|
|
|
|
else if (flag == NDIHEDRALS) data.ndihedrals = read_int(fp);
|
|
|
|
else if (flag == NDIHEDRALTYPES) data.ndihedraltypes = read_int(fp);
|
|
|
|
else if (flag == DIHEDRAL_PER_ATOM) data.dihedral_per_atom = read_int(fp);
|
|
|
|
else if (flag == NIMPROPERS) data.nimpropers = read_int(fp);
|
|
|
|
else if (flag == NIMPROPERTYPES) data.nimpropertypes = read_int(fp);
|
|
|
|
else if (flag == IMPROPER_PER_ATOM) data.improper_per_atom = read_int(fp);
|
|
|
|
else if (flag == BOXLO_0) data.xlo = read_double(fp);
|
|
|
|
else if (flag == BOXHI_0) data.xhi = read_double(fp);
|
|
|
|
else if (flag == BOXLO_1) data.ylo = read_double(fp);
|
|
|
|
else if (flag == BOXHI_1) data.yhi = read_double(fp);
|
|
|
|
else if (flag == BOXLO_2) data.zlo = read_double(fp);
|
|
|
|
else if (flag == BOXHI_2) data.zhi = read_double(fp);
|
|
|
|
else if (flag == SPECIAL_LJ_1) data.special_lj[1] = read_double(fp);
|
|
|
|
else if (flag == SPECIAL_LJ_2) data.special_lj[2] = read_double(fp);
|
|
|
|
else if (flag == SPECIAL_LJ_3) data.special_lj[3] = read_double(fp);
|
|
|
|
else if (flag == SPECIAL_COUL_1) data.special_coul[1] = read_double(fp);
|
|
|
|
else if (flag == SPECIAL_COUL_2) data.special_coul[2] = read_double(fp);
|
|
|
|
else if (flag == SPECIAL_COUL_3) data.special_coul[3] = read_double(fp);
|
|
|
|
else if (flag == XY) {
|
2007-03-08 08:59:28 +08:00
|
|
|
data.triclinic = 1;
|
|
|
|
data.xy = read_double(fp);
|
2007-06-20 21:17:04 +08:00
|
|
|
} else if (flag == XZ) {
|
2007-03-08 08:59:28 +08:00
|
|
|
data.triclinic = 1;
|
|
|
|
data.xz = read_double(fp);
|
2007-06-20 21:17:04 +08:00
|
|
|
} else if (flag == YZ) {
|
2007-03-08 08:59:28 +08:00
|
|
|
data.triclinic = 1;
|
|
|
|
data.yz = read_double(fp);
|
|
|
|
} else {
|
2007-06-20 21:17:04 +08:00
|
|
|
printf("ERROR: Invalid flag in header section of restart file %d\n",
|
|
|
|
flag);
|
2006-09-28 03:51:49 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
flag = read_int(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// set atom style to flag
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void set_style(char *name, Data &data, int flag)
|
2006-09-28 03:51:49 +08:00
|
|
|
{
|
2007-06-20 21:17:04 +08:00
|
|
|
if (strcmp(name,"angle") == 0) data.style_angle = flag;
|
|
|
|
else if (strcmp(name,"atomic") == 0) data.style_atomic = flag;
|
|
|
|
else if (strcmp(name,"bond") == 0) data.style_bond = flag;
|
|
|
|
else if (strcmp(name,"charge") == 0) data.style_charge = flag;
|
|
|
|
else if (strcmp(name,"dipole") == 0) data.style_dipole = flag;
|
|
|
|
else if (strcmp(name,"dpd") == 0) data.style_dpd = flag;
|
|
|
|
else if (strcmp(name,"ellipsoid") == 0) data.style_ellipsoid = flag;
|
|
|
|
else if (strcmp(name,"full") == 0) data.style_full = flag;
|
|
|
|
else if (strcmp(name,"granular") == 0) data.style_granular = flag;
|
|
|
|
else if (strcmp(name,"hybrid") == 0) data.style_hybrid = flag;
|
|
|
|
else if (strcmp(name,"molecular") == 0) data.style_molecular = flag;
|
2006-09-28 03:51:49 +08:00
|
|
|
else {
|
|
|
|
printf("ERROR: Unknown atom style %s\n",name);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// read group info from restart file, just ignore it
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void groups(FILE *fp)
|
|
|
|
{
|
|
|
|
int ngroup = read_int(fp);
|
|
|
|
|
|
|
|
int n;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
for (int i = 0; i < ngroup; i++) {
|
|
|
|
name = read_char(fp);
|
|
|
|
delete [] name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
2007-06-20 21:17:04 +08:00
|
|
|
// read type arrays from restart file
|
2006-09-28 03:51:49 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
void type_arrays(FILE *fp, Data &data)
|
2006-09-28 03:51:49 +08:00
|
|
|
{
|
2007-06-20 21:17:04 +08:00
|
|
|
data.mass = NULL;
|
|
|
|
data.shape = NULL;
|
|
|
|
data.dipole = NULL;
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
int flag;
|
|
|
|
flag = read_int(fp);
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
while (flag >= 0) {
|
|
|
|
|
|
|
|
if (flag == MASS) {
|
|
|
|
data.mass = new double[data.ntypes+1];
|
|
|
|
fread(&data.mass[1],sizeof(double),data.ntypes,fp);
|
|
|
|
} else if (flag == SHAPE) {
|
|
|
|
data.dipole = new double[3*(data.ntypes+1)];
|
|
|
|
fread(&data.shape[3],sizeof(double),3*data.ntypes,fp);
|
|
|
|
} else if (flag == DIPOLE) {
|
|
|
|
data.dipole = new double[data.ntypes+1];
|
|
|
|
fread(&data.dipole[1],sizeof(double),data.ntypes,fp);
|
|
|
|
} else {
|
|
|
|
printf("ERROR: Invalid flag in type arrays section of restart file %d\n",
|
|
|
|
flag);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
flag = read_int(fp);
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// read force-field info from restart file
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void force_fields(FILE *fp, Data &data)
|
|
|
|
{
|
2007-06-20 21:17:04 +08:00
|
|
|
data.pair_style = data.bond_style = data.angle_style =
|
|
|
|
data.dihedral_style = data.improper_style = NULL;
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
int flag;
|
|
|
|
flag = read_int(fp);
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
while (flag >= 0) {
|
|
|
|
|
|
|
|
if (flag == PAIR) {
|
|
|
|
data.pair_style = read_char(fp);
|
|
|
|
pair(fp,data,data.pair_style,1);
|
|
|
|
} else if (flag == BOND) {
|
|
|
|
data.bond_style = read_char(fp);
|
|
|
|
bond(fp,data);
|
|
|
|
} else if (flag == ANGLE) {
|
|
|
|
data.angle_style = read_char(fp);
|
|
|
|
angle(fp,data);
|
|
|
|
} else if (flag == DIHEDRAL) {
|
|
|
|
data.dihedral_style = read_char(fp);
|
|
|
|
dihedral(fp,data);
|
|
|
|
} else if (flag == IMPROPER) {
|
|
|
|
data.improper_style = read_char(fp);
|
|
|
|
improper(fp,data);
|
|
|
|
} else {
|
|
|
|
printf("ERROR: Invalid flag in force fields section of restart file %d\n",
|
|
|
|
flag);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
flag = read_int(fp);
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// read fix info from restart file, just ignore it
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void modify(FILE *fp)
|
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
// nfix = # of fix entries with state
|
|
|
|
|
|
|
|
int nfix = read_int(fp);
|
|
|
|
|
|
|
|
// read each entry with id string, style string, chunk of data
|
|
|
|
|
|
|
|
for (int i = 0; i < nfix; i++) {
|
|
|
|
buf = read_char(fp); delete [] buf;
|
|
|
|
buf = read_char(fp); delete [] buf;
|
|
|
|
buf = read_char(fp); delete [] buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nfix = # of fix entries with peratom info
|
|
|
|
|
|
|
|
int nfix_peratom = read_int(fp);
|
|
|
|
|
|
|
|
// read each entry with id string, style string, maxsize of one atom data
|
|
|
|
|
|
|
|
for (int i = 0; i < nfix_peratom; i++) {
|
|
|
|
buf = read_char(fp); delete [] buf;
|
|
|
|
buf = read_char(fp); delete [] buf;
|
|
|
|
n = read_int(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// read atom info from restart file and store in data struct
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
int atom(double *buf, Data &data)
|
|
|
|
{
|
2007-06-20 21:17:04 +08:00
|
|
|
// allocate per-atom arrays
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
if (data.iatoms == 0) {
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
// common to all atom styles
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
data.x = new double[data.natoms];
|
|
|
|
data.y = new double[data.natoms];
|
|
|
|
data.z = new double[data.natoms];
|
|
|
|
data.tag = new int[data.natoms];
|
|
|
|
data.type = new int[data.natoms];
|
|
|
|
data.mask = new int[data.natoms];
|
|
|
|
data.image = new int[data.natoms];
|
|
|
|
data.vx = new double[data.natoms];
|
|
|
|
data.vy = new double[data.natoms];
|
|
|
|
data.vz = new double[data.natoms];
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
// style-specific arrays
|
|
|
|
// don't worry about re-allocating if style = hybrid
|
|
|
|
|
|
|
|
if (data.style_angle) allocate_angle(data);
|
|
|
|
if (data.style_atomic) allocate_atomic(data);
|
|
|
|
if (data.style_bond) allocate_bond(data);
|
|
|
|
if (data.style_charge) allocate_charge(data);
|
|
|
|
if (data.style_dipole) allocate_dipole(data);
|
|
|
|
if (data.style_dpd) allocate_dpd(data);
|
|
|
|
if (data.style_ellipsoid) allocate_ellipsoid(data);
|
|
|
|
if (data.style_full) allocate_full(data);
|
|
|
|
if (data.style_granular) allocate_granular(data);
|
|
|
|
if (data.style_molecular) allocate_molecular(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
// read atom quatities from buf
|
|
|
|
// if hybrid, loop over all sub-styles in order listed
|
|
|
|
// if hybrid, loop index k will match style setting to insure correct order
|
|
|
|
|
|
|
|
int nloop = 1;
|
|
|
|
if (data.style_hybrid) nloop = data.style_hybrid;
|
|
|
|
|
|
|
|
int iatoms = data.iatoms;
|
|
|
|
int m = 0;
|
|
|
|
for (int k = 1; k <= nloop; k++) {
|
|
|
|
if (k == data.style_angle) m += atom_angle(&buf[m],data,iatoms);
|
|
|
|
if (k == data.style_atomic) m += atom_atomic(&buf[m],data,iatoms);
|
|
|
|
if (k == data.style_bond) m += atom_bond(&buf[m],data,iatoms);
|
|
|
|
if (k == data.style_charge) m += atom_charge(&buf[m],data,iatoms);
|
|
|
|
if (k == data.style_dpd) m += atom_dpd(&buf[m],data,iatoms);
|
|
|
|
if (k == data.style_full) m += atom_full(&buf[m],data,iatoms);
|
|
|
|
if (k == data.style_granular) m += atom_granular(&buf[m],data,iatoms);
|
|
|
|
if (k == data.style_molecular) m += atom_molecular(&buf[m],data,iatoms);
|
|
|
|
}
|
|
|
|
|
|
|
|
data.iatoms++;
|
|
|
|
m = static_cast<int> (buf[0]);
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// read one atom's info from buffer
|
|
|
|
// one routine per atom style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
int atom_angle(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int type,atom1,atom2,atom3;
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
data.molecule[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
|
|
|
|
int n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] < atom1) {
|
|
|
|
data.bond_type[data.ibonds] = type;
|
|
|
|
data.bond_atom1[data.ibonds] = data.tag[iatoms];
|
|
|
|
data.bond_atom2[data.ibonds] = atom1;
|
|
|
|
data.ibonds++;
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
atom2 = static_cast<int> (buf[m++]);
|
|
|
|
atom3 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] == atom2) {
|
|
|
|
data.angle_type[data.iangles] = type;
|
|
|
|
data.angle_atom1[data.iangles] = atom1;
|
|
|
|
data.angle_atom2[data.iangles] = atom2;
|
|
|
|
data.angle_atom3[data.iangles] = atom3;
|
|
|
|
data.iangles++;
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
return m;
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
int atom_atomic(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
return m;
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
int atom_bond(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int type,atom1;
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
data.molecule[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
|
|
|
|
int n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] < atom1) {
|
|
|
|
data.bond_type[data.ibonds] = type;
|
|
|
|
data.bond_atom1[data.ibonds] = data.tag[iatoms];
|
|
|
|
data.bond_atom2[data.ibonds] = atom1;
|
|
|
|
data.ibonds++;
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
return m;
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
int atom_charge(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
2006-09-28 03:51:49 +08:00
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
data.q[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
int atom_dipole(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
data.q[iatoms] = buf[m++];
|
|
|
|
data.mux[iatoms] = buf[m++];
|
|
|
|
data.muy[iatoms] = buf[m++];
|
|
|
|
data.muz[iatoms] = buf[m++];
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
int atom_dpd(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
int atom_ellipsoid(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
data.quatw[iatoms] = buf[m++];
|
|
|
|
data.quati[iatoms] = buf[m++];
|
|
|
|
data.quatj[iatoms] = buf[m++];
|
|
|
|
data.quatk[iatoms] = buf[m++];
|
|
|
|
data.angmomx[iatoms] = buf[m++];
|
|
|
|
data.angmomy[iatoms] = buf[m++];
|
|
|
|
data.angmomz[iatoms] = buf[m++];
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
int atom_granular(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
data.radius[iatoms] = buf[m++];
|
|
|
|
data.density[iatoms] = buf[m++];
|
|
|
|
data.xphix[iatoms] = buf[m++];
|
|
|
|
data.xphiy[iatoms] = buf[m++];
|
|
|
|
data.xphiz[iatoms] = buf[m++];
|
|
|
|
data.omegax[iatoms] = buf[m++];
|
|
|
|
data.omegay[iatoms] = buf[m++];
|
|
|
|
data.omegaz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
int atom_full(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int type,atom1,atom2,atom3,atom4;
|
|
|
|
|
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
data.q[iatoms] = buf[m++];
|
|
|
|
data.molecule[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
|
|
|
|
int n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] < atom1) {
|
|
|
|
data.bond_type[data.ibonds] = type;
|
|
|
|
data.bond_atom1[data.ibonds] = data.tag[iatoms];
|
|
|
|
data.bond_atom2[data.ibonds] = atom1;
|
|
|
|
data.ibonds++;
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
atom2 = static_cast<int> (buf[m++]);
|
|
|
|
atom3 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] == atom2) {
|
|
|
|
data.angle_type[data.iangles] = type;
|
|
|
|
data.angle_atom1[data.iangles] = atom1;
|
|
|
|
data.angle_atom2[data.iangles] = atom2;
|
|
|
|
data.angle_atom3[data.iangles] = atom3;
|
|
|
|
data.iangles++;
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
atom2 = static_cast<int> (buf[m++]);
|
|
|
|
atom3 = static_cast<int> (buf[m++]);
|
|
|
|
atom4 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] == atom2) {
|
|
|
|
data.dihedral_type[data.idihedrals] = type;
|
|
|
|
data.dihedral_atom1[data.idihedrals] = atom1;
|
|
|
|
data.dihedral_atom2[data.idihedrals] = atom2;
|
|
|
|
data.dihedral_atom3[data.idihedrals] = atom3;
|
|
|
|
data.dihedral_atom4[data.idihedrals] = atom4;
|
|
|
|
data.idihedrals++;
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
atom2 = static_cast<int> (buf[m++]);
|
|
|
|
atom3 = static_cast<int> (buf[m++]);
|
|
|
|
atom4 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] == atom2) {
|
|
|
|
data.improper_type[data.iimpropers] = type;
|
|
|
|
data.improper_atom1[data.iimpropers] = atom1;
|
|
|
|
data.improper_atom2[data.iimpropers] = atom2;
|
|
|
|
data.improper_atom3[data.iimpropers] = atom3;
|
|
|
|
data.improper_atom4[data.iimpropers] = atom4;
|
|
|
|
data.iimpropers++;
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
int atom_molecular(double *buf, Data &data, int iatoms)
|
|
|
|
{
|
|
|
|
int type,atom1,atom2,atom3,atom4;
|
|
|
|
|
|
|
|
int m = 1;
|
|
|
|
data.x[iatoms] = buf[m++];
|
|
|
|
data.y[iatoms] = buf[m++];
|
|
|
|
data.z[iatoms] = buf[m++];
|
|
|
|
data.tag[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.type[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.mask[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.image[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
data.vx[iatoms] = buf[m++];
|
|
|
|
data.vy[iatoms] = buf[m++];
|
|
|
|
data.vz[iatoms] = buf[m++];
|
|
|
|
|
|
|
|
data.molecule[iatoms] = static_cast<int> (buf[m++]);
|
|
|
|
|
|
|
|
int n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] < atom1) {
|
|
|
|
data.bond_type[data.ibonds] = type;
|
|
|
|
data.bond_atom1[data.ibonds] = data.tag[iatoms];
|
|
|
|
data.bond_atom2[data.ibonds] = atom1;
|
|
|
|
data.ibonds++;
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
atom2 = static_cast<int> (buf[m++]);
|
|
|
|
atom3 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] == atom2) {
|
|
|
|
data.angle_type[data.iangles] = type;
|
|
|
|
data.angle_atom1[data.iangles] = atom1;
|
|
|
|
data.angle_atom2[data.iangles] = atom2;
|
|
|
|
data.angle_atom3[data.iangles] = atom3;
|
|
|
|
data.iangles++;
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
atom2 = static_cast<int> (buf[m++]);
|
|
|
|
atom3 = static_cast<int> (buf[m++]);
|
|
|
|
atom4 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] == atom2) {
|
|
|
|
data.dihedral_type[data.idihedrals] = type;
|
|
|
|
data.dihedral_atom1[data.idihedrals] = atom1;
|
|
|
|
data.dihedral_atom2[data.idihedrals] = atom2;
|
|
|
|
data.dihedral_atom3[data.idihedrals] = atom3;
|
|
|
|
data.dihedral_atom4[data.idihedrals] = atom4;
|
|
|
|
data.idihedrals++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
n = static_cast<int> (buf[m++]);
|
|
|
|
for (int k = 0; k < n; k++) {
|
|
|
|
type = static_cast<int> (buf[m++]);
|
|
|
|
atom1 = static_cast<int> (buf[m++]);
|
|
|
|
atom2 = static_cast<int> (buf[m++]);
|
|
|
|
atom3 = static_cast<int> (buf[m++]);
|
|
|
|
atom4 = static_cast<int> (buf[m++]);
|
|
|
|
if (data.newton_bond || data.tag[iatoms] == atom2) {
|
|
|
|
data.improper_type[data.iimpropers] = type;
|
|
|
|
data.improper_atom1[data.iimpropers] = atom1;
|
|
|
|
data.improper_atom2[data.iimpropers] = atom2;
|
|
|
|
data.improper_atom3[data.iimpropers] = atom3;
|
|
|
|
data.improper_atom4[data.iimpropers] = atom4;
|
|
|
|
data.iimpropers++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// per-atom memory allocation routines
|
|
|
|
// one routine per atom style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void allocate_angle(Data &data)
|
|
|
|
{
|
|
|
|
data.molecule = new int[data.natoms];
|
|
|
|
data.bond_type = new int[data.nbonds];
|
|
|
|
data.bond_atom1 = new int[data.nbonds];
|
|
|
|
data.bond_atom2 = new int[data.nbonds];
|
|
|
|
data.angle_type = new int[data.nangles];
|
|
|
|
data.angle_atom1 = new int[data.nangles];
|
|
|
|
data.angle_atom2 = new int[data.nangles];
|
|
|
|
data.angle_atom3 = new int[data.nangles];
|
|
|
|
}
|
|
|
|
|
|
|
|
void allocate_atomic(Data &data) {}
|
|
|
|
|
|
|
|
void allocate_bond(Data &data)
|
|
|
|
{
|
|
|
|
data.molecule = new int[data.natoms];
|
|
|
|
data.bond_type = new int[data.nbonds];
|
|
|
|
data.bond_atom1 = new int[data.nbonds];
|
|
|
|
data.bond_atom2 = new int[data.nbonds];
|
|
|
|
}
|
|
|
|
|
|
|
|
void allocate_charge(Data &data)
|
|
|
|
{
|
|
|
|
data.q = new double[data.natoms];
|
|
|
|
}
|
|
|
|
|
|
|
|
void allocate_dipole(Data &data)
|
|
|
|
{
|
|
|
|
data.q = new double[data.natoms];
|
|
|
|
data.mux = new double[data.natoms];
|
|
|
|
data.muy = new double[data.natoms];
|
|
|
|
data.muz = new double[data.natoms];
|
|
|
|
}
|
|
|
|
|
|
|
|
void allocate_dpd(Data &data) {}
|
|
|
|
|
|
|
|
void allocate_full(Data &data)
|
|
|
|
{
|
|
|
|
data.q = new double[data.natoms];
|
|
|
|
data.molecule = new int[data.natoms];
|
|
|
|
data.bond_type = new int[data.nbonds];
|
|
|
|
data.bond_atom1 = new int[data.nbonds];
|
|
|
|
data.bond_atom2 = new int[data.nbonds];
|
|
|
|
data.angle_type = new int[data.nangles];
|
|
|
|
data.angle_atom1 = new int[data.nangles];
|
|
|
|
data.angle_atom2 = new int[data.nangles];
|
|
|
|
data.angle_atom3 = new int[data.nangles];
|
|
|
|
data.dihedral_type = new int[data.ndihedrals];
|
|
|
|
data.dihedral_atom1 = new int[data.ndihedrals];
|
|
|
|
data.dihedral_atom2 = new int[data.ndihedrals];
|
|
|
|
data.dihedral_atom3 = new int[data.ndihedrals];
|
|
|
|
data.dihedral_atom4 = new int[data.ndihedrals];
|
|
|
|
data.improper_type = new int[data.nimpropers];
|
|
|
|
data.improper_atom1 = new int[data.nimpropers];
|
|
|
|
data.improper_atom2 = new int[data.nimpropers];
|
|
|
|
data.improper_atom3 = new int[data.nimpropers];
|
|
|
|
data.improper_atom4 = new int[data.nimpropers];
|
|
|
|
}
|
|
|
|
|
|
|
|
void allocate_ellipsoid(Data &data)
|
|
|
|
{
|
|
|
|
data.quatw = new double[data.natoms];
|
|
|
|
data.quati = new double[data.natoms];
|
|
|
|
data.quatj = new double[data.natoms];
|
|
|
|
data.quatk = new double[data.natoms];
|
|
|
|
data.angmomx = new double[data.natoms];
|
|
|
|
data.angmomy = new double[data.natoms];
|
|
|
|
data.angmomz = new double[data.natoms];
|
|
|
|
}
|
|
|
|
|
|
|
|
void allocate_granular(Data &data)
|
|
|
|
{
|
|
|
|
data.radius = new double[data.natoms];
|
|
|
|
data.density = new double[data.natoms];
|
|
|
|
data.xphix = new double[data.natoms];
|
|
|
|
data.xphiy = new double[data.natoms];
|
|
|
|
data.xphiz = new double[data.natoms];
|
|
|
|
data.omegax = new double[data.natoms];
|
|
|
|
data.omegay = new double[data.natoms];
|
|
|
|
data.omegaz = new double[data.natoms];
|
|
|
|
}
|
|
|
|
|
|
|
|
void allocate_molecular(Data &data)
|
|
|
|
{
|
|
|
|
data.molecule = new int[data.natoms];
|
|
|
|
data.bond_type = new int[data.nbonds];
|
|
|
|
data.bond_atom1 = new int[data.nbonds];
|
|
|
|
data.bond_atom2 = new int[data.nbonds];
|
|
|
|
data.angle_type = new int[data.nangles];
|
|
|
|
data.angle_atom1 = new int[data.nangles];
|
|
|
|
data.angle_atom2 = new int[data.nangles];
|
|
|
|
data.angle_atom3 = new int[data.nangles];
|
|
|
|
data.dihedral_type = new int[data.ndihedrals];
|
|
|
|
data.dihedral_atom1 = new int[data.ndihedrals];
|
|
|
|
data.dihedral_atom2 = new int[data.ndihedrals];
|
|
|
|
data.dihedral_atom3 = new int[data.ndihedrals];
|
|
|
|
data.dihedral_atom4 = new int[data.ndihedrals];
|
|
|
|
data.improper_type = new int[data.nimpropers];
|
|
|
|
data.improper_atom1 = new int[data.nimpropers];
|
|
|
|
data.improper_atom2 = new int[data.nimpropers];
|
|
|
|
data.improper_atom3 = new int[data.nimpropers];
|
|
|
|
data.improper_atom4 = new int[data.nimpropers];
|
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// pair coeffs
|
|
|
|
// one section for each pair style
|
|
|
|
// flag = 1, read all coeff info and allocation arrays
|
|
|
|
// flag = 0, just read global settings (when called recursively by hybrid)
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void pair(FILE *fp, Data &data, char *style, int flag)
|
|
|
|
{
|
|
|
|
int i,j,m;
|
|
|
|
int itmp;
|
|
|
|
double rtmp;
|
|
|
|
|
|
|
|
if (strcmp(style,"none") == 0) {
|
|
|
|
|
|
|
|
} else if ((strcmp(style,"buck") == 0) ||
|
|
|
|
(strcmp(style,"buck/coul/cut") == 0) ||
|
|
|
|
(strcmp(style,"buck/coul/long") == 0)) {
|
|
|
|
|
|
|
|
if (strcmp(style,"buck") == 0) {
|
|
|
|
m = 0;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"buck/coul/cut") == 0) {
|
|
|
|
m = 1;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_lj_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"buck/coul/long") == 0) {
|
|
|
|
m = 0;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_lj_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_buck_A = new double[data.ntypes+1];
|
|
|
|
data.pair_buck_rho = new double[data.ntypes+1];
|
|
|
|
data.pair_buck_C = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
|
|
|
if (i == j) {
|
|
|
|
data.pair_buck_A[i] = read_double(fp);
|
|
|
|
data.pair_buck_rho[i] = read_double(fp);
|
|
|
|
data.pair_buck_C[i] = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
if (m) double cut_coul = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double buck_A = read_double(fp);
|
|
|
|
double buck_rho = read_double(fp);
|
|
|
|
double buck_C = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
if (m) double cut_coul = read_double(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
} else if (strcmp(style,"colloid") == 0) {
|
|
|
|
|
|
|
|
double cut_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_colloid_A12 = new double[data.ntypes+1];
|
|
|
|
data.pair_colloid_sigma = new double[data.ntypes+1];
|
|
|
|
data.pair_colloid_d1 = new double[data.ntypes+1];
|
|
|
|
data.pair_colloid_d2 = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
|
|
|
if (i == j) {
|
|
|
|
data.pair_colloid_A12[i] = read_double(fp);
|
|
|
|
data.pair_colloid_sigma[i] = read_double(fp);
|
|
|
|
data.pair_colloid_d1[i] = read_double(fp);
|
|
|
|
data.pair_colloid_d2[i] = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double colloid_A12 = read_double(fp);
|
|
|
|
double colloid_sigma = read_double(fp);
|
|
|
|
double colloid_d1 = read_double(fp);
|
|
|
|
double colloid_d2 = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strcmp(style,"dipole/cut") == 0) {
|
|
|
|
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_coul_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_dipole_epsilon = new double[data.ntypes+1];
|
|
|
|
data.pair_dipole_sigma = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
|
|
|
if (i == j) {
|
|
|
|
data.pair_dipole_epsilon[i] = read_double(fp);
|
|
|
|
data.pair_dipole_sigma[i] = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
double cut_coul = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double dipole_epsilon = read_double(fp);
|
|
|
|
double dipole_sigma = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
double cut_coul = read_double(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if (strcmp(style,"dpd") == 0) {
|
|
|
|
|
|
|
|
double temperature = read_double(fp);
|
|
|
|
double cut_global = read_double(fp);
|
|
|
|
int seed = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_dpd_a0 = new double[data.ntypes+1];
|
|
|
|
data.pair_dpd_gamma = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
2007-06-20 21:17:04 +08:00
|
|
|
if (i == j) {
|
|
|
|
data.pair_dpd_a0[i] = read_double(fp);
|
|
|
|
data.pair_dpd_gamma[i] = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double dpd_a0 = read_double(fp);
|
|
|
|
double dpd_gamma = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strcmp(style,"eam") == 0) {
|
2007-02-10 05:34:10 +08:00
|
|
|
} else if (strcmp(style,"eam/opt") == 0) {
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if (strcmp(style,"eam/alloy") == 0) {
|
2007-02-10 05:34:10 +08:00
|
|
|
} else if (strcmp(style,"eam/alloy/opt") == 0) {
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if (strcmp(style,"eam/fs") == 0) {
|
2007-02-10 05:34:10 +08:00
|
|
|
} else if (strcmp(style,"eam/fs/opt") == 0) {
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-21 02:39:21 +08:00
|
|
|
} else if (strcmp(style,"gayberne") == 0) {
|
|
|
|
|
|
|
|
double gamma = read_double(fp);
|
|
|
|
double upsilon = read_double(fp);
|
|
|
|
double mu = read_double(fp);
|
|
|
|
double cut_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_gb_epsilon = new double[data.ntypes+1];
|
|
|
|
data.pair_gb_sigma = new double[data.ntypes+1];
|
|
|
|
data.pair_gb_epsa = new double[data.ntypes+1];
|
|
|
|
data.pair_gb_epsb = new double[data.ntypes+1];
|
|
|
|
data.pair_gb_epsc = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (itmp) {
|
|
|
|
data.pair_gb_epsa[i] = read_double(fp);
|
|
|
|
data.pair_gb_epsb[i] = read_double(fp);
|
|
|
|
data.pair_gb_epsc[i] = read_double(fp);
|
|
|
|
data.pair_gb_epsa[i] = pow(data.pair_gb_epsa[i],-mu);
|
|
|
|
data.pair_gb_epsb[i] = pow(data.pair_gb_epsb[i],-mu);
|
|
|
|
data.pair_gb_epsc[i] = pow(data.pair_gb_epsc[i],-mu);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
|
|
|
if (i == j) {
|
|
|
|
data.pair_gb_epsilon[i] = read_double(fp);
|
|
|
|
data.pair_gb_sigma[i] = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double gb_epsilon = read_double(fp);
|
|
|
|
double gb_sigma = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if ((strcmp(style,"gran/history") == 0) ||
|
|
|
|
(strcmp(style,"gran/no_history") == 0) ||
|
|
|
|
(strcmp(style,"gran/hertzian") == 0)) {
|
|
|
|
|
|
|
|
double xkk = read_double(fp);
|
|
|
|
double gamman = read_double(fp);
|
|
|
|
double xmu = read_double(fp);
|
|
|
|
int dampflag = read_int(fp);
|
|
|
|
|
|
|
|
} else if ((strcmp(style,"lj/charmm/coul/charmm") == 0) ||
|
|
|
|
(strcmp(style,"lj/charmm/coul/charmm/implicit") == 0) ||
|
2007-06-20 21:17:04 +08:00
|
|
|
(strcmp(style,"lj/charmm/coul/long") == 0) ||
|
|
|
|
(strcmp(style,"lj/charmm/coul/long/opt") == 0)) {
|
2006-09-28 03:51:49 +08:00
|
|
|
|
|
|
|
if (strcmp(style,"lj/charmm/coul/charmm") == 0) {
|
|
|
|
double cut_lj_inner = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
double cut_coul_inner = read_double(fp);
|
|
|
|
double cut_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"lj/charmm/coul/charmm/implicit") == 0) {
|
|
|
|
double cut_lj_inner = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
double cut_coul_inner = read_double(fp);
|
|
|
|
double cut_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"lj/charmm/coul/long") == 0) {
|
|
|
|
double cut_lj_inner = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
double cut_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_charmm_epsilon = new double[data.ntypes+1];
|
|
|
|
data.pair_charmm_sigma = new double[data.ntypes+1];
|
|
|
|
data.pair_charmm_eps14 = new double[data.ntypes+1];
|
|
|
|
data.pair_charmm_sigma14 = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
|
|
|
if (i == j) {
|
|
|
|
data.pair_charmm_epsilon[i] = read_double(fp);
|
|
|
|
data.pair_charmm_sigma[i] = read_double(fp);
|
|
|
|
data.pair_charmm_eps14[i] = read_double(fp);
|
|
|
|
data.pair_charmm_sigma14[i] = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double charmm_epsilon = read_double(fp);
|
|
|
|
double charmm_sigma = read_double(fp);
|
|
|
|
double charmm_eps14 = read_double(fp);
|
|
|
|
double charmm_sigma14 = read_double(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ((strcmp(style,"lj/class2") == 0) ||
|
|
|
|
(strcmp(style,"lj/class2/coul/cut") == 0) ||
|
|
|
|
(strcmp(style,"lj/class2/coul/long") == 0)) {
|
|
|
|
|
|
|
|
if (strcmp(style,"lj/class2") == 0) {
|
|
|
|
m = 0;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"lj/class2/coul/cut") == 0) {
|
|
|
|
m = 1;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_lj_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"lj/class2/coul/long") == 0) {
|
|
|
|
m = 0;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_lj_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_class2_epsilon = new double[data.ntypes+1];
|
|
|
|
data.pair_class2_sigma = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
|
|
|
if (i == j) {
|
|
|
|
data.pair_class2_epsilon[i] = read_double(fp);
|
|
|
|
data.pair_class2_sigma[i] = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
if (m) double cut_coul = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double class2_epsilon = read_double(fp);
|
|
|
|
double class2_sigma = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
if (m) double cut_coul = read_double(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ((strcmp(style,"lj/cut") == 0) ||
|
2007-02-10 05:34:10 +08:00
|
|
|
(strcmp(style,"lj/cut/opt") == 0) ||
|
2006-09-28 03:51:49 +08:00
|
|
|
(strcmp(style,"lj/cut/coul/cut") == 0) ||
|
|
|
|
(strcmp(style,"lj/cut/coul/debye") == 0) ||
|
|
|
|
(strcmp(style,"lj/cut/coul/long") == 0) ||
|
|
|
|
(strcmp(style,"lj/cut/coul/long/tip4p") == 0)) {
|
|
|
|
|
|
|
|
if (strcmp(style,"lj/cut") == 0) {
|
|
|
|
m = 0;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"lj/cut/coul/cut") == 0) {
|
|
|
|
m = 1;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_lj_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"lj/cut/coul/debye") == 0) {
|
|
|
|
m = 1;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_lj_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"lj/cut/coul/long") == 0) {
|
|
|
|
m = 0;
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_lj_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
} else if (strcmp(style,"lj/cut/coul/long/tip4p") == 0) {
|
|
|
|
m = 0;
|
|
|
|
int typeO = read_int(fp);
|
|
|
|
int typeH = read_int(fp);
|
|
|
|
int typeB = read_int(fp);
|
|
|
|
int typeA = read_int(fp);
|
|
|
|
double qdist = read_double(fp);
|
|
|
|
double cut_lj_global = read_double(fp);
|
|
|
|
double cut_lj_coul = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_lj_epsilon = new double[data.ntypes+1];
|
|
|
|
data.pair_lj_sigma = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
|
|
|
if (i == j) {
|
|
|
|
data.pair_lj_epsilon[i] = read_double(fp);
|
|
|
|
data.pair_lj_sigma[i] = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
if (m) double cut_coul = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double lj_epsilon = read_double(fp);
|
|
|
|
double lj_sigma = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
if (m) double cut_coul = read_double(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strcmp(style,"lj/expand") == 0) {
|
|
|
|
|
|
|
|
double cut_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_ljexpand_epsilon = new double[data.ntypes+1];
|
|
|
|
data.pair_ljexpand_sigma = new double[data.ntypes+1];
|
|
|
|
data.pair_ljexpand_shift = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
2007-06-20 21:17:04 +08:00
|
|
|
if (i == j) {
|
|
|
|
data.pair_ljexpand_epsilon[i] = read_double(fp);
|
|
|
|
data.pair_ljexpand_sigma[i] = read_double(fp);
|
|
|
|
data.pair_ljexpand_shift[i] = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double ljexpand_epsilon = read_double(fp);
|
|
|
|
double ljexpand_sigma = read_double(fp);
|
|
|
|
double ljexpand_shift = read_double(fp);
|
|
|
|
double cut_lj = read_double(fp);
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-10 05:34:10 +08:00
|
|
|
} else if ((strcmp(style,"morse") == 0) ||
|
|
|
|
(strcmp(style,"morse/opt") == 0)) {
|
2006-09-28 03:51:49 +08:00
|
|
|
|
|
|
|
double cut_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_morse_d0 = new double[data.ntypes+1];
|
|
|
|
data.pair_morse_alpha = new double[data.ntypes+1];
|
|
|
|
data.pair_morse_r0 = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
2007-06-20 21:17:04 +08:00
|
|
|
if (i == j) {
|
|
|
|
data.pair_morse_d0[i] = read_double(fp);
|
|
|
|
data.pair_morse_alpha[i] = read_double(fp);
|
|
|
|
data.pair_morse_r0[i] = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double morse_d0 = read_double(fp);
|
|
|
|
double morse_alpha = read_double(fp);
|
|
|
|
double morse_r0 = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strcmp(style,"soft") == 0) {
|
|
|
|
|
|
|
|
double cut_global = read_double(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_soft_start = new double[data.ntypes+1];
|
|
|
|
data.pair_soft_stop = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
2007-06-20 21:17:04 +08:00
|
|
|
if (i == j) {
|
|
|
|
data.pair_soft_start[i] = read_double(fp);
|
|
|
|
data.pair_soft_stop[i] = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double soft_start = read_double(fp);
|
|
|
|
double soft_stop = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-30 07:25:38 +08:00
|
|
|
} else if (strcmp(style,"sw") == 0) {
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if (strcmp(style,"table") == 0) {
|
|
|
|
|
|
|
|
int tabstyle = read_int(fp);
|
|
|
|
int n = read_int(fp);
|
|
|
|
|
2007-01-30 07:25:38 +08:00
|
|
|
} else if (strcmp(style,"tersoff") == 0) {
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if (strcmp(style,"yukawa") == 0) {
|
|
|
|
|
|
|
|
double kappa = read_double(fp);
|
|
|
|
double cut_global = read_double(fp);
|
|
|
|
int offset_flag = read_int(fp);
|
|
|
|
int mix_flag = read_int(fp);
|
|
|
|
|
|
|
|
if (!flag) return;
|
|
|
|
|
|
|
|
data.pair_yukawa_A = new double[data.ntypes+1];
|
|
|
|
|
|
|
|
for (i = 1; i <= data.ntypes; i++)
|
|
|
|
for (j = i; j <= data.ntypes; j++) {
|
|
|
|
itmp = read_int(fp);
|
|
|
|
if (i == j && itmp == 0) {
|
|
|
|
printf("ERROR: Pair coeff %d,%d is not in restart file\n",i,j);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (itmp) {
|
2007-06-20 21:17:04 +08:00
|
|
|
if (i == j) {
|
|
|
|
data.pair_yukawa_A[i] = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
} else {
|
|
|
|
double yukawa_A = read_double(fp);
|
|
|
|
double cut = read_double(fp);
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strcmp(style,"hybrid") == 0) {
|
|
|
|
|
|
|
|
// for each substyle of hybrid,
|
|
|
|
// read its settings by calling pair() recursively with flag = 0
|
|
|
|
// so that coeff array allocation is skipped
|
|
|
|
|
|
|
|
int nstyles = read_int(fp);
|
|
|
|
for (int i = 0; i < nstyles; i++) {
|
|
|
|
char *substyle = read_char(fp);
|
|
|
|
pair(fp,data,substyle,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
printf("ERROR: Unknown pair style %s\n",style);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// bond coeffs
|
|
|
|
// one section for each bond style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void bond(FILE *fp, Data &data)
|
|
|
|
{
|
|
|
|
if (strcmp(data.bond_style,"none") == 0) {
|
|
|
|
|
|
|
|
} else if (strcmp(data.bond_style,"class2") == 0) {
|
|
|
|
|
|
|
|
data.bond_class2_r0 = new double[data.nbondtypes+1];
|
|
|
|
data.bond_class2_k2 = new double[data.nbondtypes+1];
|
|
|
|
data.bond_class2_k3 = new double[data.nbondtypes+1];
|
|
|
|
data.bond_class2_k4 = new double[data.nbondtypes+1];
|
|
|
|
fread(&data.bond_class2_r0[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_class2_k2[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_class2_k3[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_class2_k4[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.bond_style,"fene") == 0) {
|
|
|
|
|
|
|
|
data.bond_fene_k = new double[data.nbondtypes+1];
|
|
|
|
data.bond_fene_r0 = new double[data.nbondtypes+1];
|
|
|
|
data.bond_fene_epsilon = new double[data.nbondtypes+1];
|
|
|
|
data.bond_fene_sigma = new double[data.nbondtypes+1];
|
|
|
|
fread(&data.bond_fene_k[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_fene_r0[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_fene_epsilon[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_fene_sigma[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.bond_style,"fene/expand") == 0) {
|
|
|
|
|
|
|
|
data.bond_feneexpand_k = new double[data.nbondtypes+1];
|
|
|
|
data.bond_feneexpand_r0 = new double[data.nbondtypes+1];
|
|
|
|
data.bond_feneexpand_epsilon = new double[data.nbondtypes+1];
|
|
|
|
data.bond_feneexpand_sigma = new double[data.nbondtypes+1];
|
|
|
|
data.bond_feneexpand_shift = new double[data.nbondtypes+1];
|
|
|
|
fread(&data.bond_feneexpand_k[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_feneexpand_r0[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_feneexpand_epsilon[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_feneexpand_sigma[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_feneexpand_shift[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.bond_style,"harmonic") == 0) {
|
|
|
|
|
|
|
|
data.bond_harmonic_k = new double[data.nbondtypes+1];
|
|
|
|
data.bond_harmonic_r0 = new double[data.nbondtypes+1];
|
|
|
|
fread(&data.bond_harmonic_k[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_harmonic_r0[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.bond_style,"morse") == 0) {
|
|
|
|
|
|
|
|
data.bond_morse_d0 = new double[data.nbondtypes+1];
|
|
|
|
data.bond_morse_alpha = new double[data.nbondtypes+1];
|
|
|
|
data.bond_morse_r0 = new double[data.nbondtypes+1];
|
|
|
|
fread(&data.bond_morse_d0[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_morse_alpha[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_morse_r0[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.bond_style,"nonlinear") == 0) {
|
|
|
|
|
|
|
|
data.bond_nonlinear_epsilon = new double[data.nbondtypes+1];
|
|
|
|
data.bond_nonlinear_r0 = new double[data.nbondtypes+1];
|
|
|
|
data.bond_nonlinear_lamda = new double[data.nbondtypes+1];
|
|
|
|
fread(&data.bond_nonlinear_epsilon[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_nonlinear_r0[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
fread(&data.bond_nonlinear_lamda[1],sizeof(double),data.nbondtypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.bond_style,"hybrid") == 0) {
|
|
|
|
|
|
|
|
int nstyles = read_int(fp);
|
|
|
|
for (int i = 0; i < nstyles; i++)
|
|
|
|
char *substyle = read_char(fp);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
printf("ERROR: Unknown bond style %s\n",data.bond_style);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// angle coeffs
|
|
|
|
// one section for each angle style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void angle(FILE *fp, Data &data)
|
|
|
|
{
|
|
|
|
if (strcmp(data.angle_style,"none") == 0) {
|
|
|
|
|
|
|
|
} else if (strcmp(data.angle_style,"charmm") == 0) {
|
|
|
|
|
|
|
|
data.angle_charmm_k = new double[data.nangletypes+1];
|
|
|
|
data.angle_charmm_theta0 = new double[data.nangletypes+1];
|
|
|
|
data.angle_charmm_k_ub = new double[data.nangletypes+1];
|
|
|
|
data.angle_charmm_r_ub = new double[data.nangletypes+1];
|
|
|
|
fread(&data.angle_charmm_k[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_charmm_theta0[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_charmm_k_ub[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_charmm_r_ub[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.angle_style,"class2") == 0) {
|
|
|
|
|
|
|
|
data.angle_class2_theta0 = new double[data.nangletypes+1];
|
|
|
|
data.angle_class2_k2 = new double[data.nangletypes+1];
|
|
|
|
data.angle_class2_k3 = new double[data.nangletypes+1];
|
|
|
|
data.angle_class2_k4 = new double[data.nangletypes+1];
|
|
|
|
|
|
|
|
data.angle_class2_bb_k = new double[data.nangletypes+1];
|
|
|
|
data.angle_class2_bb_r1 = new double[data.nangletypes+1];
|
|
|
|
data.angle_class2_bb_r2 = new double[data.nangletypes+1];
|
|
|
|
|
|
|
|
data.angle_class2_ba_k1 = new double[data.nangletypes+1];
|
|
|
|
data.angle_class2_ba_k2 = new double[data.nangletypes+1];
|
|
|
|
data.angle_class2_ba_r1 = new double[data.nangletypes+1];
|
|
|
|
data.angle_class2_ba_r2 = new double[data.nangletypes+1];
|
|
|
|
|
|
|
|
fread(&data.angle_class2_theta0[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_class2_k2[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_class2_k3[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_class2_k4[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
|
|
|
|
fread(&data.angle_class2_bb_k[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_class2_bb_r1[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_class2_bb_r2[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
|
|
|
|
fread(&data.angle_class2_ba_k1[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_class2_ba_k2[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_class2_ba_r1[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_class2_ba_r2[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.angle_style,"cosine") == 0) {
|
|
|
|
|
|
|
|
data.angle_cosine_k = new double[data.nangletypes+1];
|
|
|
|
fread(&data.angle_cosine_k[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.angle_style,"cosine/squared") == 0) {
|
|
|
|
|
|
|
|
data.angle_cosine_squared_k = new double[data.nangletypes+1];
|
|
|
|
data.angle_cosine_squared_theta0 = new double[data.nangletypes+1];
|
|
|
|
fread(&data.angle_cosine_squared_k[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_cosine_squared_theta0[1],
|
|
|
|
sizeof(double),data.nangletypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.angle_style,"harmonic") == 0) {
|
|
|
|
|
|
|
|
data.angle_harmonic_k = new double[data.nangletypes+1];
|
|
|
|
data.angle_harmonic_theta0 = new double[data.nangletypes+1];
|
|
|
|
fread(&data.angle_harmonic_k[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
fread(&data.angle_harmonic_theta0[1],sizeof(double),data.nangletypes,fp);
|
|
|
|
|
2007-06-23 01:00:20 +08:00
|
|
|
} else if (strcmp(data.angle_style,"hybrid") == 0) {
|
|
|
|
|
|
|
|
int nstyles = read_int(fp);
|
|
|
|
for (int i = 0; i < nstyles; i++)
|
|
|
|
char *substyle = read_char(fp);
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else {
|
|
|
|
printf("ERROR: Unknown angle style %s\n",data.angle_style);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// dihedral coeffs
|
|
|
|
// one section for each dihedral style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void dihedral(FILE *fp, Data &data)
|
|
|
|
{
|
|
|
|
if (strcmp(data.dihedral_style,"none") == 0) {
|
|
|
|
|
|
|
|
} else if (strcmp(data.dihedral_style,"charmm") == 0) {
|
|
|
|
|
|
|
|
data.dihedral_charmm_k = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_charmm_multiplicity = new int[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_charmm_sign = new int[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_charmm_weight = new double[data.ndihedraltypes+1];
|
|
|
|
fread(&data.dihedral_charmm_k[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_charmm_multiplicity[1],sizeof(int),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_charmm_sign[1],sizeof(int),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_charmm_weight[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.dihedral_style,"class2") == 0) {
|
|
|
|
|
|
|
|
data.dihedral_class2_k1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_k2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_k3 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_phi1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_phi2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_phi3 = new double[data.ndihedraltypes+1];
|
|
|
|
|
|
|
|
data.dihedral_class2_mbt_f1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_mbt_f2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_mbt_f3 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_mbt_r0 = new double[data.ndihedraltypes+1];
|
|
|
|
|
|
|
|
data.dihedral_class2_ebt_f1_1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_ebt_f2_1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_ebt_f3_1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_ebt_r0_1 = new double[data.ndihedraltypes+1];
|
|
|
|
|
|
|
|
data.dihedral_class2_ebt_f1_2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_ebt_f2_2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_ebt_f3_2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_ebt_r0_2 = new double[data.ndihedraltypes+1];
|
|
|
|
|
|
|
|
data.dihedral_class2_at_f1_1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_at_f2_1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_at_f3_1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_at_theta0_1 = new double[data.ndihedraltypes+1];
|
|
|
|
|
|
|
|
data.dihedral_class2_at_f1_2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_at_f2_2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_at_f3_2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_at_theta0_2 = new double[data.ndihedraltypes+1];
|
|
|
|
|
|
|
|
data.dihedral_class2_aat_k = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_aat_theta0_1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_aat_theta0_2 = new double[data.ndihedraltypes+1];
|
|
|
|
|
|
|
|
data.dihedral_class2_bb13_k = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_bb13_r10 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_class2_bb13_r30 = new double[data.ndihedraltypes+1];
|
|
|
|
|
|
|
|
fread(&data.dihedral_class2_k1[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_k2[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_k3[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_phi1[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_phi2[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_phi3[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
fread(&data.dihedral_class2_mbt_f1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_mbt_f2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_mbt_f3[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_mbt_r0[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
fread(&data.dihedral_class2_ebt_f1_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_ebt_f2_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_ebt_f3_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_ebt_r0_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
fread(&data.dihedral_class2_ebt_f1_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_ebt_f2_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_ebt_f3_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_ebt_r0_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
fread(&data.dihedral_class2_at_f1_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_at_f2_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_at_f3_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_at_theta0_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
fread(&data.dihedral_class2_at_f1_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_at_f2_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_at_f3_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_at_theta0_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
fread(&data.dihedral_class2_aat_k[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_aat_theta0_1[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_aat_theta0_2[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
fread(&data.dihedral_class2_bb13_k[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_bb13_r10[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_class2_bb13_r30[1],sizeof(double),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.dihedral_style,"harmonic") == 0) {
|
|
|
|
|
|
|
|
data.dihedral_harmonic_k = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_harmonic_multiplicity = new int[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_harmonic_sign = new int[data.ndihedraltypes+1];
|
|
|
|
fread(&data.dihedral_harmonic_k[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_harmonic_multiplicity[1],sizeof(int),
|
|
|
|
data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_harmonic_sign[1],sizeof(int),data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.dihedral_style,"helix") == 0) {
|
|
|
|
|
|
|
|
data.dihedral_helix_aphi = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_helix_bphi = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_helix_cphi = new double[data.ndihedraltypes+1];
|
|
|
|
fread(&data.dihedral_helix_aphi[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_helix_bphi[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_helix_cphi[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.dihedral_style,"multi/harmonic") == 0) {
|
|
|
|
|
|
|
|
data.dihedral_multi_a1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_multi_a2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_multi_a3 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_multi_a4 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_multi_a5 = new double[data.ndihedraltypes+1];
|
|
|
|
fread(&data.dihedral_multi_a1[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_multi_a2[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_multi_a3[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_multi_a4[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_multi_a5[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
|
2006-09-29 00:35:11 +08:00
|
|
|
} else if (strcmp(data.dihedral_style,"opls") == 0) {
|
|
|
|
|
|
|
|
data.dihedral_opls_k1 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_opls_k2 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_opls_k3 = new double[data.ndihedraltypes+1];
|
|
|
|
data.dihedral_opls_k4 = new double[data.ndihedraltypes+1];
|
|
|
|
fread(&data.dihedral_opls_k1[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_opls_k2[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_opls_k3[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
fread(&data.dihedral_opls_k4[1],sizeof(double),data.ndihedraltypes,fp);
|
|
|
|
|
2007-06-23 01:00:20 +08:00
|
|
|
} else if (strcmp(data.dihedral_style,"hybrid") == 0) {
|
|
|
|
|
|
|
|
int nstyles = read_int(fp);
|
|
|
|
for (int i = 0; i < nstyles; i++)
|
|
|
|
char *substyle = read_char(fp);
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else {
|
|
|
|
printf("ERROR: Unknown dihedral style %s\n",data.dihedral_style);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// improper coeffs
|
|
|
|
// one section for each improper style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void improper(FILE *fp, Data &data)
|
|
|
|
{
|
|
|
|
if (strcmp(data.improper_style,"none") == 0) {
|
|
|
|
|
|
|
|
} else if (strcmp(data.improper_style,"class2") == 0) {
|
|
|
|
|
|
|
|
data.improper_class2_k0 = new double[data.nimpropertypes+1];
|
|
|
|
data.improper_class2_chi0 = new double[data.nimpropertypes+1];
|
|
|
|
|
|
|
|
data.improper_class2_aa_k1 = new double[data.nimpropertypes+1];
|
|
|
|
data.improper_class2_aa_k2 = new double[data.nimpropertypes+1];
|
|
|
|
data.improper_class2_aa_k3 = new double[data.nimpropertypes+1];
|
|
|
|
data.improper_class2_aa_theta0_1 = new double[data.nimpropertypes+1];
|
|
|
|
data.improper_class2_aa_theta0_2 = new double[data.nimpropertypes+1];
|
|
|
|
data.improper_class2_aa_theta0_3 = new double[data.nimpropertypes+1];
|
|
|
|
|
|
|
|
fread(&data.improper_class2_k0[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_class2_chi0[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
|
|
|
|
fread(&data.improper_class2_aa_k1[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_class2_aa_k2[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_class2_aa_k3[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_class2_aa_theta0_1[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_class2_aa_theta0_2[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_class2_aa_theta0_3[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.improper_style,"cvff") == 0) {
|
|
|
|
|
|
|
|
data.improper_cvff_k = new double[data.nimpropertypes+1];
|
|
|
|
data.improper_cvff_sign = new int[data.nimpropertypes+1];
|
|
|
|
data.improper_cvff_multiplicity = new int[data.nimpropertypes+1];
|
|
|
|
fread(&data.improper_cvff_k[1],sizeof(double),data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_cvff_sign[1],sizeof(int),data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_cvff_multiplicity[1],sizeof(int),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
|
|
|
|
} else if (strcmp(data.improper_style,"harmonic") == 0) {
|
|
|
|
|
|
|
|
data.improper_harmonic_k = new double[data.nimpropertypes+1];
|
|
|
|
data.improper_harmonic_chi = new double[data.nimpropertypes+1];
|
|
|
|
fread(&data.improper_harmonic_k[1],sizeof(double),data.nimpropertypes,fp);
|
|
|
|
fread(&data.improper_harmonic_chi[1],sizeof(double),
|
|
|
|
data.nimpropertypes,fp);
|
|
|
|
|
2007-06-23 01:00:20 +08:00
|
|
|
} else if (strcmp(data.improper_style,"hybrid") == 0) {
|
|
|
|
|
|
|
|
int nstyles = read_int(fp);
|
|
|
|
for (int i = 0; i < nstyles; i++)
|
|
|
|
char *substyle = read_char(fp);
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else {
|
|
|
|
printf("ERROR: Unknown improper style %s\n",data.improper_style);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
2007-06-20 21:17:04 +08:00
|
|
|
// initialize Data
|
2006-09-28 03:51:49 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
Data::Data() {}
|
2006-09-28 03:51:49 +08:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// print out stats on problem
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Data::stats()
|
|
|
|
{
|
|
|
|
printf(" Restart file version = %s\n",version);
|
|
|
|
printf(" Ntimestep = %d\n",ntimestep);
|
|
|
|
printf(" Nprocs = %d\n",nprocs);
|
|
|
|
printf(" Natoms = %d\n",natoms);
|
|
|
|
printf(" Nbonds = %d\n",nbonds);
|
|
|
|
printf(" Nangles = %d\n",nangles);
|
|
|
|
printf(" Ndihedrals = %d\n",ndihedrals);
|
|
|
|
printf(" Nimpropers = %d\n",nimpropers);
|
|
|
|
printf(" Unit style = %s\n",unit_style);
|
|
|
|
printf(" Atom style = %s\n",atom_style);
|
|
|
|
printf(" Pair style = %s\n",pair_style);
|
|
|
|
printf(" Bond style = %s\n",bond_style);
|
|
|
|
printf(" Angle style = %s\n",angle_style);
|
|
|
|
printf(" Dihedral style = %s\n",dihedral_style);
|
|
|
|
printf(" Improper style = %s\n",improper_style);
|
2007-07-04 04:07:03 +08:00
|
|
|
printf(" Xlo xhi = %g %g\n",xlo,xhi);
|
|
|
|
printf(" Ylo yhi = %g %g\n",ylo,yhi);
|
|
|
|
printf(" Zlo zhi = %g %g\n",zlo,zhi);
|
|
|
|
if (triclinic) printf(" Xy xz yz = %g %g %g\n",xy,xz,yz);
|
2006-09-28 03:51:49 +08:00
|
|
|
printf(" Periodicity = %d %d %d\n",xperiodic,yperiodic,zperiodic);
|
|
|
|
printf(" Boundary = %d %d, %d %d, %d %d\n",boundary[0][0],boundary[0][1],
|
|
|
|
boundary[1][0],boundary[1][1],boundary[2][0],boundary[2][1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// write the data file
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Data::write(FILE *fp)
|
|
|
|
{
|
|
|
|
fprintf(fp,"LAMMPS data file from restart file: timestep = %d, procs = %d\n",
|
|
|
|
ntimestep,nprocs);
|
|
|
|
|
|
|
|
fprintf(fp,"\n");
|
|
|
|
|
|
|
|
fprintf(fp,"%d atoms\n",natoms);
|
|
|
|
if (nbonds) fprintf(fp,"%d bonds\n",nbonds);
|
|
|
|
if (nangles) fprintf(fp,"%d angles\n",nangles);
|
|
|
|
if (ndihedrals) fprintf(fp,"%d dihedrals\n",ndihedrals);
|
|
|
|
if (nimpropers) fprintf(fp,"%d impropers\n",nimpropers);
|
|
|
|
|
|
|
|
fprintf(fp,"\n");
|
|
|
|
|
|
|
|
fprintf(fp,"%d atom types\n",ntypes);
|
|
|
|
if (nbondtypes) fprintf(fp,"%d bond types\n",nbondtypes);
|
|
|
|
if (nangletypes) fprintf(fp,"%d angle types\n",nangletypes);
|
|
|
|
if (ndihedraltypes) fprintf(fp,"%d dihedral types\n",ndihedraltypes);
|
|
|
|
if (nimpropertypes) fprintf(fp,"%d improper types\n",nimpropertypes);
|
|
|
|
|
|
|
|
fprintf(fp,"\n");
|
|
|
|
|
|
|
|
fprintf(fp,"%g %g xlo xhi\n",xlo,xhi);
|
|
|
|
fprintf(fp,"%g %g ylo yhi\n",ylo,yhi);
|
|
|
|
fprintf(fp,"%g %g zlo zhi\n",zlo,zhi);
|
2007-07-04 04:07:03 +08:00
|
|
|
if (triclinic) fprintf(fp,"%g %g %g xy xz yz\n",xy,xz,yz);
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
if (mass) {
|
2006-09-28 03:51:49 +08:00
|
|
|
fprintf(fp,"\nMasses\n\n");
|
|
|
|
for (int i = 1; i <= ntypes; i++) fprintf(fp,"%d %g\n",i,mass[i]);
|
|
|
|
}
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
if (shape) {
|
|
|
|
fprintf(fp,"\nShapes\n\n");
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,shape[3*i+0],shape[3*i+1],shape[3*i+2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dipole) {
|
2006-09-28 03:51:49 +08:00
|
|
|
fprintf(fp,"\nDipoles\n\n");
|
|
|
|
for (int i = 1; i <= ntypes; i++) fprintf(fp,"%d %g\n",i,dipole[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pair_style) {
|
2007-04-28 00:49:36 +08:00
|
|
|
if ((strcmp(pair_style,"none") != 0) &&
|
|
|
|
(strcmp(pair_style,"eam") != 0) &&
|
|
|
|
(strcmp(pair_style,"eam/opt") != 0) &&
|
|
|
|
(strcmp(pair_style,"eam/alloy") != 0) &&
|
|
|
|
(strcmp(pair_style,"eam/alloy/opt") != 0) &&
|
|
|
|
(strcmp(pair_style,"eam/fs") != 0) &&
|
|
|
|
(strcmp(pair_style,"eam/fs/opt") != 0) &&
|
|
|
|
(strcmp(pair_style,"meam") != 0) &&
|
|
|
|
(strcmp(pair_style,"gran/history") != 0) &&
|
|
|
|
(strcmp(pair_style,"gran/no_history") != 0) &&
|
|
|
|
(strcmp(pair_style,"gran/hertzian") != 0) &&
|
|
|
|
(strcmp(pair_style,"sw") != 0) &&
|
|
|
|
(strcmp(pair_style,"table") != 0) &&
|
|
|
|
(strcmp(pair_style,"tersoff") != 0) &&
|
|
|
|
(strcmp(pair_style,"hybrid") != 0))
|
|
|
|
fprintf(fp,"\nPair Coeffs\n\n");
|
2007-06-20 21:17:04 +08:00
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
if ((strcmp(pair_style,"buck") == 0) ||
|
|
|
|
(strcmp(pair_style,"buck/coul/cut") == 0) ||
|
|
|
|
(strcmp(pair_style,"buck/coul/long") == 0)) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,
|
|
|
|
pair_buck_A[i],pair_buck_rho[i],pair_buck_C[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
} else if (strcmp(pair_style,"colloid") == 0) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
pair_colloid_A12[i],pair_colloid_sigma[i],
|
|
|
|
pair_colloid_d2[i],pair_colloid_d2[i]);
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
} else if (strcmp(pair_style,"dipole/cut") == 0) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
pair_dipole_epsilon[i],pair_dipole_sigma[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(pair_style,"dpd") == 0) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
pair_dpd_a0[i],pair_dpd_gamma[i]);
|
|
|
|
|
2007-06-21 02:39:21 +08:00
|
|
|
} else if (strcmp(pair_style,"gayberne") == 0) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g %g %g %g %g %g\n",i,
|
|
|
|
pair_gb_epsilon[i],pair_gb_sigma[i],
|
|
|
|
pair_gb_epsa[i],pair_gb_epsb[i],pair_gb_epsc[i],
|
|
|
|
pair_gb_epsa[i],pair_gb_epsb[i],pair_gb_epsc[i]);
|
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if ((strcmp(pair_style,"lj/charmm/coul/charmm") == 0) ||
|
2007-06-20 21:17:04 +08:00
|
|
|
(strcmp(pair_style,"lj/charmm/coul/charmm/implicit") == 0) ||
|
2006-09-28 03:51:49 +08:00
|
|
|
(strcmp(pair_style,"lj/charmm/coul/long") == 0) ||
|
2007-06-20 21:17:04 +08:00
|
|
|
(strcmp(pair_style,"lj/charmm/coul/long") == 0)) {
|
2006-09-28 03:51:49 +08:00
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
pair_charmm_epsilon[i],pair_charmm_sigma[i],
|
|
|
|
pair_charmm_eps14[i],pair_charmm_sigma14[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if ((strcmp(pair_style,"lj/class2") == 0) ||
|
|
|
|
(strcmp(pair_style,"lj/class2/coul/cut") == 0) ||
|
|
|
|
(strcmp(pair_style,"lj/class2/coul/long") == 0)) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
pair_class2_epsilon[i],pair_class2_sigma[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if ((strcmp(pair_style,"lj/cut") == 0) ||
|
2007-06-20 21:17:04 +08:00
|
|
|
(strcmp(pair_style,"lj/cut/opt") == 0) ||
|
2006-09-28 03:51:49 +08:00
|
|
|
(strcmp(pair_style,"lj/cut/coul/cut") == 0) ||
|
|
|
|
(strcmp(pair_style,"lj/cut/coul/debye") == 0) ||
|
|
|
|
(strcmp(pair_style,"lj/cut/coul/long") == 0) ||
|
2007-06-20 21:17:04 +08:00
|
|
|
(strcmp(pair_style,"lj/cut/coul/long/tip4p") == 0)) {
|
2006-09-28 03:51:49 +08:00
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
pair_lj_epsilon[i],pair_lj_sigma[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(pair_style,"lj/expand") == 0) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,
|
|
|
|
pair_ljexpand_epsilon[i],pair_ljexpand_sigma[i],
|
|
|
|
pair_ljexpand_shift[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
} else if ((strcmp(pair_style,"morse") == 0) ||
|
|
|
|
(strcmp(pair_style,"morse/opt") == 0)) {
|
2006-09-28 03:51:49 +08:00
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,
|
|
|
|
pair_morse_d0[i],pair_morse_alpha[i],pair_morse_r0[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if (strcmp(pair_style,"soft") == 0) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
pair_soft_start[i],pair_soft_stop[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
|
2006-09-28 03:51:49 +08:00
|
|
|
} else if (strcmp(pair_style,"yukawa") == 0) {
|
|
|
|
for (int i = 1; i <= ntypes; i++)
|
|
|
|
fprintf(fp,"%d %g\n",i,
|
|
|
|
pair_yukawa_A[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bond_style) {
|
|
|
|
if ((strcmp(bond_style,"none") != 0) &&
|
|
|
|
(strcmp(bond_style,"hybrid") != 0))
|
|
|
|
fprintf(fp,"\nBond Coeffs\n\n");
|
|
|
|
|
|
|
|
if (strcmp(bond_style,"class2") == 0) {
|
|
|
|
for (int i = 1; i <= nbondtypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
bond_class2_r0[i],bond_class2_k2[i],
|
|
|
|
bond_class2_k3[i],bond_class2_k4[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(bond_style,"fene") == 0) {
|
|
|
|
for (int i = 1; i <= nbondtypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
bond_fene_k[i],bond_fene_r0[i],
|
|
|
|
bond_fene_epsilon[i],bond_fene_sigma[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(bond_style,"fene/expand") == 0) {
|
|
|
|
for (int i = 1; i <= nbondtypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g %g\n",i,
|
|
|
|
bond_feneexpand_k[i],bond_feneexpand_r0[i],
|
|
|
|
bond_feneexpand_epsilon[i],bond_feneexpand_sigma[i],
|
|
|
|
bond_feneexpand_shift[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(bond_style,"harmonic") == 0) {
|
|
|
|
for (int i = 1; i <= nbondtypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
bond_harmonic_k[i],bond_harmonic_r0[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(bond_style,"morse") == 0) {
|
|
|
|
for (int i = 1; i <= nbondtypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,
|
|
|
|
bond_morse_d0[i],bond_morse_alpha[i],bond_morse_r0[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(bond_style,"nonlinear") == 0) {
|
|
|
|
for (int i = 1; i <= nbondtypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,
|
|
|
|
bond_nonlinear_epsilon[i],bond_nonlinear_r0[i],
|
|
|
|
bond_nonlinear_lamda[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (angle_style) {
|
|
|
|
double PI = 3.1415926; // convert back to degrees
|
|
|
|
|
2007-06-23 01:00:20 +08:00
|
|
|
if ((strcmp(angle_style,"none") != 0) &&
|
|
|
|
(strcmp(angle_style,"hybrid") != 0))
|
2006-09-28 03:51:49 +08:00
|
|
|
fprintf(fp,"\nAngle Coeffs\n\n");
|
2007-06-23 01:00:20 +08:00
|
|
|
|
2007-07-18 22:45:17 +08:00
|
|
|
if (strcmp(angle_style,"charmm") == 0) {
|
2006-09-28 03:51:49 +08:00
|
|
|
for (int i = 1; i <= nangletypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
angle_charmm_k[i],angle_charmm_theta0[i]/PI*180.0,
|
|
|
|
angle_charmm_k_ub[i],angle_charmm_r_ub[i]);
|
|
|
|
|
2007-07-18 22:45:17 +08:00
|
|
|
} else if (strcmp(angle_style,"class2") == 0) {
|
2006-09-28 03:51:49 +08:00
|
|
|
for (int i = 1; i <= nangletypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
angle_class2_theta0[i]/PI*180.0,angle_class2_k2[i],
|
|
|
|
angle_class2_k3[i],angle_class2_k4[i]);
|
|
|
|
|
|
|
|
fprintf(fp,"\nBondBond Coeffs\n\n");
|
|
|
|
for (int i = 1; i <= nangletypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,
|
|
|
|
angle_class2_bb_k[i],
|
|
|
|
angle_class2_bb_r1[i],angle_class2_bb_r2[i]);
|
|
|
|
|
|
|
|
fprintf(fp,"\nBondAngle Coeffs\n\n");
|
|
|
|
for (int i = 1; i <= nangletypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
angle_class2_ba_k1[i],angle_class2_ba_k2[i],
|
|
|
|
angle_class2_ba_r1[i],angle_class2_ba_r2[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(angle_style,"cosine") == 0) {
|
|
|
|
for (int i = 1; i <= nangletypes; i++)
|
|
|
|
fprintf(fp,"%d %g\n",i,
|
|
|
|
angle_cosine_k[i]);
|
|
|
|
|
|
|
|
} if (strcmp(angle_style,"harmonic") == 0) {
|
|
|
|
for (int i = 1; i <= nangletypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
angle_harmonic_k[i],angle_harmonic_theta0[i]/PI*180.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dihedral_style) {
|
|
|
|
double PI = 3.1415926; // convert back to degrees
|
|
|
|
|
2007-06-23 01:00:20 +08:00
|
|
|
if ((strcmp(dihedral_style,"none") != 0) &&
|
|
|
|
(strcmp(dihedral_style,"hybrid") != 0))
|
2006-09-28 03:51:49 +08:00
|
|
|
fprintf(fp,"\nDihedral Coeffs\n\n");
|
|
|
|
|
2007-07-18 22:45:17 +08:00
|
|
|
if (strcmp(dihedral_style,"charmm") == 0) {
|
2006-09-28 03:51:49 +08:00
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %d %d %g\n",i,
|
|
|
|
dihedral_charmm_k[i],dihedral_charmm_multiplicity[i],
|
|
|
|
dihedral_charmm_sign[i],dihedral_charmm_weight[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(dihedral_style,"class2") == 0) {
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g %g %g\n",i,
|
2007-05-03 23:06:03 +08:00
|
|
|
dihedral_class2_k1[i],
|
2006-09-28 03:51:49 +08:00
|
|
|
dihedral_class2_phi1[i]/PI*180.0,
|
2007-05-03 23:06:03 +08:00
|
|
|
dihedral_class2_k2[i],
|
2006-09-28 03:51:49 +08:00
|
|
|
dihedral_class2_phi2[i]/PI*180.0,
|
2007-05-03 23:06:03 +08:00
|
|
|
dihedral_class2_k3[i],
|
2006-09-28 03:51:49 +08:00
|
|
|
dihedral_class2_phi3[i]/PI*180.0);
|
|
|
|
|
|
|
|
fprintf(fp,"\nMiddleBondTorsion Coeffs\n\n");
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
dihedral_class2_mbt_f1[i],dihedral_class2_mbt_f2[i],
|
|
|
|
dihedral_class2_mbt_f3[i],dihedral_class2_mbt_r0[i]);
|
|
|
|
|
|
|
|
fprintf(fp,"\nEndBondTorsion Coeffs\n\n");
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g %g %g %g %g\n",i,
|
|
|
|
dihedral_class2_ebt_f1_1[i],dihedral_class2_ebt_f2_1[i],
|
2007-05-03 23:06:03 +08:00
|
|
|
dihedral_class2_ebt_f3_1[i],
|
2006-09-28 03:51:49 +08:00
|
|
|
dihedral_class2_ebt_f1_2[i],dihedral_class2_ebt_f2_2[i],
|
2007-05-03 23:06:03 +08:00
|
|
|
dihedral_class2_ebt_f3_2[i],
|
|
|
|
dihedral_class2_ebt_r0_1[i],
|
|
|
|
dihedral_class2_ebt_r0_2[i]);
|
2006-09-28 03:51:49 +08:00
|
|
|
|
|
|
|
fprintf(fp,"\nAngleTorsion Coeffs\n\n");
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g %g %g %g %g\n",i,
|
|
|
|
dihedral_class2_at_f1_1[i],dihedral_class2_at_f2_1[i],
|
|
|
|
dihedral_class2_at_f3_1[i],
|
|
|
|
dihedral_class2_at_f1_2[i],dihedral_class2_at_f2_2[i],
|
|
|
|
dihedral_class2_at_f3_2[i],
|
2007-05-03 23:06:03 +08:00
|
|
|
dihedral_class2_at_theta0_1[i]/PI*180.0,
|
2006-09-28 03:51:49 +08:00
|
|
|
dihedral_class2_at_theta0_2[i]/PI*180.0);
|
|
|
|
|
|
|
|
fprintf(fp,"\nAngleAngleTorsion Coeffs\n\n");
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,
|
|
|
|
dihedral_class2_aat_k[i],
|
|
|
|
dihedral_class2_aat_theta0_1[i]/PI*180.0,
|
|
|
|
dihedral_class2_aat_theta0_2[i]/PI*180.0);
|
|
|
|
|
|
|
|
fprintf(fp,"\nBondBond13 Coeffs\n\n");
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g\n",i,
|
|
|
|
dihedral_class2_bb13_k[i],
|
|
|
|
dihedral_class2_bb13_r10[i],dihedral_class2_bb13_r30[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(dihedral_style,"harmonic") == 0) {
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %d %d\n",i,
|
|
|
|
dihedral_harmonic_k[i],dihedral_harmonic_multiplicity[i],
|
|
|
|
dihedral_harmonic_sign[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(dihedral_style,"multi/harmonic") == 0) {
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g %g\n",i,
|
|
|
|
dihedral_multi_a1[i],dihedral_multi_a2[i],
|
|
|
|
dihedral_multi_a3[i],dihedral_multi_a4[i],
|
|
|
|
dihedral_multi_a5[i]);
|
2006-09-29 00:35:11 +08:00
|
|
|
|
|
|
|
} else if (strcmp(dihedral_style,"opls") == 0) {
|
|
|
|
for (int i = 1; i <= ndihedraltypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g\n",i,
|
|
|
|
dihedral_opls_k1[i],dihedral_opls_k2[i],
|
|
|
|
dihedral_opls_k3[i],dihedral_opls_k4[i]);
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (improper_style) {
|
|
|
|
double PI = 3.1415926; // convert back to degrees
|
|
|
|
|
2007-06-23 01:00:20 +08:00
|
|
|
if ((strcmp(improper_style,"none") != 0) &&
|
|
|
|
(strcmp(improper_style,"hybrid") != 0))
|
2006-09-28 03:51:49 +08:00
|
|
|
fprintf(fp,"\nImproper Coeffs\n\n");
|
|
|
|
|
2007-07-18 22:45:17 +08:00
|
|
|
if (strcmp(improper_style,"class2") == 0) {
|
2006-09-28 03:51:49 +08:00
|
|
|
for (int i = 1; i <= nimpropertypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
improper_class2_k0[i],improper_class2_chi0[i]/PI*180.0);
|
|
|
|
|
|
|
|
fprintf(fp,"\nAngleAngle Coeffs\n\n");
|
|
|
|
for (int i = 1; i <= nimpropertypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g %g %g %g %g\n",i,
|
|
|
|
improper_class2_aa_k1[i],improper_class2_aa_k2[i],
|
|
|
|
improper_class2_aa_k3[i],
|
|
|
|
improper_class2_aa_theta0_1[i]/PI*180.0,
|
|
|
|
improper_class2_aa_theta0_2[i]/PI*180.0,
|
|
|
|
improper_class2_aa_theta0_3[i]/PI*180.0);
|
|
|
|
|
|
|
|
} else if (strcmp(improper_style,"cvff") == 0) {
|
|
|
|
for (int i = 1; i <= nimpropertypes; i++)
|
|
|
|
fprintf(fp,"%d %g %d %d\n",i,
|
|
|
|
improper_cvff_k[i],improper_cvff_sign[i],
|
|
|
|
improper_cvff_multiplicity[i]);
|
|
|
|
|
|
|
|
} else if (strcmp(improper_style,"harmonic") == 0) {
|
|
|
|
for (int i = 1; i <= nimpropertypes; i++)
|
|
|
|
fprintf(fp,"%d %g %g\n",i,
|
|
|
|
improper_harmonic_k[i],improper_harmonic_chi[i]/PI*180.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (natoms) {
|
|
|
|
fprintf(fp,"\nAtoms\n\n");
|
|
|
|
|
|
|
|
int ix,iy,iz;
|
|
|
|
for (int i = 0; i < natoms; i++) {
|
2007-06-20 21:17:04 +08:00
|
|
|
|
2006-12-09 01:23:17 +08:00
|
|
|
ix = (image[i] & 1023) - 512;
|
|
|
|
iy = (image[i] >> 10 & 1023) - 512;
|
|
|
|
iz = (image[i] >> 20) - 512;
|
2006-09-28 03:51:49 +08:00
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
if (style_hybrid == 0) {
|
|
|
|
if (style_angle) write_atom_angle(fp,i,ix,iy,iz);
|
|
|
|
if (style_atomic) write_atom_atomic(fp,i,ix,iy,iz);
|
|
|
|
if (style_bond) write_atom_bond(fp,i,ix,iy,iz);
|
|
|
|
if (style_charge) write_atom_charge(fp,i,ix,iy,iz);
|
|
|
|
if (style_dipole) write_atom_dipole(fp,i,ix,iy,iz);
|
|
|
|
if (style_dpd) write_atom_dpd(fp,i,ix,iy,iz);
|
|
|
|
if (style_ellipsoid) write_atom_ellipsoid(fp,i,ix,iy,iz);
|
|
|
|
if (style_full) write_atom_full(fp,i,ix,iy,iz);
|
|
|
|
if (style_granular) write_atom_granular(fp,i,ix,iy,iz);
|
|
|
|
if (style_molecular) write_atom_molecular(fp,i,ix,iy,iz);
|
|
|
|
fprintf(fp,"\n");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
fprintf(fp,"%d %d %g %g %g",tag[i],type[i],x[i],y[i],z[i]);
|
|
|
|
for (int k = 1; k <= style_hybrid; k++) {
|
|
|
|
if (k == style_angle) write_atom_angle_extra(fp,i);
|
|
|
|
if (k == style_atomic) write_atom_atomic_extra(fp,i);
|
|
|
|
if (k == style_bond) write_atom_bond_extra(fp,i);
|
|
|
|
if (k == style_charge) write_atom_charge_extra(fp,i);
|
|
|
|
if (k == style_dipole) write_atom_dipole_extra(fp,i);
|
|
|
|
if (k == style_dpd) write_atom_dpd_extra(fp,i);
|
|
|
|
if (k == style_ellipsoid) write_atom_ellipsoid_extra(fp,i);
|
|
|
|
if (k == style_full) write_atom_full_extra(fp,i);
|
|
|
|
if (k == style_granular) write_atom_granular_extra(fp,i);
|
|
|
|
if (k == style_molecular) write_atom_molecular_extra(fp,i);
|
|
|
|
}
|
|
|
|
fprintf(fp," %d %d %d\n",ix,iy,iz);
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (natoms) {
|
|
|
|
fprintf(fp,"\nVelocities\n\n");
|
|
|
|
for (int i = 0; i < natoms; i++)
|
2007-06-20 21:17:04 +08:00
|
|
|
|
|
|
|
if (style_hybrid == 0) {
|
|
|
|
if (style_angle) write_vel_angle(fp,i);
|
|
|
|
if (style_atomic) write_vel_atomic(fp,i);
|
|
|
|
if (style_bond) write_vel_bond(fp,i);
|
|
|
|
if (style_charge) write_vel_charge(fp,i);
|
|
|
|
if (style_dipole) write_vel_dipole(fp,i);
|
|
|
|
if (style_dpd) write_vel_dpd(fp,i);
|
|
|
|
if (style_ellipsoid) write_vel_ellipsoid(fp,i);
|
|
|
|
if (style_full) write_vel_full(fp,i);
|
|
|
|
if (style_granular) write_vel_granular(fp,i);
|
|
|
|
if (style_molecular) write_vel_molecular(fp,i);
|
|
|
|
fprintf(fp,"\n");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
fprintf(fp,"%d %g %g %g",tag[i],vx[i],vy[i],vz[i]);
|
|
|
|
for (int k = 1; k <= style_hybrid; k++) {
|
|
|
|
if (k == style_angle) write_vel_angle_extra(fp,i);
|
|
|
|
if (k == style_atomic) write_vel_atomic_extra(fp,i);
|
|
|
|
if (k == style_bond) write_vel_bond_extra(fp,i);
|
|
|
|
if (k == style_charge) write_vel_charge_extra(fp,i);
|
|
|
|
if (k == style_dipole) write_vel_dipole_extra(fp,i);
|
|
|
|
if (k == style_dpd) write_vel_dpd_extra(fp,i);
|
|
|
|
if (k == style_ellipsoid) write_vel_ellipsoid_extra(fp,i);
|
|
|
|
if (k == style_full) write_vel_full_extra(fp,i);
|
|
|
|
if (k == style_granular) write_vel_granular_extra(fp,i);
|
|
|
|
if (k == style_molecular) write_vel_molecular_extra(fp,i);
|
|
|
|
}
|
|
|
|
fprintf(fp,"\n");
|
|
|
|
}
|
2006-09-28 03:51:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nbonds) {
|
|
|
|
fprintf(fp,"\nBonds\n\n");
|
|
|
|
for (int i = 0; i < nbonds; i++)
|
|
|
|
fprintf(fp,"%d %d %d %d\n",
|
|
|
|
i+1,bond_type[i],bond_atom1[i],bond_atom2[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nangles) {
|
|
|
|
fprintf(fp,"\nAngles\n\n");
|
|
|
|
for (int i = 0; i < nangles; i++)
|
|
|
|
fprintf(fp,"%d %d %d %d %d\n",
|
|
|
|
i+1,angle_type[i],angle_atom1[i],angle_atom2[i],angle_atom3[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ndihedrals) {
|
|
|
|
fprintf(fp,"\nDihedrals\n\n");
|
|
|
|
for (int i = 0; i < ndihedrals; i++)
|
|
|
|
fprintf(fp,"%d %d %d %d %d %d\n",
|
|
|
|
i+1,dihedral_type[i],dihedral_atom1[i],dihedral_atom2[i],
|
|
|
|
dihedral_atom3[i],dihedral_atom4[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nimpropers) {
|
|
|
|
fprintf(fp,"\nImpropers\n\n");
|
|
|
|
for (int i = 0; i < nimpropers; i++)
|
|
|
|
fprintf(fp,"%d %d %d %d %d %d\n",
|
|
|
|
i+1,improper_type[i],improper_atom1[i],improper_atom2[i],
|
|
|
|
improper_atom3[i],improper_atom4[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-20 21:17:04 +08:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// per-atom write routines
|
|
|
|
// one routine per atom style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Data::write_atom_angle(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %d %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],molecule[i],type[i],x[i],y[i],z[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_atomic(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],type[i],x[i],y[i],z[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_bond(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %d %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],molecule[i],type[i],x[i],y[i],z[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_charge(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %15.12g %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],type[i],q[i],x[i],y[i],z[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_dipole(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %15.12g %15.12g %15.12g %15.12g %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],type[i],q[i],x[i],y[i],z[i],mux[i],muy[i],muz[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_dpd(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],type[i],x[i],y[i],z[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_ellipsoid(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %15.12g %15.12g %15.12g %15.12g %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],type[i],x[i],y[i],z[i],
|
|
|
|
quatw[i],quati[i],quatj[i],quatk[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_full(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %d %15.12g %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],molecule[i],type[i],q[i],x[i],y[i],z[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_granular(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %15.12g %15.12g %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],type[i],2.0*radius[i],density[i],x[i],y[i],z[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_molecular(FILE *fp, int i, int ix, int iy, int iz)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %d %d %15.12g %15.12g %15.12g %d %d %d",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],molecule[i],type[i],x[i],y[i],z[i],ix,iy,iz);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// per-atom write routines of extra quantities unique to style
|
|
|
|
// one routine per atom style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Data::write_atom_angle_extra(FILE *fp, int i)
|
|
|
|
{
|
|
|
|
fprintf(fp," %d",molecule[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_atomic_extra(FILE *fp, int i) {}
|
|
|
|
|
|
|
|
void Data::write_atom_bond_extra(FILE *fp, int i)
|
|
|
|
{
|
|
|
|
fprintf(fp," %d",molecule[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_charge_extra(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp," %15.12g",q[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_dipole_extra(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp," %15.12g %15.12g %15.12g %15.12g",q[i],mux[i],muy[i],muz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_dpd_extra(FILE *fp, int i) {}
|
|
|
|
|
|
|
|
void Data::write_atom_ellipsoid_extra(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp," %15.12g %15.12g %15.12g %15.12g",quatw[i],quati[i],quatj[i],quatk[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_full_extra(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp," %d %15.12g",molecule[i],q[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_granular_extra(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp," %15.12g %15.12g",2.0*radius[i],density[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_atom_molecular_extra(FILE *fp, int i)
|
|
|
|
{
|
|
|
|
fprintf(fp," %d",molecule[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// per-atom velocity write routines
|
|
|
|
// one routine per atom style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Data::write_vel_angle(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g",tag[i],vx[i],vy[i],vz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_atomic(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g",tag[i],vx[i],vy[i],vz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_bond(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g",tag[i],vx[i],vy[i],vz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_charge(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g",tag[i],vx[i],vy[i],vz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_dipole(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g",tag[i],vx[i],vy[i],vz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_dpd(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g",tag[i],vx[i],vy[i],vz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_ellipsoid(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g %15.12g %15.12g %15.12g",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],vx[i],vy[i],vz[i],angmomx[i],angmomy[i],angmomz[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_full(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g",tag[i],vx[i],vy[i],vz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_granular(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g %15.12g %15.12g %15.12g",
|
2007-06-20 21:17:04 +08:00
|
|
|
tag[i],vx[i],vy[i],vz[i],omegax[i],omegay[i],omegaz[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_molecular(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp,"%d %15.12g %15.12g %15.12g",tag[i],vx[i],vy[i],vz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// per-atom velocity write routines of extra quantities unique to style
|
|
|
|
// one routine per atom style
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Data::write_vel_angle_extra(FILE *fp, int i) {}
|
|
|
|
void Data::write_vel_atomic_extra(FILE *fp, int i) {}
|
|
|
|
void Data::write_vel_bond_extra(FILE *fp, int i) {}
|
|
|
|
void Data::write_vel_charge_extra(FILE *fp, int i) {}
|
|
|
|
void Data::write_vel_dipole_extra(FILE *fp, int i) {}
|
|
|
|
void Data::write_vel_dpd_extra(FILE *fp, int i) {}
|
|
|
|
|
|
|
|
void Data::write_vel_ellipsoid_extra(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp," %15.12g %15.12g %15.12g",angmomx[i],angmomy[i],angmomz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_full_extra(FILE *fp, int i) {}
|
|
|
|
|
|
|
|
void Data::write_vel_granular_extra(FILE *fp, int i)
|
|
|
|
{
|
2007-08-14 22:20:49 +08:00
|
|
|
fprintf(fp," %15.12g %15.12g %15.12g",omegax[i],omegay[i],omegaz[i]);
|
2007-06-20 21:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Data::write_vel_molecular_extra(FILE *fp, int i) {}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// binary reads from restart file
|
|
|
|
// ---------------------------------------------------------------------
|
2006-09-28 03:51:49 +08:00
|
|
|
|
|
|
|
int read_int(FILE *fp)
|
|
|
|
{
|
|
|
|
int value;
|
|
|
|
fread(&value,sizeof(int),1,fp);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double read_double(FILE *fp)
|
|
|
|
{
|
|
|
|
double value;
|
|
|
|
fread(&value,sizeof(double),1,fp);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *read_char(FILE *fp)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
fread(&n,sizeof(int),1,fp);
|
|
|
|
if (n == 0) return NULL;
|
|
|
|
char *value = new char[n];
|
|
|
|
fread(value,sizeof(char),n,fp);
|
|
|
|
return value;
|
|
|
|
}
|