Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
paulxshen committed Jan 14, 2025
1 parent f24d413 commit 7ddb114
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Luminescent_AI_docs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1246,15 +1246,15 @@
},
"outputs": [],
"source": [
"# 30G RAM\n",
"# 60G RAM\n",
"import os\n",
"import luminescent as lumi\n",
"\n",
"path = os.path.join(\"runs\", \"demux\")\n",
"c = lumi.mimo(west=1, east=1, south=1, l=4.0, w=4.0, wwg=.5, taper=0.05)\n",
"c = lumi.mimo(west=1, east=2, l=5.0, w=5.0, wwg=.5, taper=0.05)\n",
"targets = {\"tparams\": {\n",
" 1.2: {\"3,1\": 1.0},\n",
" 1.80: {\"2,1\": 1.0},\n",
" 0.9: {\"3,1\": 1.0},\n",
" 1.8: {\"2,1\": 1.0},\n",
"}}\n",
"\n",
"lumi.make_pic_inv_prob(\n",
Expand Down
3 changes: 2 additions & 1 deletion luminescent/luminescent/pic/sparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def make_pic_sim_prob(path, c: gf.Component, nres,
study="sparams",

wavelength=None,
wl_res=.01,
**kwargs):
if wavelength:
raise ValueError("wavelength is deprecated, use wavelengths instead")
Expand All @@ -36,7 +37,7 @@ def make_pic_sim_prob(path, c: gf.Component, nres,
wavelengths = [wavelengths]
else:
wavelengths = wavelengths
wavelengths, wl, T = adjust_wavelengths(wavelengths)
wavelengths, wl, T = adjust_wavelengths(wavelengths, wl_res)
for w in wavelengths:
for k in keys:
entries.append([w, *unpack_sparam_key(k)])
Expand Down
15 changes: 7 additions & 8 deletions luminescent/luminescent/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,24 +191,23 @@ def wavelength_range(center, bandwidth, length=3):
return sorted([1/x for x in np.linspace(f1, f2, length).tolist()])


def adjust_wavelengths(wavelengths, wl_res=.05):
wavelengths0 = copy.deepcopy(wavelengths)
def adjust_wavelengths(wavelengths, wl_res=.01):
if len(wavelengths) == 1:
return wavelengths, wavelengths[0], 1
wavelengths = sorted(set(wavelengths), reverse=True)
wavelengths = sorted(set(wavelengths))
wavelengths0 = copy.deepcopy(wavelengths)
wl = median(wavelengths)
freqs = [wl/w for w in wavelengths]
nresfreq = round(1/min(np.diff([0]+freqs)))
freqs0 = [wl/w for w in reversed(wavelengths)]
nresfreq = round(1/min(np.diff([0]+freqs0)))

while True:
freqs = [round(f*nresfreq)/nresfreq for f in freqs]

freqs = [round(f*nresfreq)/nresfreq for f in freqs0]
wavelengths = [wl/f for f in reversed(freqs)]
if max([abs(w-w0) for w, w0 in zip(wavelengths, wavelengths0)]) <= wl_res:
break
nresfreq += 1
print(
f"wavelengths has been adjusted to facilitate simulation:\n{wavelengths}")
f"wavelengths has been adjusted within `wl_res` to facilitate simulation:\n{wavelengths}")
return wavelengths, wl, nresfreq


Expand Down
2 changes: 1 addition & 1 deletion luminescent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='luminescent', # Your package name
version='0.4.7', # Your package version
version='0.4.9', # Your package version
description='A description of your package',
author='Paul Shen',
author_email='pxshen@alumni.stanford.edu',
Expand Down
18 changes: 9 additions & 9 deletions luminescent/temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@
# sol = lumi.load_res(path)


# 30G RAM
import os
import luminescent as lumi

path = os.path.join("runs", "splitter")
c = lumi.mimo(west=1, east=2, l=4.0, w=2.0, wwg=.5, taper=.05, )
targets = {
"tparams": {1.55: {"2,1": 0.5}},
}
path = os.path.join("runs", "demux")
c = lumi.mimo(west=1, east=1, south=1, l=4.0, w=4.0, wwg=.5, taper=0.05)
targets = {"tparams": {
1.2: {"3,1": 1.0},
1.80: {"2,1": 1.0},
}}

lumi.make_pic_inv_prob(
path, c, targets,
nres=15, symmetries=[1],
lvoid=0.2, lsolid=.1,
iters=50, stoploss=.05,
approx_2D_mode="TE") # ,dtype="float16")#,gpu="CUDA")
lvoid=0.15, lsolid=0.1, nres=30,
approx_2D_mode="TE", stoploss=.1, iters=200, dtype="float16") # ,gpu="CUDA")
lumi.solve(path)
21 changes: 15 additions & 6 deletions temp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import numpy as np
# 30G RAM
import os
import luminescent as lumi

try:
np.finfo(np.float16)
print("float16 is supported.")
except ValueError:
print("float16 is not supported.")
path = os.path.join("runs", "demux")
c = lumi.mimo(west=1, east=1, south=1, l=4.0, w=4.0, wwg=.5, taper=0.05)
targets = {"tparams": {
1.2: {"3,1": 1.0},
1.80: {"2,1": 1.0},
}}

lumi.make_pic_inv_prob(
path, c, targets,
lvoid=0.15, lsolid=0.1, nres=30,
approx_2D_mode="TE", stoploss=.1, iters=200, dtype="float16") # ,gpu="CUDA")
lumi.solve(path)

0 comments on commit 7ddb114

Please sign in to comment.