diff options
author | Thomas White <taw@physics.org> | 2009-11-17 10:02:23 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2009-11-17 10:02:23 +0100 |
commit | 924736e50cf25baacb22bebbddf28a4f60194af5 (patch) | |
tree | 5b0c922d899ca3803ba2633c4c7ef7f277563f8c /src | |
parent | 73d3559d7fac9b258ae84954ab08369b9fe10c10 (diff) |
Work in progress
Diffstat (limited to 'src')
-rw-r--r-- | src/diffraction.c | 24 | ||||
-rw-r--r-- | src/image.h | 3 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/diffraction.c b/src/diffraction.c index 1a589462..91154b05 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -61,16 +61,20 @@ static double lattice_factor(struct threevec q, double ax, double ay, double az, } -static complex get_sfac(const char *n, struct threevec q, double en) +static complex get_sfac(const char *n, double s, double en) { return 1.0; } -static double molecule_factor(struct molecule *mol, struct threevec q, +static complex molecule_factor(struct molecule *mol, struct threevec q, double en) { int i; + double F = 0.0; + double s; + + s = modulus(q.u, q.v, q.w); for ( i=0; i<mol->n_species; i++ ) { @@ -81,14 +85,19 @@ static double molecule_factor(struct molecule *mol, struct threevec q, spec = mol->species[i]; - sfac = get_sfac(spec->species, q, en); for ( j=0; j<spec->n_atoms; j++ ) { - contrib += + + double ph; + + ph= q.u*spec->x[j] + q.v*spec->y[j] + q.w*spec->z[j]; + contrib += cos(ph) + I*sin(ph); } + sfac = get_sfac(spec->species, s, en); + F += sfac * contrib * exp(-2.0 * spec->B[j] * s); } - return 1e5; + return F; } @@ -215,12 +224,13 @@ void get_diffraction(struct image *image, UnitCell *cell) &bx, &by, &bz, &cx, &cy, &cz); - image->sfacs = malloc(image->width * image->height * sizeof(double)); + image->sfacs = malloc(image->width * image->height * sizeof(complex)); for ( x=0; x<image->width; x++ ) { for ( y=0; y<image->height; y++ ) { - double f_lattice, f_molecule; + double f_lattice; + complex f_molecule; struct threevec q; q = image->qvecs[x + image->width*y]; diff --git a/src/image.h b/src/image.h index 68c8fa13..3f67e973 100644 --- a/src/image.h +++ b/src/image.h @@ -18,6 +18,7 @@ #define IMAGE_H #include <stdint.h> +#include <complex.h> /* How is the scaling of the image described? */ @@ -80,7 +81,7 @@ struct molecule struct image { uint16_t *data; - double *sfacs; + complex *sfacs; struct threevec *qvecs; double *twotheta; struct molecule *molecule; |