-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVTF.cpp
44 lines (41 loc) · 1.09 KB
/
VTF.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <time.h>
#include <vector>
#include <math.h>
#include <assert.h>
using namespace std;
#include "Random.h"
#include "Bead.h"
#include "Polymer.h"
#include "Box.h"
#include "VTF.h"
void VTFFile::writeHeader()
{
Bead* bead;
vector<Bead*> beads;
// Just get the first bead
bead = polymers[0]->getBead(0);
stream = fopen(filename.c_str(), "w");
assert(stream);
fprintf(stream, "unitcell %lf %lf %lf\n", box->getX(), box->getY(), box->getZ());
for(int i=0;i<polymers.size();i++) {
beads = polymers[i]->getBeads();
fprintf(stream, "atom %d:%d\tradius %lf segid %d\n", beads[0]->getIndex(), beads[0]->getIndex()+(beads.size()-1), beads[0]->getDiameter()/2.0, i);
}
}
void VTFFile::writeBeadPositions()
{
Bead* bead;
fprintf(stream, "\ntimestep\n");
fprintf(stream, "unitcell %lf %lf %lf\n", box->getX(), box->getY(), box->getZ());
for(int i=0;i<polymers.size();i++) {
for(int j=0;j<polymers[i]->size();j++) {
bead = polymers[i]->getBead(j);
fprintf(stream, "%lf\t %lf\t %lf\n", bead->getX(), bead->getY(), bead->getZ());
}
}
}
VTFFile::~VTFFile()
{
fclose(stream);
}