From d944bcc3df0a8d7a10b755b5858c85e61a835a35 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Thu, 21 Feb 2019 14:01:24 -0500 Subject: simplified and sped up measurementsn substantially, correlation functions and some distributions again incompatible --- src/sample.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/sample.cpp (limited to 'src/sample.cpp') 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 +#include + +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"; +} + -- cgit v1.2.3-70-g09d2