Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #define N_dx 100 // rasbienie po X
- #define N_times 1000
- class MD {
- std::string s;
- std::fstream f;
- double x_min;
- double x_max;
- double y_min;
- double y_max;
- int index;
- double x[];
- double y[];
- double rho [N_times][N_dx];
- public:
- void fileopen (std::string);
- int read_head();
- void read_state(int);
- void obr_state(int,int);
- };
- void fileopen(std::string& fname){
- f.open(fname);
- }
- int MD::read_head ()
- {
- int n;
- f>>s;f>>s;
- f>>s;
- f>>s;f>>s;f>>s;f>>s;
- f>>n; // number of atoms
- f>>s;f>>s;f>>s;f>>s;f>>s;f>>s;
- f>>x_min; // chtenie razmerov
- f>>x_max; // chtenie razmerov
- f>>y_min; // chtenie razmerov
- f>>y_max;
- f>>s;f>>s;
- f>>s;f>>s;f>>s;f>>s;f>>s;
- n=n/100;
- return n;
- }
- void MD::read_state (int N){
- for (int i=0; i<N; i++){
- f>>index;
- f>>x[index];
- f>>y[index];
- }
- }
- void MD::obr_state(int N,int t_index){
- int n;
- n=1000; // kol-vo dx
- int dn[n];
- int dn_index;
- double X;
- double Y;
- double dx;
- double x_x;
- dn_index=0;
- X=(x_max-x_min);
- Y=(y_max-y_min);
- dx= X/n; //
- x_x= x_min + dx;
- for (int i=0;i<n;i++){ // prohod po oblasti
- for (int j=0;j<N;j++){ // prohod po atomam
- if (x[j]>=(x_x - dx) && x[j]<x_x){
- dn[i]++;
- }
- x_x+=dx;
- }
- dn_index ++;
- rho[t_index][dn_index]=dn[i]/(Y*dx);
- }
- }
- int main()
- {
- int time_index;
- int N;
- MD Melt;
- std::string Filename = "dump.melt";
- time_index=0;
- Melt.fileopen(Filename);
- for (int i=0; i<N_times; i++){
- N=Melt.read_head();
- Melt.read_state(N);
- Melt.obr_state(N,time_index);
- time_index++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement