Untitled
unknown
c_cpp
a month ago
1.2 kB
4
Indexable
Never
#include<iostream> #include<fstream> #include<cmath> using namespace std; int main() { int x_unit = 30; int y_unit = 30; int z_unit = 0; int cubic[x_unit][y_unit]={}; for(int i=0;i<x_unit;i++) for(int j=0;j<y_unit;j++) cubic[i][j]=1; int atoms=0; int X[x_unit*y_unit]={}; int Y[x_unit*y_unit]={}; int Z[x_unit*y_unit]={0}; for(int i=0;i<x_unit;i++) { for(int j=0;j<y_unit;j++) { if(cubic[i][j]==1) { X[atoms]=i; Y[atoms]=j; atoms++; } } } ofstream outputFile("文件輸出用_2.txt"); outputFile << "LAMMPS data file via write_data, version 23 Jun 2022, timestep = 0" << endl << endl; outputFile << atoms << " atoms" << endl << "1 atom types" << endl << endl; outputFile << "0 " << x_unit << " xlo xhi" << endl; outputFile << "0 " << y_unit << " ylo yhi" << endl; outputFile << "0 " << z_unit << " zlo zhi" << endl << endl; outputFile << "Masses" << endl << endl << "1 12.011" << endl << endl; outputFile << "Atoms # molecular" << endl << endl; for(int i=0;i<atoms;i++) outputFile << i+1 << " 1 " << X[i] << " " << Y[i] << " " << Z[i] << endl; outputFile.close(); return 0; }
Leave a Comment