-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
252 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from numpy.random import random_integers | ||
|
||
if __name__=='__main__': | ||
import sys | ||
num_seeds = int(sys.argv[1]) if len(sys.argv) > 1 else 1 | ||
seeds = random_integers(0, 2**24, num_seeds) | ||
|
||
for seed in seeds: | ||
print '{:06x}'.format(seed) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
static int bisect(double a[], double x, int l, int r) | ||
{ | ||
int mid; | ||
|
||
while (r-l > 1) | ||
{ | ||
mid = (l+r)/2; | ||
if (a[mid] < x) l = mid; | ||
else r = mid; | ||
} | ||
|
||
return (x < a[l]) ? l : r; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "bond_dist.h" | ||
#include <math.h> | ||
|
||
#include "bisect.c" | ||
|
||
#define R(n) fabs(N/M_PI*sin(M_PI*n/N)) | ||
|
||
void bond_dist_dilute(bonds *b, double sigma, rng *rand) | ||
{ | ||
int n, num_bonds = 0; | ||
double *f, sum = 0., p = -2.*sigma; | ||
|
||
f = malloc(N * sizeof(double)); | ||
|
||
/* compute probability distribution */ | ||
|
||
f[0] = 0.; | ||
|
||
for (n = 1; n < N; n++) | ||
{ | ||
double r, w; | ||
|
||
r = R(n); | ||
w = pow(r, p); | ||
f[n] = f[n-1] + w; | ||
sum += w; | ||
} | ||
|
||
for (n = 1; n < N; n++) f[n] /= sum; | ||
|
||
/* generate bonds */ | ||
|
||
while (num_bonds < NUM_BONDS) | ||
{ | ||
int i, j; | ||
double r; | ||
|
||
i = (int) (N * RNG_UNIFORM(rand)); | ||
r = RNG_UNIFORM(rand); | ||
n = bisect(f, r, 1, N); | ||
j = i + n; | ||
|
||
if (j >= N) | ||
{ | ||
int _i = i; | ||
i = j - N; | ||
j = _i; | ||
} | ||
|
||
if (! bonds_have(b, i, j)) | ||
{ | ||
double v = RNG_GAUSS(rand, 1.); | ||
bonds_add(b, i, j, v); | ||
num_bonds++; | ||
} | ||
} | ||
|
||
free(f); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "bonds.h" | ||
|
||
void bond_dist_dilute(bonds *b, double sigma, rng *rand); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "bonds.h" | ||
|
||
void bonds_init(bonds *b) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < N; i++) | ||
b->head[i] = NULL; | ||
} | ||
|
||
void bonds_add(bonds *b, int i, int j, double v) | ||
{ | ||
node *new = malloc(sizeof(node)); | ||
new->j = j; | ||
new->v = v; | ||
new->next = b->head[i]; | ||
b->head[i] = new; | ||
} | ||
|
||
int bonds_have(bonds *b, int i, int j) | ||
{ | ||
node *next = b->head[i]; | ||
|
||
while (next) | ||
{ | ||
if (next->j == j) | ||
return 1; | ||
|
||
next = next->next; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void bonds_to_list(bonds *b, int *bond_site, double *bond_value) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < N; i++) | ||
{ | ||
node *next = b->head[i]; | ||
|
||
while (next) | ||
{ | ||
*(bond_site++) = i; | ||
*(bond_site++) = next->j; | ||
*(bond_value++) = next->v; | ||
next = next->next; | ||
} | ||
} | ||
} | ||
|
||
void bonds_free(bonds *b) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < N; i++) | ||
{ | ||
node *this = b->head[i]; | ||
|
||
while (this) | ||
{ | ||
node *next = this->next; | ||
free(this); | ||
this = next; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef BONDS_H | ||
#define BONDS_H | ||
|
||
#include "rng.h" | ||
#include "sample.h" | ||
|
||
typedef struct | ||
{ | ||
int j; | ||
double v; | ||
void *next; | ||
} node; | ||
|
||
typedef struct { node *head[N]; } bonds; | ||
|
||
void bonds_init(bonds *b); | ||
|
||
void bonds_add(bonds *b, int i, int j, double v); | ||
|
||
int bonds_have(bonds *b, int i, int j); | ||
|
||
void bonds_to_list(bonds *b, int *bond_site, double *bond_value); | ||
|
||
void bonds_free(bonds *b); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters