CST.docx
《CST.docx》由会员分享,可在线阅读,更多相关《CST.docx(24页珍藏版)》请在冰豆网上搜索。
CST
'*Construct/DiscretePorts/ComputeSelfInductanceofDis.Ports
'!
!
!
Donotchangethelineabove!
!
'
'fhi:
05-03-2009addedlinkstoCapsfordifferential/nondifferentialLinks
'fhi:
10-09-2007Capson/off,meshsymmetry-planesconsidered,mesh-searchbasedonmin/maxmesh-step
'fhi:
20-08-2007adaptedtoDE2008
'fhi:
11-02-2006Initialversion
'fhi:
03-04-2006Compute-LforarbitrarilyorientatedportsandaddsthemintoDesignStudio
'fhi:
05-04-2006De2006:
SP5corrections:
PRTracker2593,2608-2610,2614
'fhi:
07-04-2006Differential_portsandBlocksimplemented,Dialogadded,autom.deletionofexistingports/blocks
'fhi:
30-10-2006Correctionofz_lower=Mesh.getzpos(Z_istop)insubroutine"search_for_zlower_z_upper"
'fhi:
31-10-2006Addedequivalentcapacitanceofports(port-wiresrep.bytwolongcylinders)
OptionExplicit
PublicListPortArray()AsString
PublicPortArrayLengthAsInteger
PublicDiscrete_Port_List()AsString,Total_Nr_of_Discrete_PortsAsInteger,N_max_searchesAsInteger
SubMain
Dimlong_ref_dirAsLong,long_ref_indexAsLong,port_nrAsInteger,deltaAsDouble
DimxAsDouble,yAsDouble,zAsDouble,plengthAsDouble,X_start_indexAsLong,X_istopAsLong
Dimx_upperAsDouble,x_lowerAsDouble,wire_radiusAsDouble
DimY_start_indexAsLong,Y_istopAsLong,y_upperAsDouble,y_lowerAsDouble,L_iAsDouble
DimL_aAsDouble,glengthAsDouble,iiiAsInteger,port_nameAsString,index_pAsLong
Dimport_indexAsLong,z_upperAsDouble,z_lowerAsDouble,output_stringAsString
Dimlong_ref_index2AsLong,source_start_pointAsDouble,source_end_pointAsDouble
Dimsource_lengthAsDouble,port_onearmlengthAsDouble,C_portAsDouble
'DS
Dimmws_block_port_position_xAsLong,mws_block_port_position_yAsLong
Dimmws_block_center_position_xAsLong,mws_block_center_position_yAsLong,make_absAsString
Dimx_offsetAsInteger,y_offsetAsInteger,size_offsetAsInteger
Dimblockname_variableAsString,rel_x_posAsDouble,rel_y_posAsDouble,rot_angleAsDouble
Dimdifferential_flagAsBoolean,orientationAsString
BeginDialogUserDialog360,119,"Drawneg.LandCfordiscretePorts"'%GRID:
10,7,1,1
CheckBox30,35,120,14,"CreateLinks",.CreateLinks
CheckBox30,50,220,21,"DifferentialPortsandBlocks",.Diff_ports_blocks
OKButton30,98,100,21
CancelButton140,98,90,21
CheckBox30,75,140,14,"CreateReport",.report
CheckBox30,15,140,14,"addCapacitances",.add_caps
EndDialog
DimdlgAsUserDialog
'setdialogdefaults
dlg.Createlinks=1:
dlg.diff_ports_blocks=0:
dlg.report=0:
dlg.add_caps=1'0=no1=yes
If(Dialog(dlg)=0)ThenExitAll'dothedialog
Ifdlg.diff_ports_blocks=1Then
differential_flag=True
Else
differential_flag=False
EndIf
size_offset=200'positionoffsetfordrawingtheelements
Total_Nr_of_Discrete_Ports=0
'searchforallportsintheMWSsection
port_name="Ports\"
get_all_child_namesport_name,ListPortArray(),PortArrayLength
Forindex_p=0ToPortArrayLength-1
port_index=Mid(ListPortArray(index_p),5,Len(ListPortArray(index_p))-4)'
IfPort.getType(port_index)="Discrete"Then'findalldiscr.ports
ReDimPreserveDiscrete_Port_List(Total_Nr_of_Discrete_Ports)
Discrete_Port_List(Total_Nr_of_Discrete_Ports)=CStr(port_index)
Total_Nr_of_Discrete_Ports=Total_Nr_of_Discrete_Ports+1
Else'wgport
ReDimPreserveDiscrete_Port_List(Total_Nr_of_Discrete_Ports)
Discrete_Port_List(Total_Nr_of_Discrete_Ports)=CStr(-port_index)'wg-port:
indicatedasnegnumber!
Total_Nr_of_Discrete_Ports=Total_Nr_of_Discrete_Ports+1
EndIf
Next
'addtexttoareport-file
output_string="TotalNumberofPorts:
"+CStr(Total_Nr_of_Discrete_Ports)+vbCrLf
'LoopoverallPorts--------------------------------------------------------------------------
Forindex_p=0ToTotal_Nr_of_Discrete_Ports-1
IfCInt(Discrete_Port_List(index_p))>0Then'consideronlydiscreteportsfor-Lcomputation
output_string=output_string+vbCrLf+"Port"+CStr(Discrete_Port_List(index_p))+vbCrLf
output_string=output_string+"PortImpedance="+CStr(Port.GetLineImpedance(Discrete_Port_List(index_p),1))+"Ohm"
plength=DiscretePort.getlength(Discrete_Port_List(index_p))
glength=DiscretePort.getgridlength(Discrete_Port_List(index_p))
output_string=output_string+"Gridlength="+CStr(glength)+"PortLength="+CStr(plength)+_
"Deviation="+CStr(Format((100*(glength-plength)/plength),"###0.##"))+"%"+vbCrLf
DiscretePort.GetElementDirIndex(Discrete_Port_List(index_p),long_ref_dir,long_ref_index)
x=Mesh.getxpos(long_ref_index)
y=Mesh.getypos(long_ref_index)
z=Mesh.getzpos(long_ref_index)
output_string=output_string+"SourceCenter-location"+CStr(x)+"/"+CStr(y)+"/"+CStr(z)
'************search-densityforgridpoints
'delta=plength/100'searchincrementtofindnextmeshindex,100=1%ofPort-length
delta=Mesh.GetMinimumEdgeLength/2'newmethod
N_max_searches=CInt(2*Mesh.GetMaximumEdgeLength/Mesh.GetMinimumEdgeLength)
'************endofsearch-density
Iflong_ref_dir=2Then'(orientationinz)
search_for_xlower_x_upper(delta,long_ref_index,x_upper,x_lower)
search_for_ylower_y_upper(delta,long_ref_index,y_upper,y_lower)
output_string=output_string+"Orientation=z"+vbCrLf
output_string=output_string+"LocationMeshlinesX:
"+CStr(x_lower)+"/center"+CStr(Mesh.getxpos(long_ref_index))+"/"+CStr(x_upper)+vbCrLf
output_string=output_string+"LocationMeshlinesY:
"+CStr(y_lower)+"/center"+CStr(Mesh.getypos(long_ref_index))+"/"+CStr(y_upper)
'effectiveradius
wire_radius=(Abs(x_upper-x_lower)+Abs(y_upper-y_lower))/(4*Exp
(1)^2)'meanvalueradius
output_string=output_string+vbCrLf+"Wireradius="+CStr(wire_radius)
'FormelfürLofastraightwire:
'innerL
L_i=Units.GetGeometryUnitToSI()*plength*4*pi*1e-7/(8*pi)
L_a=Units.GetGeometryUnitToSI()*plength*2*1e-7*(Log(2*plength/wire_radius)-1)
output_string=output_string+"L_i="+CStr(L_i*1e9)+"L_a="+CStr(L_a*1e9)+"nH"+vbCrLf
'------capacitanceofdiscreteportz------
Ifdlg.add_caps=1Then
source_start_point=Mesh.getzpos(long_ref_index)
DiscretePort.GetElement2ndIndex(Discrete_Port_List(index_p),long_ref_index2)
source_end_point=Mesh.getzpos(long_ref_index2)
source_length=Abs(source_end_point-source_start_point)
port_onearmlength=(plength-source_length)/2
C_port=Units.GetGeometryUnitToSI()*(4*pi*8.856e-12*port_onearmlength)/(Log((4*port_onearmlength^2*(4*source_length/2+port_onearmlength))/_
((2*wire_radius)^2*(4*source_length/2+3*port_onearmlength))))
output_string=output_string+"Port_Capacitance="+CStr(C_port*1e12)+"pF"+vbCrLf
EndIf
'----------endcapz----------------------
EndIf'orientationz.....
Iflong_ref_dir=0Then'(orientationinx)
search_for_zlower_z_upper(delta,long_ref_index,z_upper,z_lower)
search_for_ylower_y_upper(delta,long_ref_index,y_upper,y_lower)
output_string=output_string+"Orientation=x"+vbCrLf
output_string=output_string+"LocationMeshlinesZ:
"+CStr(z_lower)+"/center"+CStr(Mesh.getzpos(long_ref_index))+"/"+CStr(z_upper)+vbCrLf
output_string=output_string+"LocationMeshlinesY:
"+CStr(y_lower)+"/center"+CStr(Mesh.getypos(long_ref_index))+"/"+CStr(y_upper)
'effectiveradius
wire_radius=(Abs(z_upper-z_lower)+Abs(y_upper-y_lower))/(4*Exp
(1)^2)'meanvalueradius
output_string=output_string+vbCrLf+"Wireradius="+CStr(wire_radius)
'FormelfürLofastraightwire:
'innerL
L_i=Units.GetGeometryUnitToSI()*plength*4*pi*1e-7/(8*pi)
L_a=Units.GetGeometryUnitToSI()*plength*2*1e-7*(Log(2*plength/wire_radius)-1)
output_string=output_string+"L_i="+CStr(L_i*1e9)+"L_a="+CStr(L_a*1e9)+"nH"+vbCrLf
'------capacitanceofdiscreteportx------
Ifdlg.add_caps=1Then
source_start_point=Mesh.getxpos(long_ref_index)
DiscretePort.GetElement2ndIndex(Discrete_Port_List(index_p),long_ref_index2)
source_end_point=Mesh.getxpos(long_ref_index2)
source_length=Abs(source_end_point-source_start_point)
port_onearmlength=(plength-source_length)/2
C_port=Units.GetGeometryUnitToSI()*(4*pi*8.856e-12*port_onearmlength)/(Log((4*port_onearmlength^2*(4*source_length/2+port_onearmlength))/_
((2*wire_radius)^2*(4*source_length/2+3*port_onearmlength))))
output_string=output_string+"Port_Capacitance="+CStr(C_port*1e12)+"pF"+vbCrLf
EndIf
'----------endcapx----------------------
EndIf'orientationx.....
Iflong_ref_dir=1Then'(orientationiny)
search_for_zlower_z_upper(delta,long_ref_index,z_upper,z_lower)
search_for_xlower_x_upper(delta,long_ref_index,x_upper,x_lower)
output_string=output_string+"Orientation=y"+vbCrLf
output_string=output_string+"LocationMeshlinesZ:
"+CStr(z_lower)+"/center"+CStr(Mesh.getzpos(long_ref_index))+"/"+CStr(z_upper)+vbCrLf
output_string=output_string+"LocationMeshlinesX:
"+CStr(x_lower)+"/center"+CStr(Mesh.getxpos(long_ref_index))+"/"+CStr(x_upper)
'effectiveradius
wire_radius=(Abs(z_upper-z_lower)+Abs(x_upper-x_lower))/(4*Exp
(1)^2)'meanvalueradius
output_string=output_string+vbCrLf+"Wireradius="+CStr(wire_radius)
'FormelfürLofastraightwire:
'innerL
L_i=Units.GetGeometryUnitToSI()*plength*4*pi*1e-7/(8*pi)
L_a=Units.GetGeometryUnitToSI()*plength*2*1e-7*(Log(2*plength/wire_radius)-1)
output_string=output_string+"L_i="+CStr(L_i*1e9)+"L_a="+CStr(L_a*1e9)+"nH"+vbCrLf
'------capacitanceofdiscreteporty------
Ifdlg.add_caps=1Then
source_start_point=Mesh.getypos(long_ref_index)
DiscretePort.GetElement2ndIndex(Discrete_Port_List(index_p),long_ref_index2)
sourc