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

get_ldos_freqs method for Python LDOS objects #1156

Merged
merged 1 commit into from
Mar 27, 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
4 changes: 2 additions & 2 deletions doc/docs/Python_User_Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -1417,9 +1417,9 @@ Meep can also calculate the LDOS (local density of states) spectrum, as describe
Create an LDOS object with frequency bandwidth `df` centered at `fcen`, at `nfreq` frequency points. This can be passed to the `dft_ldos` step function below, and has the properties `freq_min`, `nfreq` and `dfreq`.

**`freqs()`**
**`get_ldos_freqs(ldos)`**
Method of `Ldos` that returns a list of the frequencies that this `Ldos` instance is computing the spectrum for.
Given an LDOS object, returns a list of the frequencies that it is computing the spectrum for.

**`dft_ldos(fcen=None, df=None, nfreq=None, ldos=None)`**
Expand Down
1 change: 1 addition & 0 deletions python/meep.i
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ PyObject *_get_array_slice_dimensions(meep::fields *f, const meep::volume &where
get_fluxes,
get_force_freqs,
get_forces,
get_ldos_freqs,
get_magnetic_energy,
get_near2far_freqs,
get_total_energy,
Expand Down
6 changes: 5 additions & 1 deletion python/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2961,14 +2961,18 @@ def _ldos(sim, todo):
sim.ldos_data = mp._dft_ldos_ldos(ldos)
sim.ldos_Fdata = mp._dft_ldos_F(ldos)
sim.ldos_Jdata = mp._dft_ldos_J(ldos)
display_csv(sim, 'ldos', zip(ldos.freq, sim.ldos_data))
display_csv(sim, 'ldos', zip(mp.get_ldos_freqs(ldos), sim.ldos_data))
return _ldos


def scale_flux_fields(s, flux):
flux.scale_dfts(s)


def get_ldos_freqs(l):
return [l.freq[i] for i in range(l.freq.size())]


def get_flux_freqs(f):
return [f.freq[i] for i in range(f.freq.size())]

Expand Down
3 changes: 1 addition & 2 deletions python/tests/ldos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import math
import unittest

import meep as mp
Expand Down Expand Up @@ -43,7 +42,7 @@ def test_ldos_user_object(self):
)

self.assertAlmostEqual(self.sim.ldos_data[0], 1.011459560620368)
self.assertEqual(ldos.freq.size(), 1)
self.assertEqual(len(mp.get_ldos_freqs(ldos)), 1)

def test_invalid_dft_ldos(self):
with self.assertRaises(ValueError):
Expand Down