void ActionAtomistic::setForcesOnAtoms( const std::vector<double>& forcesToApply, unsigned ind ){ if(donotforce) return; for(unsigned i=0;i<indexes.size();++i){ forces[i][0]=forcesToApply[ind]; ind++; forces[i][1]=forcesToApply[ind]; ind++; forces[i][2]=forcesToApply[ind]; ind++; } virial(0,0)=forcesToApply[ind]; ind++; virial(0,1)=forcesToApply[ind]; ind++; virial(0,2)=forcesToApply[ind]; ind++; virial(1,0)=forcesToApply[ind]; ind++; virial(1,1)=forcesToApply[ind]; ind++; virial(1,2)=forcesToApply[ind]; ind++; virial(2,0)=forcesToApply[ind]; ind++; virial(2,1)=forcesToApply[ind]; ind++; virial(2,2)=forcesToApply[ind]; plumed_dbg_assert( ind+1==forcesToApply.size()); }
/** total pressure */ double pressure() { return density() * (temp() + virial() / dimension); }
int main(int argc,char *argv[]) { static char *desc[] = { "[TT]mkice[tt] generates an ice crystal in the Ih crystal form which is the", "most stable form. The rectangular unitcell contains eight molecules", "and all oxygens are tetrahedrally coordinated.[PAR]", "If an input file is given it is interpreted as a series of oxygen", "coordinates the distance between which can be scaled by the odist flag.", "The program then adds hydrogens to the oxygens in random orientation", "but with proper OH distances and HOH angle. This feature allows to", "build water clusters based on oxygen coordinates only." }; static int nx=1,ny=1,nz=1; static gmx_bool bYaw=FALSE,bLJ=TRUE,bFull=TRUE,bSeries=FALSE; static gmx_bool bOrdered=TRUE,bDiamond=FALSE,bPBC=TRUE; static real rcut=0.3,odist=0.274,hdist=0.09572; t_pargs pa[] = { { "-nx", FALSE, etINT, {&nx}, "nx" }, { "-ny", FALSE, etINT, {&ny}, "ny" }, { "-nz", FALSE, etINT, {&nz}, "nz" }, { "-yaw", FALSE, etBOOL, {&bYaw}, "Generate virtual sites and shell positions" }, { "-lj", FALSE, etBOOL, {&bLJ}, "Use LJ as well as coulomb for virial calculation" }, { "-rcut", FALSE,etREAL, {&rcut},"Cut-off for virial calculations" }, { "-full", FALSE,etBOOL, {&bFull},"Full virial output" }, { "-odist", FALSE, etREAL, {&odist}, "Distance (nm) between oxygens" }, { "-hdist", FALSE, etREAL, {&hdist}, "Bondlength (nm) for OH bond" }, { "-diamond",FALSE,etBOOL, {&bDiamond}, "Make a diamond instead" }, { "-pbc", FALSE, etBOOL, {&bPBC}, "Make a periodic diamond" }, { "-order", FALSE,etBOOL, {&bOrdered}, "Make a proton-ordered ice lattice" }, { "-series",FALSE, etBOOL, {&bSeries}, "Do a series of virial calculations with different cut-off (from 0.3 up till the specified one)" } }; t_filenm fnm[] = { { efSTO, "-p", "ice", ffWRITE }, { efSTO, "-c", NULL, ffOPTRD }, { efDAT, "-f", NULL, ffOPTRD }, { efTRN, "-o", "ice", ffOPTWR } }; #define NFILE asize(fnm) FILE *fp; char *fn,quote[256]; int i,j,k,n,nmax,m,natom,natmol; t_atoms *pdba; t_atoms atoms; t_symtab symtab; rvec box,tmp,*xx; matrix boxje; CopyRight(stdout,argv[0]); parse_common_args(&argc,argv,0,NFILE,fnm,asize(pa),pa,asize(desc), desc,0,NULL); if (debug) { fprintf(debug,"nx = %3d, ny = %3d, nz = %3d\n",nx,ny,nz); fprintf(debug,"YAW = %3s, LJ = %3s, rcut = %g\n",yesno_names[bYaw], yesno_names[bLJ],rcut); } if (bYaw) natmol = 5; else if (bDiamond) natmol = 1; else natmol = 3; if (opt2bSet("-f",NFILE,fnm)) { natom = read_rel_coords(opt2fn("-f",NFILE,fnm),&xx,natmol); nmax = natom; } else { natom = natmol*8; nmax = natom*nx*ny*nz; snew(xx,nmax); } snew(pdba,1); init_t_atoms(pdba,nmax,TRUE); pdba->nr = nmax; open_symtab(&symtab); for(n=0; (n<nmax); n++) { pdba->pdbinfo[n].type = epdbATOM; pdba->pdbinfo[n].atomnr = 1+n; pdba->atom[n].resnr = 1+(n/natmol); pdba->atomname[n] = put_symtab(&symtab, bDiamond ? diamname[(n % natmol)] : watname[(n % natmol)]); if (bDiamond) pdba->resname[n] = put_symtab(&symtab,"DIA"); else pdba->resname[n] = put_symtab(&symtab,"SOL"); sprintf(pdba->pdbinfo[n].pdbresnr,"%d",n); pdba->atom[n].chain = ' '; } /* Generate the unit cell */ if (bDiamond) unitcell_d(xx,box,odist); else if (opt2bSet("-f",NFILE,fnm)) { random_h_coords(natmol,natom/natmol,xx,box,bYaw,odist,hdist); } else unitcell(xx,box,bYaw,odist,hdist); if (debug) { clear_mat(boxje); boxje[XX][XX] = box[XX]; boxje[YY][YY] = box[YY]; boxje[ZZ][ZZ] = box[ZZ]; } n=0; for(i=0; (i<nx); i++) { tmp[XX] = i*box[XX]; for(j=0; (j<ny); j++) { tmp[YY] = j*box[YY]; for(k=0; (k<nz); k++) { tmp[ZZ] = k*box[ZZ]; for(m=0; (m<natom); m++,n++) { if ((!bOrdered && ((m % natmol) == 0)) || bOrdered) rvec_add(xx[n % natom],tmp,xx[n]); else ; } } } } clear_mat(boxje); boxje[XX][XX] = box[XX]*nx; boxje[YY][YY] = box[YY]*ny; boxje[ZZ][ZZ] = box[ZZ]*nz; printf("Crystal: %10.5f %10.5f %10.5f\n", nx*box[XX],ny*box[YY],nz*box[ZZ]); if (debug && !bDiamond) { if (bSeries) for(i=3; (i<=10*rcut); i++) { fprintf(debug,"This is with rcut = %g\n",i*0.1); virial(debug,bFull,nmax/natmol,xx,boxje, 0.1*i,bYaw,bYaw ? qyaw : qspc,bLJ); } else virial(debug,bFull,nmax/natmol,xx,boxje, rcut,bYaw,bYaw ? qyaw : qspc,bLJ); } if (bDiamond) mk_diamond(pdba,xx,odist,&symtab,bPBC,boxje); fn = ftp2fn(efSTO,NFILE,fnm); if (fn2ftp(fn) == efPDB) { fp = gmx_ffopen(fn,"w"); if (bDiamond) fprintf(fp,"HEADER This is a *diamond*\n"); else fprintf(fp,"HEADER A beautiful Ice Ih crystal\n"); fprintf(fp,"REMARK Generated by mkice with the following options:\n" "REMARK nx = %d, ny = %d, nz = %d, odist = %g, hdist = %g\n", nx,ny,nz,odist,hdist); bromacs(quote,255); write_pdbfile(fp,quote,pdba,xx,boxje,' ',-1); gmx_ffclose(fp); } else { bromacs(quote,255); write_sto_conf(fn,quote,pdba,xx,NULL,boxje); } if (ftp2bSet(efTRN,NFILE,fnm)) write_trn(ftp2fn(efTRN,NFILE,fnm),0,0,0,boxje,nmax,xx,NULL,NULL); return 0; }
void star1d::dump_info() { DEBUG_FUNCNAME; printf("ESTER 1d model file"); printf(" (Version %s)\n", version.name.c_str()); // printf("\n1d ESTER model file (Version %d.%d rev %d",version.major,version.minor,version.rev); // if(version.svn) printf(".svn"); // printf(")\n\n"); printf("General parameters:\n\n"); printf("\tMass = %.5f Msun (%e g)\n",M/M_SUN,M); printf("\tRadius = %.5f Rsun (%e cm)\n",R/R_SUN,R); printf("\tLuminosity = %.4f Lsun (%e erg/s)\n",luminosity()/L_SUN,luminosity()); printf("\tTeff = %.2f\n",Teff()(0)); printf("\tlog(geff) = %.4f\n",log10(gsup())(0)); printf("\tX0=%.4f Y0=%.4f Z0=%.4f\n",X0,Y0,Z0); printf("\n"); if(conv==0) printf("No convective core\n\n"); else { printf("Convective core:\n\n"); double mcc=Mcore(); printf("\tMass_core = %.5f Msun (%e g)\n",mcc/M_SUN,mcc); double rcc=Rcore()(0); printf("\tRadius_core (p) = %.5f Rsun (%e cm)\n",rcc/R_SUN,rcc); printf("\tX_core/X_env = %.4f\n",Xc); printf("\n"); } printf("Central values:\n\n"); printf("\tTemperature = %e K\n",Tc); printf("\tDensity = %e g/cm3\n",rhoc); printf("\tPressure = %e dyn/cm2\n",pc); printf("\n"); printf("Grid parameters:\n\n"); printf("\t # of domains = %d\n",ndomains); printf("\t # of domains in convective core = %d\n",conv); printf("\t nr = %d (",nr); for(int n=0;n<ndomains;n++) { printf("%d",map.gl.npts[n]); if(n<ndomains-1) printf(","); } printf(")\n"); printf("\n"); printf("Additional parameters:\n\n"); printf("\tOpacity = %s\n",opa.name); printf("\tEquation of state = %s\n",eos.name); printf("\tNuclear reactions = %s\n",nuc.name); printf("\tAtmosphere = %s\n",atm.name); printf("\tsurff = %e\n",surff); printf("\tcore_convec = %d\n",core_convec); printf("\tenv_convec = %d\n",core_convec); printf("\tmin_core_size = %e\n",min_core_size); printf("\n"); printf("Tests:\n\n"); printf("\tVirial test = %e\n",virial()); printf("\tEnergy test = %e\n",energy_test()); printf("\n"); }