diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-02-21 14:01:24 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-02-21 14:01:24 -0500 |
commit | d944bcc3df0a8d7a10b755b5858c85e61a835a35 (patch) | |
tree | 611a52a9d51439e9cd39b6ef9bfe35b0e966c38d /src/sample.cpp | |
parent | a408c9884e5267a6fd3c9555b1c94e32df92fee5 (diff) | |
download | fuse_networks-d944bcc3df0a8d7a10b755b5858c85e61a835a35.tar.gz fuse_networks-d944bcc3df0a8d7a10b755b5858c85e61a835a35.tar.bz2 fuse_networks-d944bcc3df0a8d7a10b755b5858c85e61a835a35.zip |
simplified and sped up measurementsn substantially, correlation functions and some distributions again incompatible
Diffstat (limited to 'src/sample.cpp')
-rw-r--r-- | src/sample.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/sample.cpp b/src/sample.cpp new file mode 100644 index 0000000..b8af937 --- /dev/null +++ b/src/sample.cpp @@ -0,0 +1,69 @@ + +#include "sample.hpp" +#include <iostream> +#include <cstdio> + +sample::sample(double Lx, double Ly, double beta) { + std::string filename = "fracture_" + std::to_string(Lx) + "_" + std::to_string(Ly) + "_" + std::to_string(beta) + "_sample.dat"; + sample_file.open(filename, std::ifstream::app); +} + +sample::~sample() { + sample_file.close(); +} + +void sample::pre_fracture(const network& n) { + sample_file << "<|"; + sample_file << "\"vr\"->{"; + for (const graph::vertex &v : n.G.vertices) { + sample_file << "{" << v.r.x << "," << v.r.y << "},"; + } + sample_file << "},\"vp\"->{"; + for (const graph::vertex &v : n.G.vertices) { + sample_file << "{"; + for (const graph::coordinate &r : v.polygon) { + sample_file << "{" << r.x << "," << r.y << "},"; + } + sample_file << "},"; + } + sample_file << "},\"ur\"->{"; + for (const graph::vertex &v : n.G.dual_vertices) { + sample_file << "{" << v.r.x << "," << v.r.y << "},"; + } + sample_file << "},\"up\"->{"; + for (const graph::vertex &v : n.G.dual_vertices) { + sample_file << "{"; + for (const graph::coordinate &r : v.polygon) { + sample_file << "{" << r.x << "," << r.y << "},"; + } + sample_file << "},"; + } + sample_file << "},\"e\"->{"; + for (const graph::edge &e : n.G.edges) { + sample_file << "{" << e.v[0] << "," << e.v[1] << "},"; + } + sample_file << "},\"ec\"->{"; + for (const graph::edge &e : n.G.edges) { + sample_file << "{" << e.crossings[0] << "," << e.crossings[1] << "},"; + } + sample_file << "},\"d\"->{"; + for (const graph::edge &e : n.G.dual_edges) { + sample_file << "{" << e.v[0] << "," << e.v[1] << "},"; + } + sample_file << "},\"dc\"->{"; + for (const graph::edge &e : n.G.dual_edges) { + sample_file << "{" << e.crossings[0] << "," << e.crossings[1] << "},"; + } + sample_file << "},\"data\"->{"; +} + +void sample::bond_broken(const network& net, const current_info& cur, unsigned i) { + long double c = logl(cur.conductivity / fabs(cur.currents[i])) + net.thresholds[i]; + sample_file << "{" << i << "," << c << "," << cur.conductivity << "},"; +} + +void sample::post_fracture(network &n) { + sample_file << "}"; + sample_file << "|>\n"; +} + |