Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix scheme interface to DFT freqs #1186

Merged
merged 1 commit into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scheme/meep-ctl-swig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ ctlio::cnumber_list make_casimir_g_kz(double T, double dt, double sigma, meep::f
meep::volume_list *make_volume_list(const meep::volume &v, int c, std::complex<double> weight,
meep::volume_list *next);

ctlio::number_list std_vector_double_to_scm(std::vector<double> *v);

#endif // MEEP_CTL_SWIG_HPP
9 changes: 9 additions & 0 deletions scheme/meep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,12 @@ ctlio::cnumber_list make_casimir_g_kz(double T, double dt, double sigma, meep::f
delete[] g;
return res;
}

ctlio::number_list std_vector_double_to_scm(std::vector<double> *v) {
ctlio::number_list res;
res.num_items = int(v->size());
res.items = new number[res.num_items];
for (int i = 0; i < res.num_items; ++i)
res.items[i] = (*v)[i];
return res;
}
31 changes: 8 additions & 23 deletions scheme/meep.scm.in
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,7 @@
(meep-dft-flux-scale-dfts f s))

(define (get-flux-freqs f)
(arith-sequence
(meep-dft-flux-freq-min-get f)
(meep-dft-flux-dfreq-get f)
(meep-dft-flux-Nfreq-get f)))
(std-vector-double-to-scm (meep-dft-flux-freq-get f)))

(export-type (make-list-type 'number))
(define (get-fluxes f)
Expand Down Expand Up @@ -640,10 +637,7 @@
(meep-dft-energy-scale-dfts f s))

(define (get-energy-freqs f)
(arith-sequence
(meep-dft-energy-freq-min-get f)
(meep-dft-energy-dfreq-get f)
(meep-dft-energy-Nfreq-get f)))
(std-vector-double-to-scm (meep-dft-energy-freq-get f)))

(define (get-electric-energy f)
(dft-energy-electric f))
Expand Down Expand Up @@ -708,10 +702,7 @@
(meep-dft-force-scale-dfts f s))

(define (get-force-freqs f)
(arith-sequence
(meep-dft-force-freq-min-get f)
(meep-dft-force-dfreq-get f)
(meep-dft-force-Nfreq-get f)))
(std-vector-double-to-scm (meep-dft-force-freq-get f)))

(define (get-forces f)
(dft-force-force f))
Expand Down Expand Up @@ -759,10 +750,7 @@
(meep-dft-near2far-scale-dfts f s))

(define (get-near2far-freqs f)
(arith-sequence
(meep-dft-near2far-freq-min-get f)
(meep-dft-near2far-dfreq-get f)
(meep-dft-near2far-Nfreq-get f)))
(std-vector-double-to-scm (meep-dft-near2far-freq-get f)))

(define (get-farfield f x)
(dft-near2far-farfield f x))
Expand Down Expand Up @@ -1224,9 +1212,9 @@
(direction (get-keyword-value args #:direction AUTOMATIC))
(num-bands (length bands))
(kpoint-func (get-keyword-value args #:kpoint-func '())))
(begin
(define coeffs (make-typed-array 'c64 '0 num-bands (meep-dft-flux-Nfreq-get flux) 2))
(define vgrp (make-typed-array 'f64 '0 num-bands (meep-dft-flux-Nfreq-get flux)))
(let ((nfreq (length (get-flux-freqs flux))))
(define coeffs (make-typed-array 'c64 '0 num-bands nfreq 2))
(define vgrp (make-typed-array 'f64 '0 num-bands nfreq))
(define kpoints-and-kdom (do-get-eigenmode-coefficients fields flux eig-vol bands eig-parity coeffs vgrp
eig-resolution eig-tolerance kpoint-func direction))
(list coeffs vgrp (first kpoints-and-kdom) (second kpoints-and-kdom)))))
Expand All @@ -1239,10 +1227,7 @@
(define dft-ldos-Jdata '())

(define (get-ldos-freqs f)
(arith-sequence
(/ (meep-dft-ldos-omega-min-get f) (* 2 pi))
(/ (meep-dft-ldos-domega-get f) (* 2 pi))
(meep-dft-ldos-Nomega-get f)))
(std-vector-double-to-scm (meep-dft-ldos-freq-get f)))

(define (dft-ldos fcen df nfreq)
(let ((ldos (new-meep-dft-ldos
Expand Down