summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fracture.cpp9
-rw-r--r--src/measurements.cpp20
-rw-r--r--src/measurements.hpp4
3 files changed, 27 insertions, 6 deletions
diff --git a/src/fracture.cpp b/src/fracture.cpp
index 742a3f9..47b4856 100644
--- a/src/fracture.cpp
+++ b/src/fracture.cpp
@@ -34,8 +34,9 @@ int main(int argc, char* argv[]) {
double Lx = 16;
double Ly = 16;
double beta = 0.5;
+ double w = 0.01;
- while ((opt = getopt(argc, argv, "N:X:Y:b:")) != -1) {
+ while ((opt = getopt(argc, argv, "N:X:Y:b:w:")) != -1) {
switch (opt) {
case 'N':
N = (unsigned int)atof(optarg);
@@ -49,6 +50,9 @@ int main(int argc, char* argv[]) {
case 'b':
beta = atof(optarg);
break;
+ case 'w':
+ w = atof(optarg);
+ break;
default:
exit(1);
}
@@ -65,12 +69,13 @@ int main(int argc, char* argv[]) {
for (unsigned int trial = 0; trial < N; trial++) {
while (true) {
try {
- graph G(Lx, Ly, rng);
+ graph G(Lx, Ly, rng, w);
network network(G, &c);
network.set_thresholds(beta, rng);
network.fracture(meas);
break;
} catch (std::exception &e) {
+ std::cout << e.what() << '\n';
}
}
diff --git a/src/measurements.cpp b/src/measurements.cpp
index 27f239d..15d37d1 100644
--- a/src/measurements.cpp
+++ b/src/measurements.cpp
@@ -112,6 +112,8 @@ ma::ma(double Lx, double Ly, unsigned int Mx, unsigned int My, double beta) :
Lx(Lx), Ly(Ly), Mx(Mx), My(My), beta(beta), G(2 * (unsigned int)ceil(Lx * Ly / 2)),
sc(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
sa(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
+ sC(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
+ sA(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
sd(2 * (unsigned int)ceil(Lx * Ly / 2), 0),
sb(log2(Mx < My ? Mx : My) + 1, 0),
Ccc((Mx / 2 + 1) * (My / 2 + 1), 0),
@@ -125,6 +127,8 @@ ma::ma(double Lx, double Ly, unsigned int Mx, unsigned int My, double beta) :
N = 0;
Nc = 0;
Na = 0;
+ NC = 0;
+ NA = 0;
// FFTW setup for correlation functions
fftw_set_timelimit(1);
@@ -150,6 +154,8 @@ ma::~ma() {
update_distribution_file("sa", sa, Na, Lx, Ly, beta);
update_distribution_file("sc", sc, Nc, Lx, Ly, beta);
+ update_distribution_file("sA", sA, NA, Lx, Ly, beta);
+ update_distribution_file("sC", sC, NC, Lx, Ly, beta);
update_distribution_file("sd", sd, N, Lx, Ly, beta);
update_distribution_file("sb", sb, N, Lx, Ly, beta);
@@ -172,7 +178,9 @@ void ma::bond_broken(const network& net, const current_info& cur, unsigned int i
long double c = logl(cur.conductivity / fabs(cur.currents[i])) + net.thresholds[i];
if (c > lv && avalanches.back().size() > 0) {
sa[avalanches.back().size() - 1]++;
+ sA[avalanches.back().size() - 1]++;
Na++;
+ NA++;
std::fill_n(fftw_forward_in, Mx * My, 0.0);
@@ -224,8 +232,10 @@ void ma::post_fracture(network &n) {
}
sc[components[i].size() - 1]++;
+ sC[components[i].size() - 1]++;
autocorrelation(Mx, My, Ccc, forward_plan, fftw_forward_in, fftw_forward_out, reverse_plan, fftw_reverse_in, fftw_reverse_out);
Nc++;
+ NC++;
for (auto it = components[i].begin(); it != components[i].end(); it++) {
fftw_forward_in[edge_r_to_ind(n.G.dual_vertices[*it].r, Lx, Ly, Mx, My)] = 0.0;
@@ -252,10 +262,10 @@ void ma::post_fracture(network &n) {
// spanning cluster
std::fill_n(fftw_forward_in, Mx * My, 0.0);
- for (unsigned int i = 0; i < n.G.dual_vertices.size(); i++) {
- if (component[i] == crack_component) {
- fftw_forward_in[edge_r_to_ind(n.G.dual_vertices[i].r, Lx, Ly, Mx, My)] += 1.0;
- }
+ sC[components[crack_component].size() - 1]++;
+ NC++;
+ for (auto it = components[crack_component].begin(); it != components[crack_component].end(); it++) {
+ fftw_forward_in[edge_r_to_ind(n.G.dual_vertices[*it].r, Lx, Ly, Mx, My)] += 1.0;
}
autocorrelation(Mx, My, Cmm, forward_plan, fftw_forward_in, fftw_forward_out, reverse_plan, fftw_reverse_in, fftw_reverse_out);
@@ -277,6 +287,8 @@ void ma::post_fracture(network &n) {
std::fill_n(fftw_forward_in, Mx * My, 0.0);
// rewind the last avalanche
+ sA[avalanches.back().size() - 1]++;
+ NA++;
for (auto e : avalanches.back()) {
boost::remove_edge(n.G.dual_edges[e].v[0], n.G.dual_edges[e].v[1], G);
n.break_edge(e, true);
diff --git a/src/measurements.hpp b/src/measurements.hpp
index bd93cfc..3d4ff3e 100644
--- a/src/measurements.hpp
+++ b/src/measurements.hpp
@@ -36,6 +36,8 @@ class ma : public hooks {
// measurement storage
std::vector<uint64_t> sc; // cluster size distribution
std::vector<uint64_t> sa; // avalanche size distribution
+ std::vector<uint64_t> sC; // cluster size distribution
+ std::vector<uint64_t> sA; // avalanche size distribution
std::vector<uint64_t> sd; // avalanche size distribution
std::vector<uint64_t> sb; // bin size distribution
std::vector<uint64_t> Ccc; // cluster-cluster correlations
@@ -46,7 +48,9 @@ class ma : public hooks {
std::vector<uint64_t> Cll; // damage-damage distribution
std::vector<uint64_t> Cee; // damage-damage distribution
uint64_t Nc;
+ uint64_t NC;
uint64_t Na;
+ uint64_t NA;
public:
long double lv;