Open anlinus opened 11 months ago
Apologies for the delayed response. I missed the notification for this issue.
It looks like you are adding an output file to the project after you wrote the project to a file. It needs to happen the other way around.
In general, all of the settings in the project
object are written to a file using project.make_sonnet_file()
. Then project.run()
calls the simulator on the file not the object.
As for the .exe
, testing is done on linux currently, and I don't plan on supporting windows directly. But it's good to know that it doesn't take much to get it working. Feel free to put up a PR with a fix for windows if you'd like though
Information
First of all, great piece of code! After a first test, I noticed that the _add_syz_parameterfile() function doesn't seem to create a thouchstone file to the defined location. Not sure what is the issue really. Simulations work good though, I can plot the results if I enter the sonnet file via the GUI.
Here is the code, it's just a slight modification from you example:
`# -- coding: utf-8 -- """ Created on Mon Dec 4 13:31:05 2023 @author: anlinus """ import logging import numpy as np import pysonnet as ps
%%
sonnet_file_path = r"C:\Users\anlinus\Documents\Sonnet Python\ring_resonator_code.son" path_to_sonnet = r"C:\Program Files\Sonnet Software\18.56"
Set up logging to the console
log = logging.getLogger() log.setLevel(logging.DEBUG) # Only prints project.run() information. Set to logging.DEBUG for more detail log.addHandler(logging.StreamHandler())
%%
Geometric constants
box_x, box_y = 100, 100 # size of the box width = 5 # transmission line width mlin_length = box_x layer = 0 # layer for gds format datatype = 1 # datatype for gds format
%%
Initialize the path
mlin = [ np.array([ [0, width/2+box_y/2], [0, -width/2+box_y/2], [box_x, -width/2+box_y/2], [box_x, width/2+box_y/2] ]) ] print(mlin[0])
%%
The GeometryProject is the most basic Sonnet project type
project = ps.GeometryProject()
The default length unit for Sonnet is mils,so let's change it
project.set_units(length='um')
Then we can set up the box
project.setup_box(box_x, box_y, 200, 200)
Define the metal types and if they are on the box top/bottom
high kinetic inductance superconductor
project.define_metal("general", "PtSi", ls=21)
low kinetic inductance superconductor
project.define_metal("general", "Nb", ls=0.08) project.set_box_cover("free space", top=True) project.set_box_cover("custom", name="Nb", bottom=True)
Lets add a dielectric layer under the microstrip and air above
project.add_dielectric("air", layer, thickness=1000) project.add_dielectric("silicon", layer + 1, thickness=100, epsilon=11.9, dielectric_loss=0.004, conductivity=4.4e-4)
We can also define technology layers
project.define_technology_layer("metal", "microstrip", layer, "PtSi", fill_type="diagonal")
We also might want to see the current density
project.set_options(current_density=True, memory='high')
%%
project.add_polygons("metal", mlin, tech_layer="microstrip") project.add_port("standard", 1, 0, box_y/2 - width/2, resistance=50) project.add_port("standard", 2, box_x, box_y/2 - width/2, resistance=50)
%%
Add the frequency sweep to the project
project.add_frequency_sweep("linear", f1=1, f2=10, f_step=0.1)
Select an analysis (doesn't need to be done if running the project)
project.set_analysis("frequency sweep")
Make the sonnet file
project.make_sonnet_file(sonnet_file_path)
Locate Sonnet
project.locate_sonnet(path_to_sonnet)
%%
Run the project
project.run("frequency sweep")
%%
project.add_syz_parameter_file('touchstone', output_folder="C:/Users/anlinus/Documents/Sonnet Python", file_name='ring_resonator_code_test')`
PS. I had to change line 22
em_path = os.path.join(sonnet_path, 'bin', 'em.exe')
where I had to add .exe to be able to find the em engine.