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

Added ansys calculator functions #76

Merged
merged 4 commits into from
May 9, 2021
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
31 changes: 28 additions & 3 deletions pyEPR/ansys.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@
try:
import pythoncom
except (ImportError, ModuleNotFoundError):
pass
pass #raise NameError ("pythoncom module not installed. Please install.")

try:
# TODO: Replace `win32com` with Linux compatible package.
# See Ansys python files in IronPython internal.
from win32com.client import Dispatch, CDispatch
except (ImportError, ModuleNotFoundError):
pass
pass #raise NameError ("win32com module not installed. Please install.")

try:
from pint import UnitRegistry
ureg = UnitRegistry()
Q = ureg.Quantity
except (ImportError, ModuleNotFoundError):
ureg = "Pint module not installed. Please install."
pass # raise NameError ("Pint module not installed. Please install.")


##############################################################################
###
Expand Down Expand Up @@ -2936,6 +2937,30 @@ def getQty(self, name):
def integrate_line(self, name):
return self._integrate(name, "EnterLine")

def normal2surface(self, name):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

''' return the part normal to surface.
Complex Vector. '''
stack = self.stack + [("EnterSurf", name),
("CalcOp", "Normal")]
stack.append(("CalcOp", "Dot"))
stack.append(("EnterSurf", name))
stack.append(("CalcOp", "Normal"))
stack.append(("CalcOp", "*"))
return CalcObject(stack, self.setup)

def tangent2surface(self, name):
''' return the part tangent to surface.
Complex Vector. '''
stack = self.stack + [("EnterSurf", name),
("CalcOp", "Normal")]
stack.append(("CalcOp", "Dot"))
stack.append(("EnterSurf", name))
stack.append(("CalcOp", "Normal"))
stack.append(("CalcOp", "*"))
stack = self.stack + stack
stack.append(("CalcOp", "-"))
return CalcObject(stack, self.setup)

def integrate_line_tangent(self, name):
''' integrate line tangent to vector expression \n
name = of line to integrate over '''
Expand Down
18 changes: 8 additions & 10 deletions pyEPR/core_distributed_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ def __init__(self, *args, **kwargs):
# Modes and variations - the following get updated in update_variation_information
self.n_modes = int(1) # : Number of eigenmodes
self.modes = None
#: List of variation indecies, which are strings of ints, such as ['0', '1']
#: List of variation indices, which are strings of ints, such as ['0', '1']
self.variations = []
self.variations_analyzed = [] # : List of analyzed variations. List of indecies
self.variations_analyzed = [] # : List of analyzed variations. List of indices

# String identifier of variables, such as "Cj='2fF' Lj='12.5nH'"
self._nominal_variation = ''
self._list_variations = ("",) # tuple set of variables
# container for eBBQ list of varibles; basically the same as _list_variations
# container for eBBQ list of variables; basically the same as _list_variations
self._hfss_variables = Dict()

self._previously_analyzed = set() # previously analyzed variations
Expand Down Expand Up @@ -356,7 +356,6 @@ def _get_lv(self, variation=None):

['Lj1:=','13nH', 'QubitGap:=','100um']
'''

if variation is None:
lv = self._nominal_variation # "Cj='2fF' Lj='12.5nH'"
lv = self._parse_listvariations(lv)
Expand All @@ -369,7 +368,7 @@ def _get_lv(self, variation=None):

@property
def n_variations(self):
""" Number of **solved** variaitons, corresponding to the
""" Number of **solved** variations, corresponding to the
selected Setup. """
return len(self._list_variations)

Expand Down Expand Up @@ -477,7 +476,6 @@ def update_ansys_info(self):
n_modes, _list_variations, nominal_variation, n_variations

'''

# from oDesign
self._nominal_variation = self.design.get_nominal_variation()

Expand Down Expand Up @@ -888,7 +886,7 @@ def get_Qdielectric(self, dielectric, mode, variation, U_E=None):

def get_Qsurface_all(self, mode, variation, U_E=None):
'''
caculate the contribution to Q of a dieletric layer of dirt on all surfaces
calculate the contribution to Q of a dielectric layer of dirt on all surfaces
set the dirt thickness and loss tangent in the config file
ref: http://arxiv.org/pdf/1509.01854.pdf
'''
Expand Down Expand Up @@ -1027,10 +1025,10 @@ def calc_p_junction(self, variation, U_H, U_E, Ljs, Cjs):
#print('\tV_peak=', V_peak)

# ------------------------------------------------------------
# Calcualte participations from the peak voltage and currents
# Calculate participation from the peak voltage and currents
#

# All junction capactive and inductive lumped energies - all peak
# All junction capacitive and inductive lumped energies - all peak
U_J_inds = {j_name: 0.5*Ljs[j_name] * I_peak_[j_name]
** 2 for j_name in self.pinfo.junctions}
U_J_caps = {j_name: 0.5*Cjs[j_name] * V_peak_[j_name]
Expand Down Expand Up @@ -1423,7 +1421,7 @@ def save(self, project_info: dict = None):
pickle.dump(to_save, handle) # , protocol=pickle.HIGHEST_PROTOCOL)

def load(self, filepath=None):
"""Utility function to load reuslts file
"""Utility function to load results file

Keyword Arguments:
filepath {[type]} -- [description] (default: {None})
Expand Down
2 changes: 1 addition & 1 deletion pyEPR/core_quantum_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def analyze_all_variations(self,

Specific params:
--------------------
variations : None returns all_variations otherwis this is a list with number
variations : None returns all_variations otherwise this is a list with number
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!!

as strings ['0', '1']
nalyze_previous :set to true if you wish to overwrite previous analysis
'''
Expand Down