Fixes in vswf spec.

Former-commit-id: 87e0dbd73de266801c5bed7e8d3e43aaf4a0ed0e
This commit is contained in:
Marek Nečada 2019-03-10 13:45:46 +00:00
parent 53109e6d92
commit 20af81440f
4 changed files with 32 additions and 5 deletions

View File

@ -703,6 +703,7 @@ cdef class BaseSpec:
self.s.norm = QPMS_NORMALISATION_POWER self.s.norm = QPMS_NORMALISATION_POWER
# set the other metadata # set the other metadata
cdef qpms_l_t l cdef qpms_l_t l
self.s.lMax_L = -1
cdef qpms_m_t m cdef qpms_m_t m
cdef qpms_vswf_type_t t cdef qpms_vswf_type_t t
for i in range(self.s.n): for i in range(self.s.n):
@ -713,7 +714,7 @@ cdef class BaseSpec:
elif (t == QPMS_VSWF_MAGNETIC): elif (t == QPMS_VSWF_MAGNETIC):
self.s.lMax_M = max(self.s.lMax_M, l) self.s.lMax_M = max(self.s.lMax_M, l)
elif (t == QPMS_VSWF_LONGITUDINAL): elif (t == QPMS_VSWF_LONGITUDINAL):
self.s.lMax.L = max(self.s.lMax_L, l) self.s.lMax_L = max(self.s.lMax_L, l)
else: else:
raise ValueError # If this happens, it's probably a bug, as it should have failed already at qpms_uvswfi2tmn raise ValueError # If this happens, it's probably a bug, as it should have failed already at qpms_uvswfi2tmn
self.s.lMax = max(self.s.lMax, l) self.s.lMax = max(self.s.lMax, l)

View File

