8000 Rescaled sampling in frequency domain (to have less volatile eps vs freq) by gomezzz · Pull Request #14 · esa/NIDN · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Rescaled sampling in frequency domain (to have less volatile eps vs freq) #14

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

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
12 changes: 7 additions & 5 deletions nidn/training/model/model_to_eps_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ def _eval_model(model, Nx_undersampled, Ny_undersampled, N_layers, target_freque
y = torch.linspace(-1, 1, Ny_undersampled)
z = torch.linspace(-1, 1, N_layers)

# Scales sampling domain of frequencies
freq_scaling = 32.0

# Linearly spaced frequency points
# freq = torch.linspace(-1,1,len(run_cfg.target_frequencies))
# freq = torch.linspace(-freq_scaling, freq_scaling, len(target_frequencies))

# Logspaced frequency points
# Normalize to max val = 1
freq = torch.tensor(target_frequencies / max(target_frequencies))
# Transform to -1 to 1
freq = (freq * 2) - 1
# Transform to -scaling to scaling
freq = (freq * 2 * freq_scaling) - freq_scaling

# Create a meshgrid from the grid ticks
X, Y, Z, FREQ = torch.meshgrid((x, y, z, freq))
Expand Down Expand Up @@ -76,8 +79,7 @@ def _regression_model_to_eps_grid(model, run_cfg: DotMap):

# Initialize the epsilon grid
eps = torch.zeros(
[run_cfg.Nx, run_cfg.Ny, run_cfg.N_layers, run_cfg.N_freq],
dtype=torch.cfloat,
[run_cfg.Nx, run_cfg.Ny, run_cfg.N_layers, run_cfg.N_freq], dtype=torch.cfloat,
)

# Net out is [0,1] thus we transform to desired real and imaginary ranges
Expand Down
8 changes: 1 addition & 7 deletions nidn/trcwa/init_trcwa.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ def _init_trcwa(eps_grid, target_frequency):

# Initialize TRCWA object
trcwa = TRCWA(
TRCWA_NG,
TRCWA_L1,
TRCWA_L2,
freqcmp,
TRCWA_THETA,
TRCWA_PHI,
verbose=0,
TRCWA_NG, TRCWA_L1, TRCWA_L2, freqcmp, TRCWA_THETA, TRCWA_PHI, verbose=0,
)

# Add vacuum layer at the top
Expand Down
54 changes: 54 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""A setuptools based setup module.
See:
https://packaging.python.org/guides/distributing-packages-using-setuptools/
https://github.com/pypa/sampleproject
"""

# Always prefer setuptools over distutils
from setuptools import setup, find_packages

setup(
name="nidn",
version="0.1.0",
description="A package for inverse material design of nanostructures using neural networks.",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url="https://github.com/esa/nidn",
author="ESA Advanced Concepts Team",
author_email="pablo.gomez@esa.int",
install_requires=[
"dotmap>=1.3.24",
"loguru>=0.5.3",
"matplotlib>=3.3.3",
"numpy>=1.20.0",
"pandas>=1.3.1",
"scipy>=1.6.0",
"tqdm>=4.56.1",
"torch>=1.9",
],
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Mathematics",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python :: 3.8",
],
packages=[
"nidn",
"nidn.materials",
"nidn.plots",
"nidn.tests",
"nidn.training",
"nidn.training.losses",
"nidn.training.model",
"nidn.training.utils",
"nidn.trcwa",
"nidn.trcwa.utils",
"nidn.utils",
],
python_requires=">=3.8, <4",
project_urls={
"Source": "https://github.com/esa/nidn/",
},
)
0