Working on scripts_common
Former-commit-id: 830060579114debef9874748618e0dcf3f14882c
This commit is contained in:
parent
e2f9923f31
commit
4dbb8f09b0
|
@ -1,4 +1,13 @@
|
||||||
import argparse
|
#import argparse # Do I need it when calling just parser methods?
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
__TODOs__ = '''
|
||||||
|
- Implement a more user-friendly way to define the lattice base vectors and positions of the particles.
|
||||||
|
cf. https://stackoverflow.com/questions/2371436/evaluating-a-mathematical-expression-in-a-string/2371789
|
||||||
|
- low priority: allow to perform some more custom operations on T-Matrix, using some kind of parsing from the previous point
|
||||||
|
- Autodetect symmetries
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
def make_action_sharedlist(opname, listname):
|
def make_action_sharedlist(opname, listname):
|
||||||
class opAction(argparse.Action):
|
class opAction(argparse.Action):
|
||||||
|
@ -10,7 +19,7 @@ def make_action_sharedlist(opname, listname):
|
||||||
|
|
||||||
|
|
||||||
def add_argparse_k_output_options(parser):
|
def add_argparse_k_output_options(parser):
|
||||||
parser.add_argument('--kdensity', '--k_density', action='store', type=int, default=33, help='Number of k-points per x-axis segment FIXME DESCRIPTION')
|
parser.add_argument('--kdensity', '--k_density', action='store', type=int, nargs='+', default=33, help='Number of k-points per x-axis segment FIXME DESCRIPTION')
|
||||||
parser.add_argument('--bz_coverage', action='store', type=float, default=1., help='Brillouin zone coverage in relative length (default 1 for whole 1. BZ)')
|
parser.add_argument('--bz_coverage', action='store', type=float, default=1., help='Brillouin zone coverage in relative length (default 1 for whole 1. BZ)')
|
||||||
parser.add_argument('--bz_edge_width', action='store', type=float, default=0., help='Width of the more densely covered belt along the 1. BZ edge in relative lengths')
|
parser.add_argument('--bz_edge_width', action='store', type=float, default=0., help='Width of the more densely covered belt along the 1. BZ edge in relative lengths')
|
||||||
parser.add_argument('--bz_edge_factor', action='store', type=float, default=8., help='Relative density of the belt along the 1. BZ edge w.r.t. k_density (default==8)')
|
parser.add_argument('--bz_edge_factor', action='store', type=float, default=8., help='Relative density of the belt along the 1. BZ edge w.r.t. k_density (default==8)')
|
||||||
|
@ -52,43 +61,32 @@ def add_argparse_common_options(parser):
|
||||||
parser.add_argument('--frequency_multiplier', action='store', type=float, default=1., help='Multiplies the frequencies in the TMatrix file by a given factor.')
|
parser.add_argument('--frequency_multiplier', action='store', type=float, default=1., help='Multiplies the frequencies in the TMatrix file by a given factor.')
|
||||||
|
|
||||||
|
|
||||||
__TODOs__ = '''
|
|
||||||
BIG TODO: Use more efficient way to calculate the interaction sums: perhaps some customized Ewald-type summation?
|
|
||||||
|
|
||||||
Small TODOs:
|
|
||||||
- Implement a more user-friendly way to define the lattice base vectors and positions of the particles.
|
|
||||||
cf. https://stackoverflow.com/questions/2371436/evaluating-a-mathematical-expression-in-a-string/2371789
|
|
||||||
- low priority: allow to perform some more custom operations on T-Matrix, using some kind of parsing from the previous point
|
|
||||||
- Autodetect symmetries
|
|
||||||
|
|
||||||
|
def arg_preprocess_particles(parser, d=None, return_tuple=False):
|
||||||
'''
|
'''
|
||||||
import argparse, re, random, string
|
Nanoparticle position and T-matrix path parsing
|
||||||
import subprocess
|
|
||||||
from scipy.constants import hbar, e as eV, pi, c
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
returns a dictionary d with keys 'particle_specs' and 'TMatrix_specs'
|
||||||
pargs=parser.parse_args()
|
|
||||||
print(pargs)
|
|
||||||
|
|
||||||
exit(0) ###
|
parser: ArgumentParser on which add_argparse_unitcell_definitions() and whose
|
||||||
|
parse_args() has been called.
|
||||||
|
|
||||||
maxlayer=pargs.maxlayer
|
d['TMatrix_specs'] is a list of specs where a spec is a tuple of
|
||||||
#DEL hexside=pargs.hexside
|
(lMax_override, TMatrix_path, ops).
|
||||||
eVfreq = pargs.eVfreq
|
|
||||||
freq = eVfreq*eV/hbar
|
|
||||||
verbose=pargs.verbose
|
|
||||||
|
|
||||||
#DEL TMatrix_file = pargs.TMatrix
|
lMax_override: int or None
|
||||||
|
TMatrix_path: string
|
||||||
|
ops: iterable with operations on the T-Matrix to be processed with perform_ops()
|
||||||
|
|
||||||
epsilon_b = pargs.background_permittivity #2.3104
|
d['particle_specs'] is an iterable of tuples (label, (xpos, ypos), TMatrix_spec_index)
|
||||||
gaussianSigma = pargs.gaussian if pargs.gaussian else None # hexside * 222 / 7
|
TMatrix_spec_index is an index of the corresponding element of d['TMatrix_specs']
|
||||||
interpfreqfactor = pargs.frequency_multiplier
|
|
||||||
scp_dest = pargs.scp_to if pargs.scp_to else None
|
|
||||||
kdensity = pargs.kdensity
|
|
||||||
chunklen = pargs.chunklen
|
|
||||||
|
|
||||||
#### Nanoparticle position and T-matrix path parsing ####
|
|
||||||
|
If a dictionary d is provided, the result is written into it; if d is None (default),
|
||||||
|
a new dictionary is created.
|
||||||
|
If return_tuple is true, then a tuple (particle_specs, TMatrix_specs) is returned
|
||||||
|
instead of the dictionary d.
|
||||||
|
'''
|
||||||
TMatrix_paths = dict()
|
TMatrix_paths = dict()
|
||||||
lMax_overrides = dict()
|
lMax_overrides = dict()
|
||||||
default_TMatrix_path = None
|
default_TMatrix_path = None
|
||||||
|
@ -182,6 +180,46 @@ particles_specs = [(label, positions(label),
|
||||||
tuple(ops[label]))]
|
tuple(ops[label]))]
|
||||||
) for label in positions.keys()]
|
) for label in positions.keys()]
|
||||||
|
|
||||||
|
# This converts the TMatrix_specs dict to a list of its ex-keys in the ex-value order
|
||||||
|
TMatrix_specs = dict((v,k) for (k,v) in TMatrix_specs.items()) # invert dict
|
||||||
|
TMatrix_specs = [TMatrix_specs[i] for i in range(len(TMatrix_specs))] # convert to list
|
||||||
|
|
||||||
|
if d is None:
|
||||||
|
d = dict()
|
||||||
|
d['particle_specs'] = particle_specs
|
||||||
|
d['TMatrix_specs'] = TMatrix_specs
|
||||||
|
if return_tuple:
|
||||||
|
return (particles_specs, TMatrix_specs)
|
||||||
|
else:
|
||||||
|
return d
|
||||||
|
|
||||||
|
'''
|
||||||
|
import argparse, re, random, string
|
||||||
|
import subprocess
|
||||||
|
from scipy.constants import hbar, e as eV, pi, c
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
pargs=parser.parse_args()
|
||||||
|
print(pargs)
|
||||||
|
|
||||||
|
exit(0) ###
|
||||||
|
|
||||||
|
maxlayer=pargs.maxlayer
|
||||||
|
#DEL hexside=pargs.hexside
|
||||||
|
eVfreq = pargs.eVfreq
|
||||||
|
freq = eVfreq*eV/hbar
|
||||||
|
verbose=pargs.verbose
|
||||||
|
|
||||||
|
#DEL TMatrix_file = pargs.TMatrix
|
||||||
|
|
||||||
|
epsilon_b = pargs.background_permittivity #2.3104
|
||||||
|
gaussianSigma = pargs.gaussian if pargs.gaussian else None # hexside * 222 / 7
|
||||||
|
interpfreqfactor = pargs.frequency_multiplier
|
||||||
|
scp_dest = pargs.scp_to if pargs.scp_to else None
|
||||||
|
kdensity = pargs.kdensity
|
||||||
|
chunklen = pargs.chunklen
|
||||||
|
|
||||||
# -----------------finished basic CLI parsing (except for op arguments) ------------------
|
# -----------------finished basic CLI parsing (except for op arguments) ------------------
|
||||||
from qpms.timetrack import _time_b, _time_e
|
from qpms.timetrack import _time_b, _time_e
|
||||||
btime=_time_b(verbose)
|
btime=_time_b(verbose)
|
||||||
|
@ -344,3 +382,4 @@ for chunki in range(chunkn):
|
||||||
|
|
||||||
_time_e(btime, verbose)
|
_time_e(btime, verbose)
|
||||||
#print(time.strftime("%H.%M:%S",time.gmtime(time.time()-begtime)))
|
#print(time.strftime("%H.%M:%S",time.gmtime(time.time()-begtime)))
|
||||||
|
'''
|
||||||
|
|
Loading…
Reference in New Issue