@ -1165,7 +1165,7 @@ qpms_errno_t qpms_trans_calculator_get_trans_array(const qpms_trans_calculator *
{ {
assert(c->normalisation == destspec->norm && c->normalisation == srcspec->norm); assert(c->normalisation == destspec->norm && c->normalisation == srcspec->norm);
assert(c->lMax >= destspec->lMax && c->lMax >= srcspec->lMax); assert(c->lMax >= destspec->lMax && c->lMax >= srcspec->lMax);
assert(!destspec->lMax_L && !srcspec->lMax_L); assert(destspec->lMax_L < 0 && srcspec->lMax_L < 0);
complex double A[c->nelem][c->nelem]; complex double A[c->nelem][c->nelem];
complex double B[c->nelem][c->nelem]; complex double B[c->nelem][c->nelem];
qpms_errno_t retval = qpms_trans_calculator_get_AB_arrays(c, qpms_errno_t retval = qpms_trans_calculator_get_AB_arrays(c,

View File

@ -25,9 +25,10 @@ qpms_errno_t qpms_vswf_set_spec_append(qpms_vswf_set_spec_t *s, const qpms_uvswf
qpms_vswf_type_t t; qpms_vswf_type_t t;
if (qpms_uvswfi2tmn(u, &t, &m, &l)!=QPMS_SUCCESS) return QPMS_ERROR; // TODO WARN if (qpms_uvswfi2tmn(u, &t, &m, &l)!=QPMS_SUCCESS) return QPMS_ERROR; // TODO WARN
if (s->n + 1 > s->capacity) { if (s->n + 1 > s->capacity) {
size_t newcap = (s->capacity > 32) ? 32 : 2*s->capacity; size_t newcap = (s->capacity < 32) ? 32 : 2*s->capacity;
qpms_uvswfi_t *newmem = realloc(s->ilist, newcap * sizeof(qpms_uvswfi_t)); qpms_uvswfi_t *newmem = realloc(s->ilist, newcap * sizeof(qpms_uvswfi_t));
if (newmem == NULL) return QPMS_ENOMEM; // TODO WARN if (newmem == NULL) return QPMS_ENOMEM; // TODO WARN
s->capacity = newcap;
s->ilist = newmem; s->ilist = newmem;
} }
s->ilist[s->n] = u; s->ilist[s->n] = u;

View File

@ -4,9 +4,16 @@ typedef int qpms_gmi_t;// There is something wrong in the includes, apparently.
#include <qpms/scatsystem.h> #include <qpms/scatsystem.h>
#include <stdlib.h> #include <stdlib.h>
#include <qpms/vswf.h> #include <qpms/vswf.h>
#include <qpms/indexing.h>
#include <stdio.h>
#include "staticgroups.h" #include "staticgroups.h"
const qpms_finite_group_t *D3h = &QPMS_FINITE_GROUP_D3h; const qpms_finite_group_t *D3h = &QPMS_FINITE_GROUP_D3h;
const qpms_finite_group_t *C4v = &QPMS_FINITE_GROUP_C4v;
const qpms_finite_group_t *TRIVG = &QPMS_FINITE_GROUP_trivial_g;
const qpms_finite_group_t *C2v = &QPMS_FINITE_GROUP_C2v;
const qpms_finite_group_t *D2h = &QPMS_FINITE_GROUP_D2h;
const qpms_finite_group_t *D4h = &QPMS_FINITE_GROUP_D4h;
double uniform_random(double min, double max) { double uniform_random(double min, double max) {
double random_value = min + (max-min)*(double)rand()/RAND_MAX; double random_value = min + (max-min)*(double)rand()/RAND_MAX;
@ -16,10 +23,22 @@ double uniform_random(double min, double max) {
int main() int main()
{ {
srand(666); srand(666);
#if 0
qpms_vswf_set_spec_t qpms_vswf_set_spec_t
*b1 = qpms_vswf_set_spec_from_lMax(1,QPMS_NORMALISATION_POWER_CS), *b1 = qpms_vswf_set_spec_from_lMax(1,QPMS_NORMALISATION_POWER_CS),
*b2 = qpms_vswf_set_spec_from_lMax(2,QPMS_NORMALISATION_POWER_CS); *b2 = qpms_vswf_set_spec_from_lMax(2,QPMS_NORMALISATION_POWER_CS);
#else
// Only electric waves
qpms_vswf_set_spec_t *b1 = qpms_vswf_set_spec_init(),
*b2 = qpms_vswf_set_spec_init();
b1->norm = b2-> norm = QPMS_NORMALISATION_POWER_CS;
for(qpms_l_t l = 1; l <= 1; ++l)
for (qpms_m_t m = -l; m <= l; ++m)
qpms_vswf_set_spec_append(b1, qpms_tmn2uvswfi(QPMS_VSWF_ELECTRIC, m, l));
for(qpms_l_t l = 1; l <= 2; ++l)
for (qpms_m_t m = -l; m <= l; ++m)
qpms_vswf_set_spec_append(b2, qpms_tmn2uvswfi(QPMS_VSWF_ELECTRIC, m, l));
#endif
qpms_tmatrix_t *t1 = qpms_tmatrix_init(b1); qpms_tmatrix_t *t1 = qpms_tmatrix_init(b1);
qpms_tmatrix_t *t2 = qpms_tmatrix_init(b2); qpms_tmatrix_t *t2 = qpms_tmatrix_init(b2);
@ -39,7 +58,11 @@ int main()
protoss.p = plist; protoss.p = plist;
protoss.p_count=3; protoss.p_count=3;
qpms_scatsys_t *ss = qpms_scatsys_apply_symmetry(&protoss, D3h); qpms_scatsys_t *ss = qpms_scatsys_apply_symmetry(&protoss, D4h);
printf("p_count: %d, tm_count: %d, nirreps: %d, orbit_type_count: %d\n",
(int)ss->p_count, (int)ss->tm_count, (int)ss->sym->nirreps,
(int)ss->orbit_type_count);
const double k = 1.7; const double k = 1.7;
@ -61,6 +84,8 @@ int main()
double err = cabs(S_full[i] - S_recfull[i]); double err = cabs(S_full[i] - S_recfull[i]);
maxerr = (err > maxerr) ? err : maxerr; maxerr = (err > maxerr) ? err : maxerr;
} }
printf("maxerr: %lg\n", maxerr);
for (qpms_iri_t iri = 0; iri < ss->sym->nirreps; ++iri) free(S_packed[iri]); for (qpms_iri_t iri = 0; iri < ss->sym->nirreps; ++iri) free(S_packed[iri]);
free(S_full); free(S_full);