Merge branch 'master' of necada.org:~/repo/qpms
Conflicts: misc/201903_finiterectlat_AaroBEC_fatMie.py Former-commit-id: 6e9130313939be2eec80f4df9a703c8e9cb42456
This commit is contained in:
commit
38bd16f94a
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator
|
||||
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator, scatsystem_set_nthreads
|
||||
from qpms.symmetries import point_group_info
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
|
@ -8,6 +8,11 @@ import os
|
|||
import sys
|
||||
nm = 1e-9
|
||||
|
||||
|
||||
if 'SLURM_CPUS_PER_TASK' in os.environ:
|
||||
scatsystem_set_nthreads(os.environ['SLURM_CPUS_PER_TASK'])
|
||||
|
||||
|
||||
rewrite_output = '--rewrite-output' in sys.argv
|
||||
|
||||
cyr_part_height = 50*nm
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator
|
||||
from qpms import Particle, CTMatrix, BaseSpec, FinitePointGroup, ScatteringSystem, TMatrixInterpolator, eV, hbar, c, MaterialInterpolator, scatsystem_set_nthreads
|
||||
from qpms.symmetries import point_group_info
|
||||
import numpy as np
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
if 'SLURM_CPUS_PER_TASK' in os.environ:
|
||||
scatsystem_set_nthreads(os.environ['SLURM_CPUS_PER_TASK'])
|
||||
|
||||
nm = 1e-9
|
||||
|
||||
rewrite_output = '--rewrite-output' in sys.argv
|
||||
|
|
|
@ -1398,6 +1398,10 @@ cdef class Particle:
|
|||
else:
|
||||
raise ValueError("Position argument has to contain 3 or 2 cartesian coordinates")
|
||||
|
||||
cpdef void scatsystem_set_nthreads(long n):
|
||||
qpms_scatsystem_set_nthreads(n)
|
||||
return
|
||||
|
||||
cdef class ScatteringSystem:
|
||||
'''
|
||||
Wrapper over the C qpms_scatsys_t structure.
|
||||
|
|
|
@ -290,6 +290,7 @@ cdef extern from "tmatrices.h":
|
|||
|
||||
|
||||
cdef extern from "scatsystem.h":
|
||||
void qpms_scatsystem_set_nthreads(long n)
|
||||
struct qpms_particle_t:
|
||||
cart3_t pos
|
||||
const qpms_tmatrix_t *tmatrix
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
#define QPMS_SCATSYS_TMATRIX_RTOL 1e-12
|
||||
|
||||
long qpms_scatsystem_nthreads_default = 4;
|
||||
long qpms_scatsystem_nthreads_override = 0;
|
||||
|
||||
void qpms_scatsystem_set_nthreads(long n) {
|
||||
qpms_scatsystem_nthreads_override = n;
|
||||
}
|
||||
|
||||
// ------------ Stupid implementation of qpms_scatsys_apply_symmetry() -------------
|
||||
|
||||
|
@ -1419,13 +1424,20 @@ complex double *qpms_scatsys_build_modeproblem_matrix_irrep_packed_parallelR(
|
|||
arg = {ss, &opistartR, &opistartR_mutex, iri, target_packed, k};
|
||||
|
||||
// FIXME THIS IS NOT PORTABLE:
|
||||
long nthreads = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (nthreads < 1) {
|
||||
QPMS_WARN("_SC_NPROCESSORS_ONLN returned %ld, using %ld thread(s) instead.",
|
||||
nthreads, qpms_scatsystem_nthreads_default);
|
||||
nthreads = qpms_scatsystem_nthreads_default;
|
||||
long nthreads;
|
||||
if (qpms_scatsystem_nthreads_override > 0) {
|
||||
nthreads = qpms_scatsystem_nthreads_override;
|
||||
QPMS_WARN("Using overriding value of %ld thread(s).",
|
||||
nthreads);
|
||||
} else {
|
||||
QPMS_DEBUG("_SC_NRPOCESSORS_ONLN returned %ld.", nthreads);
|
||||
nthreads = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (nthreads < 1) {
|
||||
QPMS_WARN("_SC_NPROCESSORS_ONLN returned %ld, using %ld thread(s) instead.",
|
||||
nthreads, qpms_scatsystem_nthreads_default);
|
||||
nthreads = qpms_scatsystem_nthreads_default;
|
||||
} else {
|
||||
QPMS_DEBUG("_SC_NRPOCESSORS_ONLN returned %ld.", nthreads);
|
||||
}
|
||||
}
|
||||
pthread_t thread_ids[nthreads];
|
||||
for(long thi = 0; thi < nthreads; ++thi)
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
#include "qpms_types.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
/// Overrides the number of threads spawned by the paralellized functions.
|
||||
/** TODO MORE DOC which are those? */
|
||||
void qpms_scatsystem_set_nthreads(long n);
|
||||
|
||||
/// A particle, defined by its T-matrix and position.
|
||||
typedef struct qpms_particle_t {
|
||||
// Does it make sense to ever use other than cartesian coords for this?
|
||||
|
|
Loading…
Reference in New Issue