diff options
| author | pants <jaron@kent-dobias.com> | 2016-09-19 15:51:29 -0400 | 
|---|---|---|
| committer | pants <jaron@kent-dobias.com> | 2016-09-19 15:51:29 -0400 | 
| commit | 77b52ecb19cf8415e67f67c78ece12b498ffa723 (patch) | |
| tree | 4508cd918d43a31163dcac1aa7b038c6544c5050 /src | |
| parent | 2969d1ef1352b22252c766372388cc3998997a72 (diff) | |
| parent | 507fa95563fe417b4373ca8c389423136318d410 (diff) | |
| download | fuse_networks-77b52ecb19cf8415e67f67c78ece12b498ffa723.tar.gz fuse_networks-77b52ecb19cf8415e67f67c78ece12b498ffa723.tar.bz2 fuse_networks-77b52ecb19cf8415e67f67c78ece12b498ffa723.zip  | |
Merge branch 'master' of gligible.lassp.cornell.edu:jkentdobias/fracture
I did git wrong
Diffstat (limited to 'src')
| -rw-r--r-- | src/fracture.c | 6 | ||||
| -rw-r--r-- | src/graph_create.c | 2 | ||||
| -rw-r--r-- | src/graph_genfunc.c | 36 | 
3 files changed, 22 insertions, 22 deletions
diff --git a/src/fracture.c b/src/fracture.c index 260f04f..dbe9ff5 100644 --- a/src/fracture.c +++ b/src/fracture.c @@ -186,9 +186,9 @@ int main(int argc, char *argv[]) {  	char *a_filename;  	if (save_cluster_dist) {  		cluster_size_dist = -				(uint32_t *)malloc(max_verts * sizeof(uint32_t)); +				(uint32_t *)calloc(max_verts, sizeof(uint32_t));  		avalanche_size_dist = -				(uint32_t *)malloc(max_edges * sizeof(uint32_t)); +				(uint32_t *)calloc(max_edges, sizeof(uint32_t));  		c_filename = (char *)malloc(filename_len * sizeof(char));  		a_filename = (char *)malloc(filename_len * sizeof(char)); @@ -241,7 +241,7 @@ int main(int argc, char *argv[]) {  	char *d_filename;  	if (save_damage) {  		damage = -				(uint32_t *)malloc(max_edges * sizeof(uint32_t)); +				(uint32_t *)calloc(max_edges, sizeof(uint32_t));  		d_filename = (char *)malloc(filename_len * sizeof(char));  		snprintf(d_filename, filename_len, "damg_%c_%c_%c_%d_%g_%g.dat", lattice_c, boundc, boundc2, L, beta, crack_len); diff --git a/src/graph_create.c b/src/graph_create.c index fdb1bf6..1c06052 100644 --- a/src/graph_create.c +++ b/src/graph_create.c @@ -667,7 +667,7 @@ graph_t *graph_create(lattice_t lattice, bound_t bound, uint_t L, bool dual, cho  	bool side_bounds;  	switch (lattice) {  		case (VORONOI_LATTICE): -			return ini_voro_graph(L, bound, dual, genfunc_hyperuniform, c); +			return ini_voro_graph(L, bound, dual, genfunc_uniform, c);  		case (SQUARE_LATTICE):  			if (bound == EMBEDDED_BOUND) side_bounds = true;  			else side_bounds = false; diff --git a/src/graph_genfunc.c b/src/graph_genfunc.c index 991e127..39a8480 100644 --- a/src/graph_genfunc.c +++ b/src/graph_genfunc.c @@ -13,6 +13,10 @@ double *genfunc_uniform(unsigned int L, bound_t boundary, gsl_rng *r, unsigned i  	return lattice;  } +double g(double rho, double dist) { +	return 1 - gsl_sf_exp(-M_PI * rho * dist); +} +  double *genfunc_hyperuniform(unsigned int L, bound_t boundary, gsl_rng *r, unsigned int *num) {  	*num = pow(L / 2 + 1, 2) + pow((L + 1) / 2, 2); @@ -49,25 +53,21 @@ double *genfunc_hyperuniform(unsigned int L, bound_t boundary, gsl_rng *r, unsig  		while(reject) {  			x = gsl_ran_flat(r, 0, 1);  			y = gsl_ran_flat(r, 0, 1); -			reject = false; +			double pp = 1;  			for (unsigned int j = 0; j < i; j++) { -				double *ds = (double *)malloc(5 * sizeof(double)); -				ds[0] = pow(x-lattice[2*j],2)+pow(y-lattice[2*j+1],2); -				ds[1] = pow(x-lattice[2*j] + 1,2)+pow(y-lattice[2*j+1],2); -				ds[2] = pow(x-lattice[2*j] - 1,2)+pow(y-lattice[2*j+1],2); -				ds[3] = pow(x-lattice[2*j],2)+pow(y-lattice[2*j+1] + 1,2); -				ds[4] = pow(x-lattice[2*j],2)+pow(y-lattice[2*j+1] - 1,2); -				double min_val = 100; -				for (unsigned int k = 0; k < 5; k++) { -					if (min_val > ds[k]) { -						min_val = ds[k]; -					} -				} -				if (1-gsl_sf_exp(-M_PI * rho * min_val) < gsl_ran_flat(r, 0, 1)) { -					reject = true; -					break; -				} -			} +				double ds0, ds1, ds2, ds3, ds4, ds5, ds6, ds7, ds8; +				ds0 = pow(x-lattice[2*j],2)+pow(y-lattice[2*j+1],2); +				ds1 = pow(x-lattice[2*j] + 1,2)+pow(y-lattice[2*j+1],2); +				ds2 = pow(x-lattice[2*j] - 1,2)+pow(y-lattice[2*j+1],2); +				ds3 = pow(x-lattice[2*j],2)+pow(y-lattice[2*j+1] + 1,2); +				ds4 = pow(x-lattice[2*j],2)+pow(y-lattice[2*j+1] - 1,2); +				ds5 = pow(x-lattice[2*j] + 1,2)+pow(y-lattice[2*j+1] + 1,2); +				ds6 = pow(x-lattice[2*j] + 1,2)+pow(y-lattice[2*j+1] - 1,2); +				ds7 = pow(x-lattice[2*j] - 1,2)+pow(y-lattice[2*j+1] + 1,2); +				ds8 = pow(x-lattice[2*j] - 1,2)+pow(y-lattice[2*j+1] - 1,2); +				pp *= g(rho, ds0) * g(rho, ds1) * g(rho, ds2) * g(rho, ds3) * g(rho, ds4) * g(rho, ds5) * g(rho, ds6) * g(rho, ds7) * g(rho, ds8); +			}  +			if (pp > gsl_ran_flat(r, 0, 1)) reject = false;  		}  		lattice[2*start + 2 * i] = x;  		lattice[2*start + 2 * i + 1] = y;  | 
