summaryrefslogtreecommitdiff
path: root/src/fracture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fracture.cpp')
-rw-r--r--src/fracture.cpp74
1 files changed, 55 insertions, 19 deletions
diff --git a/src/fracture.cpp b/src/fracture.cpp
index 53a11a5..b1bde45 100644
--- a/src/fracture.cpp
+++ b/src/fracture.cpp
@@ -35,7 +35,11 @@ int main(int argc, char* argv[]) {
double Ly = 16;
double beta = 0.5;
- while ((opt = getopt(argc, argv, "N:X:Y:b:")) != -1) {
+ unsigned n = 128;
+ double a = 1.0;
+ bool use_aN = false;
+
+ while ((opt = getopt(argc, argv, "N:X:Y:b:n:a:")) != -1) {
switch (opt) {
case 'N':
N = (unsigned)atof(optarg);
@@ -49,6 +53,14 @@ int main(int argc, char* argv[]) {
case 'b':
beta = atof(optarg);
break;
+ case 'n':
+ n = (unsigned)atof(optarg);
+ use_aN = true;
+ break;
+ case 'a':
+ a = atof(optarg);
+ use_aN = true;
+ break;
default:
exit(1);
}
@@ -57,30 +69,54 @@ int main(int argc, char* argv[]) {
cholmod_common c;
CHOL_F(start)(&c);
- // fourier transforms of powers of two are faster
- unsigned Mx = pow(2, ceil(log2(4*Lx)));
- unsigned My = pow(2, ceil(log2(4*Ly)));
-
- ma meas(Lx, Ly, Mx, My, beta);
-
randutils::auto_seed_128 seeds;
std::mt19937 rng{seeds};
- for (unsigned trial = 0; trial < N; trial++) {
- while (true) {
- try {
- graph G(Lx, Ly, rng);
- network network(G, &c);
- network.set_thresholds(beta, rng);
- network.fracture(meas);
- break;
- } catch (std::exception &e) {
- std::cout << e.what() << '\n';
+ if (use_aN) {
+ unsigned Mx = pow(2, ceil(log2(4*2*n*a)));
+ unsigned My = pow(2, ceil(log2(4*2*n/a)));
+
+ ma meas(n, a, Mx, My, beta);
+
+ for (unsigned trial = 0; trial < N; trial++) {
+ while (true) {
+ try {
+ graph G(n, a, rng);
+ network network(G, &c);
+ network.set_thresholds(beta, rng);
+ network.fracture(meas);
+ break;
+ } catch (std::exception &e) {
+ std::cout << e.what() << '\n';
+ }
}
+
+ if (quit.load())
+ break;
}
+ } else {
+ // fourier transforms of powers of two are faster
+ unsigned Mx = pow(2, ceil(log2(4*Lx)));
+ unsigned My = pow(2, ceil(log2(4*Ly)));
+
+ ma meas(Lx, Ly, Mx, My, beta);
+
+ for (unsigned trial = 0; trial < N; trial++) {
+ while (true) {
+ try {
+ graph G(Lx, Ly, rng);
+ network network(G, &c);
+ network.set_thresholds(beta, rng);
+ network.fracture(meas);
+ break;
+ } catch (std::exception &e) {
+ std::cout << e.what() << '\n';
+ }
+ }
- if (quit.load())
- break;
+ if (quit.load())
+ break;
+ }
}
CHOL_F(finish)(&c);