Custom wave vector range supplied as an array
When a custom array of the wave vector range is supplied to the eigensolver, at the end of the dispersion computation an error is popping up.
The snippet of the code used when the error occurred:
k_ = np.concatenate((np.linspace(-80e6,-10e6,21),np.linspace(-10e6,10e6,21),np.linspace(10e6,80e6,21)))
k_ = np.unique(k_)
sample.disp_shs_test = tx.experiments.eigenmodes(sample, num_cpus=-1,num_modes=10, k=k_)
The error message:
TypeError Traceback (most recent call last) Cell In[13], line 3 1 k_ = np.concatenate((np.linspace(-80e6,-10e6,21),np.linspace(-10e6,10e6,21),np.linspace(10e6,80e6,21))) 2 k_ = np.unique(k_) ----> 3 sample.disp_shs_test = tx.experiments.eigenmodes(sample, num_cpus=-1,num_modes=10, k=k_)
File ~/gitlab/tetrax_features/develop/tetrax/experiments/eigen/solve.py:252, in eigenmodes(sample, num_modes, kmin, kmax, Nk, k, m, mmin, mmax, interactions, save_mode_profiles, frequency_tolerance, inverse_tolerance, maxiter_inverse, optional_output, verbose, num_cpus, parallel_backend, label) 237 add_to_bib(sample, "linewidth") 239 result = EigenResult( 240 ResultInfo( 241 result_type=ResultType.EIGEN, (...) 249 has_linewidths=EigenOutput.LINEWIDTHS in config.optional_output, 250 ) --> 252 result.save() 254 return result
File ~/gitlab/tetrax_features/develop/tetrax/experiments/eigen/result.py:193, in EigenResult.save(self, path) 190 outcome_report["files"].append("mode_profiles/") 192 full_report = assemble_report(self.result_info, self.config, outcome_report) --> 193 save_report(full_report, path)
File ~/gitlab/tetrax_features/develop/tetrax/experiments/_result.py:176, in save_report(report, path) 174 """Save a report dictionary to a JSON file.""" 175 with open(path / "report.json", "w") as outfile: --> 176 json.dump(report, outfile, indent=4)
File ~/anaconda3/lib/python3.10/json/init.py:179, in dump(obj, fp, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw) 173 iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii, 174 check_circular=check_circular, allow_nan=allow_nan, indent=indent, 175 separators=separators, 176 default=default, sort_keys=sort_keys, **kw).iterencode(obj) 177 # could accelerate with writelines in some versions of Python, at 178 # a debuggability cost --> 179 for chunk in iterable: 180 fp.write(chunk)
File ~/anaconda3/lib/python3.10/json/encoder.py:431, in _make_iterencode.._iterencode(o, _current_indent_level) 429 yield from _iterencode_list(o, _current_indent_level) 430 elif isinstance(o, dict): --> 431 yield from _iterencode_dict(o, _current_indent_level) 432 else: 433 if markers is not None:
File ~/anaconda3/lib/python3.10/json/encoder.py:405, in _make_iterencode.._iterencode_dict(dct, _current_indent_level) 403 else: 404 chunks = _iterencode(value, _current_indent_level) --> 405 yield from chunks 406 if newline_indent is not None: 407 _current_indent_level -= 1
File ~/anaconda3/lib/python3.10/json/encoder.py:405, in _make_iterencode.._iterencode_dict(dct, _current_indent_level) 403 else: 404 chunks = _iterencode(value, _current_indent_level) --> 405 yield from chunks 406 if newline_indent is not None: 407 _current_indent_level -= 1
File ~/anaconda3/lib/python3.10/json/encoder.py:325, in _make_iterencode.._iterencode_list(lst, _current_indent_level) 323 else: 324 chunks = _iterencode(value, _current_indent_level) --> 325 yield from chunks 326 if newline_indent is not None: 327 _current_indent_level -= 1
File ~/anaconda3/lib/python3.10/json/encoder.py:438, in _make_iterencode.._iterencode(o, _current_indent_level) 436 raise ValueError("Circular reference detected") 437 markers[markerid] = o --> 438 o = _default(o) 439 yield from _iterencode(o, _current_indent_level) 440 if markers is not None:
File ~/anaconda3/lib/python3.10/json/encoder.py:179, in JSONEncoder.default(self, o)
160 def default(self, o):
161 """Implement this method in a subclass such that it returns
162 a serializable object for o
, or calls the base implementation
163 (to raise a TypeError
).
(...)
177
178 """
--> 179 raise TypeError(f'Object of type {o.class.name} '
180 f'is not JSON serializable')
TypeError: Object of type ndarray is not JSON serializable