Bug fixes mostly in lattice generators.

Former-commit-id: 1fbed5865f20b7191b31fe24d263bd16baca7fa7
This commit is contained in:
Marek Nečada 2019-09-13 15:39:44 +03:00
parent e910de936e
commit b45bdcd49a
4 changed files with 24 additions and 13 deletions

View File

@ -10,7 +10,7 @@ PGenPolReturnData PGen_next_pol_from_cart2(PGen *g) {
return PGenPolDoneVal; return PGenPolDoneVal;
else { else {
PGenPolReturnData p; PGenPolReturnData p;
p.flags = c.flags; p.flags = (c.flags & ~QPMS_COORDS_BITRANGE) | QPMS_COORDS_POL;
p.point_pol = cart2pol(c.point_cart2); p.point_pol = cart2pol(c.point_cart2);
return p; return p;
} }
@ -22,7 +22,7 @@ PGenCart2ReturnData PGen_next_cart2_from_pol(PGen *g) {
return PGenCart2DoneVal; return PGenCart2DoneVal;
else { else {
PGenCart2ReturnData c; PGenCart2ReturnData c;
c.flags = p.flags; c.flags = (p.flags & ~QPMS_COORDS_BITRANGE) | QPMS_COORDS_CART2;
c.point_cart2 = pol2cart(p.point_pol); c.point_cart2 = pol2cart(p.point_pol);
return c; return c;
} }
@ -34,7 +34,7 @@ PGenSphReturnData PGen_next_sph_from_cart3(PGen *g) {
return PGenSphDoneVal; return PGenSphDoneVal;
else { else {
PGenSphReturnData s; PGenSphReturnData s;
s.flags = c.flags; s.flags = (c.flags & ~QPMS_COORDS_BITRANGE) | QPMS_COORDS_SPH;
s.point_sph = cart2sph(c.point_cart3); s.point_sph = cart2sph(c.point_cart3);
return s; return s;
} }
@ -46,7 +46,7 @@ PGenCart3ReturnData PGen_next_cart3_from_cart2xy(PGen *g) {
return PGenCart3DoneVal; return PGenCart3DoneVal;
else { else {
PGenCart3ReturnData c3; PGenCart3ReturnData c3;
c3.flags = c2.flags; c3.flags = (c2.flags & ~QPMS_COORDS_BITRANGE) | QPMS_COORDS_CART3;
c3.point_cart3 = cart22cart3xy(c2.point_cart2); c3.point_cart3 = cart22cart3xy(c2.point_cart2);
return c3; return c3;
} }
@ -58,7 +58,7 @@ PGenSphReturnData PGen_next_sph_from_cart2(PGen *g) {
return PGenSphDoneVal; return PGenSphDoneVal;
else { else {
PGenSphReturnData s; PGenSphReturnData s;
s.flags = c.flags; s.flags = (c.flags & ~QPMS_COORDS_BITRANGE) | QPMS_COORDS_SPH;
s.point_sph = cart22sph(c.point_cart2); s.point_sph = cart22sph(c.point_cart2);
return s; return s;
} }
@ -70,7 +70,7 @@ PGenCart3ReturnData PGen_next_cart3_from_sph(PGen *g) {
return PGenCart3DoneVal; return PGenCart3DoneVal;
else { else {
PGenCart3ReturnData c; PGenCart3ReturnData c;
c.flags = s.flags; c.flags = (s.flags & ~QPMS_COORDS_BITRANGE) | QPMS_COORDS_CART3;
c.point_cart3 = sph2cart(s.point_sph); c.point_cart3 = sph2cart(s.point_sph);
return c; return c;
} }
@ -569,13 +569,13 @@ const PGenClassInfo PGen_xyWeb = {
"PGen_xyWeb", "PGen_xyWeb",
2, 2,
PGEN_COORDS_CART2, PGEN_COORDS_CART2,
NULL,//PGen_xyWeb_next, NULL,//PGen_xyWeb_next, // FIXME I should really implement this.
NULL,//PGen_xyWeb_next_z, NULL,//PGen_xyWeb_next_z,
PGen_next_pol_from_cart2, //NULL,//PGen_xyWeb_next_pol, PGen_next_pol_from_cart2, //NULL,//PGen_xyWeb_next_pol,
PGen_next_sph_from_cart2, //NULL,//PGen_xyWeb_next_sph, PGen_next_sph_from_cart2, //NULL,//PGen_xyWeb_next_sph,
PGen_xyWeb_next_cart2, // native PGen_xyWeb_next_cart2, // native
PGen_next_cart3_from_cart2xy, //NULL,//PGen_xyWeb_next_cart3, PGen_next_cart3_from_cart2xy, //NULL,//PGen_xyWeb_next_cart3,
NULL,//PGen_xyWeb_fetch, NULL,//PGen_xyWeb_fetch, // FIXME I should really implement this
NULL,//PGen_xyWeb_fetch_z, NULL,//PGen_xyWeb_fetch_z,
NULL,//PGen_xyWeb_fetch_pol, NULL,//PGen_xyWeb_fetch_pol,
NULL,//PGen_xyWeb_fetch_sph, NULL,//PGen_xyWeb_fetch_sph,

View File

@ -907,7 +907,7 @@ size_t qpms_emptylattice2_modes_maxfreq(double **target_freqs,
QPMS_CRASHING_MALLOC(Kpoints, sizeof(cart2_t) * capacity); QPMS_CRASHING_MALLOC(Kpoints, sizeof(cart2_t) * capacity);
PGen Kgen = PGen_xyWeb_new(b1, b2, rtol, k, 0, true, maxk_safe, true); PGen Kgen = PGen_xyWeb_new(b1, b2, rtol, k, 0, true, maxk_safe, true);
size_t generated; size_t generated = 0;
PGenReturnDataBulk rd; PGenReturnDataBulk rd;
while((rd = PGen_fetch_cart2(&Kgen, capacity - generated, Kpoints + generated)).flags & PGEN_NOTDONE) while((rd = PGen_fetch_cart2(&Kgen, capacity - generated, Kpoints + generated)).flags & PGEN_NOTDONE)
generated += rd.generated; generated += rd.generated;

View File

@ -200,6 +200,16 @@ cdef extern from "lattices.h":
void *statedata void *statedata
void PGen_destroy(PGen *g) void PGen_destroy(PGen *g)
int l2d_reciprocalBasis2pi(cart2_t b1, cart2_t b2, cart2_t *rb1, cart2_t *rb2);
double l2d_unitcell_area(cart2_t b1, cart2_t b2)
void l2d_reduceBasis(cart2_t in1, cart2_t in2, cart2_t *out1, cart2_t *out2)
const double BASIS_RTOL
size_t qpms_emptylattice2_modes_maxfreq(double **target_freqs, cart2_t b1_rec, cart2_t b2_rec,
double rtol, cart2_t k, double wave_speed, double maxomega)
void qpms_emptylattice2_modes_nearest(double *target_freqs, cart2_t b1_rec, cart2_t b2_rec,
double rtol, cart2_t k, double wave_speed, double omega)
# now the individual PGen implementations: # now the individual PGen implementations:
# FIXME Is bint always guaranteed to be equivalent to _Bool? (I dont't think so.) # FIXME Is bint always guaranteed to be equivalent to _Bool? (I dont't think so.)
PGen PGen_xyWeb_new(cart2_t b1, cart2_t b2, double rtol, cart2_t offset, PGen PGen_xyWeb_new(cart2_t b1, cart2_t b2, double rtol, cart2_t offset,
@ -211,10 +221,9 @@ cdef extern from "lattices.h":
double maxR, bint inc_maxR, PGen_1D_incrementDirection incdir) double maxR, bint inc_maxR, PGen_1D_incrementDirection incdir)
int qpms_reduce_lattice_basis(double *b, size_t bsize, size_t ndim, double delta) int qpms_reduce_lattice_basis(double *b, size_t bsize, size_t ndim, double delta)
size_t qpms_emptylattice2_modes_maxfreq(double **target_freqs, cart2_t b1_rec, cart2_t b2_rec, cdef extern from "vectors.h":
double rtol, cart2_t k, double wave_speed, double maxomega) cart2_t cart2_substract(cart2_t a, cart2_t b)
size_t qpms_emptylattice2_modes_nearest(double *target_freqs, cart2_t b1_rec, cart2_t b2_rec, cart2_t cart2_scale(const double c, cart2_t b)
double rtol, cart2_t k, double wave_speed, double omega)
cdef extern from "quaternions.h": cdef extern from "quaternions.h":

View File

@ -708,6 +708,7 @@ static inline void qpms_array_coord_transform(void *dest, qpms_coord_system_t td
/** The dest and src arrays must not overlap */ /** The dest and src arrays must not overlap */
static inline void anycoord_arr2something(void *dest, qpms_coord_system_t tdest, static inline void anycoord_arr2something(void *dest, qpms_coord_system_t tdest,
const anycoord_point_t *src, qpms_coord_system_t tsrc, size_t nmemb) { const anycoord_point_t *src, qpms_coord_system_t tsrc, size_t nmemb) {
if(nmemb) {
switch(tdest & QPMS_COORDS_BITRANGE) { switch(tdest & QPMS_COORDS_BITRANGE) {
case QPMS_COORDS_SPH: case QPMS_COORDS_SPH:
{ {
@ -834,6 +835,7 @@ static inline void anycoord_arr2something(void *dest, qpms_coord_system_t tdest,
} }
QPMS_WTF; QPMS_WTF;
} }
}