Commit c6af54b9 authored by Thomas White's avatar Thomas White
Browse files

partial_sim: Use flat noise in cell parameters

parent 812bce99
......@@ -44,15 +44,15 @@ static void mess_up_cell(UnitCell *cell)
//cell_print(cell);
cell_get_reciprocal(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
ax = gaussian_noise(ax, cnoise*fabs(ax)/100.0);
ay = gaussian_noise(ay, cnoise*fabs(ay)/100.0);
az = gaussian_noise(az, cnoise*fabs(az)/100.0);
bx = gaussian_noise(bx, cnoise*fabs(bx)/100.0);
by = gaussian_noise(by, cnoise*fabs(by)/100.0);
bz = gaussian_noise(bz, cnoise*fabs(bz)/100.0);
cx = gaussian_noise(cx, cnoise*fabs(cx)/100.0);
cy = gaussian_noise(cy, cnoise*fabs(cy)/100.0);
cz = gaussian_noise(cz, cnoise*fabs(cz)/100.0);
ax = flat_noise(ax, cnoise*fabs(ax)/100.0);
ay = flat_noise(ay, cnoise*fabs(ay)/100.0);
az = flat_noise(az, cnoise*fabs(az)/100.0);
bx = flat_noise(bx, cnoise*fabs(bx)/100.0);
by = flat_noise(by, cnoise*fabs(by)/100.0);
bz = flat_noise(bz, cnoise*fabs(bz)/100.0);
cx = flat_noise(cx, cnoise*fabs(cx)/100.0);
cy = flat_noise(cy, cnoise*fabs(cy)/100.0);
cz = flat_noise(cz, cnoise*fabs(cz)/100.0);
cell_set_reciprocal(cell, ax, ay, az, bx, by, bz, cx, cy, cz);
//STATUS("Changed:\n");
......
......@@ -121,6 +121,19 @@ void progress_bar(int val, int total, const char *text)
}
double random_flat(double max)
{
return max * (double)random()/RAND_MAX;
}
double flat_noise(double expected, double width)
{
double noise = random_flat(2.0*width);
return expected+noise-width;
}
double gaussian_noise(double expected, double stddev)
{
double x1, x2, noise;
......
......@@ -91,6 +91,8 @@ extern int assplode(const char *a, const char *delims, char ***pbits,
AssplodeFlag flags);
extern void progress_bar(int val, int total, const char *text);
extern double random_flat(double max);
extern double flat_noise(double expected, double width);
extern double gaussian_noise(double expected, double stddev);
extern int poisson_noise(double expected);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment