pyEPR.core_distributed_analysis module¶
Main distributed analysis module to use pyEPR.
Contains code to connect to Ansys and to analyze HFSS files using the EPR method.
This module handles the microwave part of the analysis and connection to
Further contains code to be able to do autogenerated reports,
Copyright Zlatko Minev, Zaki Leghtas, and the pyEPR team 2015, 2016, 2017, 2018, 2019, 2020
-
class
pyEPR.core_distributed_analysis.
DistributedAnalysis
(*args, **kwargs)[source]¶ Bases:
object
DISTRIBUTED ANALYSIS of layout and microwave results.
Main computation class & interface with HFSS.
This class defines a DistributedAnalysis object which calculates and saves Hamiltonian parameters from an HFSS simulation.
Further, it allows one to calculate dissipation, etc.
-
calc_Q_external
(variation, freq_GHz, U_E=None)[source]¶ Calculate the coupling Q of mode m with each port p Expected that you have specified the mode before calling this
Parameters: - variation (str) – A string identifier of the variation,
- as '0', '1', .. (such) –
-
calc_avg_current_J_surf_mag
(variation: str, junc_rect: str, junc_line)[source]¶ - Peak current I_max for mode J in junction J
- The avg. is over the surface of the junction. I.e., spatial.
Parameters: - variation (str) – A string identifier of the variation, such as ‘0’, ‘1’, …
- junc_rect (str) – name of rectangle to integrate over
- junc_line (str) – name of junction line to integrate over
Returns: Value of peak current
-
calc_current
(fields, line: str)[source]¶ Function to calculate Current based on line. Not in use.
Parameters: line (str) – integration line between plates - name
-
calc_current_using_line_voltage
(variation: str, junc_line_name: str, junc_L_Henries: float, Cj_Farads: float = None)[source]¶ Peak current I_max for prespecified mode calculating line voltage across junction.
Make sure that you have set the correct variation in HFSS before running this
Parameters: - variation – variation number
- junc_line_name – name of the HFSS line spanning the junction
- junc_L_Henries – junction inductance in henries
- Cj_Farads – junction cap in Farads
- TODO – Smooth?
-
calc_energy_electric
(variation: str = None, obj: str = 'AllObjects', volume: str = 'Deprecated', smooth: bool = False, obj_dims: int = 3)[source]¶ Calculates two times the peak electric energy, or 4 times the RMS, \(4*\mathcal{E}_{\mathrm{elec}}\) (since we do not divide by 2 and use the peak phasors).
\[\mathcal{E}_{\mathrm{elec}}=\frac{1}{4}\mathrm{Re}\int_{V}\mathrm{d}v\vec{E}_{\text{max}}^{*}\overleftrightarrow{\epsilon}\vec{E}_{\text{max}}\]Parameters: - variation (str) – A string identifier of the variation, such as ‘0’, ‘1’, …
- obj (string | 'AllObjects') – Name of the object to integrate over
- smooth (bool | False) – Smooth the electric field or not when performing calculation
- obj_dims (int | 3) – 1 - line, 2 - surface, 3 - volume. Default volume
Example
Example use to calculate the energy participation ratio (EPR) of a substrate
1 2 3
ℰ_total = epr_hfss.calc_energy_electric(obj='AllObjects') ℰ_substr = epr_hfss.calc_energy_electric(obj='Box1') print(f'Energy in substrate = {100*ℰ_substr/ℰ_total:.1f}%')
-
calc_energy_magnetic
(variation: str = None, obj: str = 'AllObjects', volume: str = 'Deprecated', smooth: bool = False, obj_dims: int = 3)[source]¶ See calc_energy_electric.
Parameters: - variation (str) – A string identifier of the variation, such as ‘0’, ‘1’, …
- volume (string | 'AllObjects') – Name of the volume to integrate over
- smooth (bool | False) – Smooth the electric field or not when performing calculation
- obj_dims (int | 3) – 1 - line, 2 - surface, 3 - volume. Default volume
-
calc_p_electric_volume
(name_dielectric3D, relative_to='AllObjects', variation=None, E_total=None)[source]¶ Calculate the dielectric energy-participation ratio of a 3D object (one that has volume) relative to the dielectric energy of a list of objects.
This is as a function relative to another object or all objects.
When all objects are specified, this does not include any energy that might be stored in any lumped elements or lumped capacitors.
Returns: ℰ_object/ℰ_total, (ℰ_object, _total)
-
calc_p_junction
(variation, U_H, U_E, Ljs, Cjs)[source]¶ For a single specific mode. Expected that you have specified the mode before calling this,
set_mode()
.Expected to precalc U_H and U_E for mode, will return pandas pd.Series object:
- junc_rect = [‘junc_rect1’, ‘junc_rect2’] name of junc rectangles to integrate H over
- junc_len = [0.0001] specify in SI units; i.e., meters
- LJs = [8e-09, 8e-09] SI units
- calc_sign = [‘junc_line1’, ‘junc_line2’]
WARNING: Cjs is experimental.
This function assumes there are no lumped capacitors in model.
Parameters: - variation (str) – A string identifier of the variation,
- as '0', '1', .. (such) –
Note
U_E and U_H are the total peak energy. (NOT twice as in U_ and U_H other places)
Warning
Potential errors: If you dont have a line or rect by the right name you will prob get an error of the type: com_error: (-2147352567, ‘Exception occurred.’, (0, None, None, None, 0, -2147024365), None)
-
calc_p_junction_single
(mode, variation, U_E=None, U_H=None)[source]¶ This function is used in the case of a single junction only. For multiple junctions, see
calc_p_junction()
.Assumes no lumped capacitive elements.
-
design
¶ Ansys design class handle
-
do_EPR_analysis
(variations: list = None, modes=None, append_analysis=True)[source]¶ Main analysis routine
Parameters: variation (str) – A string identifier of the variation, such as ‘0’, ‘1’, … - variations : list | None
- Example list of variations is [‘0’, ‘1’] A variation is a combination of project/design variables in an optimetric sweep
- modes : list | None
- Modes to analyze for example modes = [0, 2, 3]
- append_analysis (bool) :
- When we run the Ansys analysis, should we redo any variations that we have already done?
- Assumptions:
Low dissipation (high-Q). It is easier to assume no lumped capacitors to simply calculations, but we have recently added Cj_variable as a new feature that is begin tested to handle capacitors.
See the paper.
Load results with epr.QuantumAnalysis class1 2
eprd = epr.DistributedAnalysis(pinfo) eprd.do_EPR_analysis(append_analysis=False)
-
get_Qseam
(seam, mode, variation, U_H=None)[source]¶ Calculate the contribution to Q of a seam, by integrating the current in the seam with finite conductance: set in the config file ref: http://arxiv.org/pdf/1509.01119.pdf
-
get_Qseam_sweep
(seam, mode, variation, variable, values, unit, U_H=None, pltresult=True)[source]¶ Q due to seam loss.
values = [‘5mm’,’6mm’,’7mm’] ref: http://arxiv.org/pdf/1509.01119.pdf
-
get_Qsurface
(mode, variation, name, U_E=None, material_properties=None)[source]¶ Calculate the contribution to Q of a dielectric layer of dirt on a given surface. Set the dirt thickness and loss tangent in the config file ref: http://arxiv.org/pdf/1509.01854.pdf
-
get_Qsurface_all
(mode, variation, U_E=None)[source]¶ 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
-
get_ansys_frequencies_all
(vs='variation')[source]¶ Return all ansys frequencies and quality factors vs a variation
Returns a multi-index pandas DataFrame
-
get_ansys_variables
()[source]¶ Get ansys variables for all variations
Returns: Return a dataframe of variables as index and columns as the variations
-
get_ansys_variations
()[source]¶ Will update ansys information and result the list of variations.
Returns: ("Cj='2fF' Lj='12nH'", "Cj='2fF' Lj='12.5nH'", "Cj='2fF' Lj='13nH'", "Cj='2fF' Lj='13.5nH'", "Cj='2fF' Lj='14nH'")
Return type: For example
-
get_convergence
(variation='0')[source]¶ Parameters: - variation (str) – A string identifier of the variation,
- as '0', '1', .. (such) –
Returns: A pandas DataFrame object
1 2 3 4 5
Solved Elements Max Delta Freq. % Pass Number 1 128955 NaN 2 167607 11.745000 3 192746 3.208600 4 199244 1.524000
-
get_convergence_vs_pass
(variation='0')[source]¶ Makes a plot in HFSS that return a pandas dataframe
Parameters: - variation (str) – A string identifier of the variation,
- as '0', '1', .. (such) –
Returns: Returns a convergence vs pass number of the eignemode freqs.
1 2 3 4 5
re(Mode(1)) [g] re(Mode(2)) [g] re(Mode(3)) [g] Pass [] 1 4.643101 4.944204 5.586289 2 5.114490 5.505828 6.242423 3 5.278594 5.604426 6.296777
-
get_freqs_bare
(variation: str)[source]¶ Warning
Outdated. Do not use. To be deprecated
Parameters: variation (str) – A string identifier of the variation, such as ‘0’, ‘1’, … Returns: [type] – [description]
-
get_freqs_bare_pd
(variation: str, frame=True)[source]¶ Return the freq and Qs of the solved modes for a variation. I.e., the Ansys solved frequencies.
Parameters: - variation (str) – A string identifier of the variation, such as ‘0’, ‘1’, …
- {bool} -- if True returns dataframe, else tuple of series. (frame) –
Returns: If frame = True, then a multi-index Dataframe that looks something like this
Freq. (GHz) Quality Factor variation mode 0 0 5.436892 1020 1 7.030932 50200 1 0 5.490328 2010 1 7.032116 104500
If frame = False, then a tuple of two Series, such as (Fs, Qs) – Tuple of pandas.Series objects; the row index is the mode number
-
get_junc_len_dir
(variation: str, junc_line)[source]¶ Return the length and direction of a junction defined by a line
Parameters: - variation (str) – simulation variation
- junc_line (str) – polyline object
Returns: junction length uj (list of 3 floats): x,y,z coordinates of the unit vector
tangent to the junction line
Return type: jl (float)
-
get_junctions_L_and_C
(variation: str)[source]¶ Returns a pandas Series with the index being the junction name as specified in the project_info.
The values in the series are numeric and in SI base units, i.e., not nH but Henries, and not fF but Farads.
Parameters: - variation (str) – label such as ‘0’ or ‘all’, in which case return
- table for all variations (pandas) –
-
get_mesh_statistics
(variation='0')[source]¶ Parameters: - variation (str) – A string identifier of the variation,
- as '0', '1', .. (such) –
Returns: A pandas dataframe, such as
1 2 3
Name Num Tets Min edge length Max edge length RMS edge length Min tet vol Max tet vol Mean tet vol Std Devn (vol) 0 Region 909451 0.000243 0.860488 0.037048 6.006260e-13 0.037352 0.000029 6.268190e-04 1 substrate 1490356 0.000270 0.893770 0.023639 1.160090e-12 0.031253 0.000007 2.309920e-04
-
get_nominal_variation_index
()[source]¶ Returns: A string identifies, such as ‘0’ or ‘1’, that labels the nominal variation index number. This may not be in the solved list!s
-
get_previously_analyzed
()[source]¶ Return previously analyzed data.
Does not yet handle data that was previously saved in a filename.
-
get_variable_vs_variations
(variable: str, convert: bool = True)[source]¶ Get ansys variables
Return HFSS variable from
self.get_ansys_variables()
as a pandas series vs variations.Parameters: convert (bool) – Convert to a numeric quantity if possible using the ureg
-
get_variables
(variation=None)[source]¶ Get ansys variables.
Parameters: variation (str) – A string identifier of the variation, such as ‘0’, ‘1’, …
-
get_variation_string
(variation=None)[source]¶ Solved variation string identifier.
Parameters: variation (str) – A string identifier of the variation, such as ‘0’, ‘1’, … Returns: Return the list variation string of parameters in ansys used to identify the variation. "$test='0.25mm' Cj='2fF' Lj='12.5nH'"
-
get_variations
()[source]¶ An array of strings corresponding to solved variations corresponding to the selected Setup.
Returns: Returns a list of strings that give the variation labels for HFSS. OrderedDict([ ('0', "Cj='2fF' Lj='12nH'"), ('1', "Cj='2fF' Lj='12.5nH'"), ('2', "Cj='2fF' Lj='13nH'"), ('3', "Cj='2fF' Lj='13.5nH'"), ('4', "Cj='2fF' Lj='14nH'")])
-
has_fields
(variation: str = None)[source]¶ Determine if fields exist for a particular solution. Just calls self.solutions.has_fields(variation_string)
Parameters: variation (str) – String of variation label, such as ‘0’ or ‘1’. If None, gets the nominal variation
-
hfss_report_f_convergence
(variation='0', save_csv=True)[source]¶ Create a report inside HFSS to plot the converge of freq and style it.
Saves report to csv file.
Returns a convergence vs pass number of the eignemode freqs. Returns a pandas dataframe:
re(Mode(1)) [g] re(Mode(2)) [g] re(Mode(3)) [g] Pass [] 1 4.643101 4.944204 5.586289 2 5.114490 5.505828 6.242423 3 5.278594 5.604426 6.296777
-
hfss_report_full_convergence
(fig=None, _display=True)[source]¶ Plot a full report of teh convergences of an eigenmode analysis for a a given variation. Makes a plot inside hfss too.
Keyword Arguments: - {matplotlib figure} -- Optional figure (default (fig) – {None})
- {bool} -- Force display or not. (default (_display) – {True})
Returns: [type] – [description]
-
load
(filepath=None)[source]¶ Utility function to load results file
Keyword Arguments: {[type]} -- [description] (default (filepath) – {None})
-
n_variations
¶ Number of solved variations, corresponding to the selected Setup.
-
options
¶ Project info options
-
project
¶ Ansys project class handle
-
quick_plot_frequencies
(swp_variable='variations', ax=None)[source]¶ Quick plot of frequencies from HFSS
-
static
results_variations_on_inside
(results: dict)[source]¶ Switches the order on result of variations. Reverse dict.
-
save
(project_info: dict = None)[source]¶ Save results to self.data_filename
Keyword Arguments: {dict} -- [description] (default (project_info) – {None})
-
set_mode
(mode_num, phase=0)[source]¶ Set source excitations should be used for fields post processing. Counting modes from 0 onward
-
set_variation
(variation: str)[source]¶ Set the ansys design to a solved variation. This will change all local variables!
Warning: not tested with global variables.
-
setup
¶ Ansys setup class handle. Could be None.
-
setup_data
()[source]¶ Set up folder paths for saving data to.
Sets the save filename with the current time.
Saves to Path(config.root_dir) / self.project.name / self.design.name
-
update_ansys_info
()[source]¶ ‘ Updates all information about the Ansys solved variations and variables.
1
n_modes, _list_variations, nominal_variation, n_variations
-
variations
= None¶ List of variation indices, which are strings of ints, such as [‘0’, ‘1’]
-