// Script function: Calculate effective atomic number using Lenz model
// See page: https://www.globalsino.com/EM/page948.html


// Unless named starting with GlobalSino, EM, My, Self, the function commands are defined 
//by Gatan DM, please see at link: http://www.globalsino.com/EM/page2597.html


TagGroup GlobalSino, EMItems
GlobalSino = DLGCreateDialog( "Please input your numbers", EMItems )
 
TagGroup MyNumberA1,MyNumberB1,MyNumberA2,MyNumberB2,MyNumberA3,MyNumberB3,MyNumberA4,MyNumberB4,MyNumberA5,MyNumberB5,MyNumberA6,MyNumberB6,MyNumberA7,MyNumberB7,MyNumberA8,MyNumberB8,MyNumberA9,MyNumberB9
 
EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z1  :", MyNumberA1, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z1 :", MyNumberB1, 0, 8, 5 ) )       

EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z2  :", MyNumberA2, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z2 :", MyNumberB2, 0, 8, 5 ) )       

EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z3  :", MyNumberA3, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z3 :", MyNumberB3, 0, 8, 5 ) )       

EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z4  :", MyNumberA4, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z4 :", MyNumberB4, 0, 8, 5 ) )       

EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z5  :", MyNumberA5, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z5 :", MyNumberB5, 0, 8, 5 ) )       

EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z6  :", MyNumberA6, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z6 :", MyNumberB6, 0, 8, 5 ) )       

EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z7  :", MyNumberA7, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z7 :", MyNumberB7, 0, 8, 5 ) )       

EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z8  :", MyNumberA8, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z8 :", MyNumberB8, 0, 8, 5 ) )       

EMItems.DLGAddElement( DLGCreateRealField( "Fraction of Z9  :", MyNumberA9, 0, 8, 3 ) )       
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number of Z9 :", MyNumberB9, 0, 8, 5 ) )       
 
if ( !Alloc( UIframe ).Init( GlobalSino ).Pose() ) exit (0)
 
number ZeffLenz, ZeffMayneord

number A1 = MyNumberA1.DLGGetValue()
number B1 = MyNumberB1.DLGGetValue()
number A2 = MyNumberA2.DLGGetValue()
number B2 = MyNumberB2.DLGGetValue()
number A3 = MyNumberA3.DLGGetValue()
number B3 = MyNumberB3.DLGGetValue()
number A4 = MyNumberA4.DLGGetValue()
number B4 = MyNumberB4.DLGGetValue()
number A5 = MyNumberA5.DLGGetValue()
number B5 = MyNumberB5.DLGGetValue()
number A6 = MyNumberA6.DLGGetValue()
number B6 = MyNumberB6.DLGGetValue()
number A7 = MyNumberA7.DLGGetValue()
number B7 = MyNumberB7.DLGGetValue()
number A8 = MyNumberA8.DLGGetValue()
number B8 = MyNumberB8.DLGGetValue()
number A9 = MyNumberA9.DLGGetValue()
number B9 = MyNumberB9.DLGGetValue()

ZeffLenz = (A1*(B1**1.3)+A2*(B2**1.3)+A3*(B3**1.3)+A4*(B4**1.3)+A5*(B5**1.3)+A6*(B6**1.3)+A7*(B7**1.3)+A8*(B8**1.3)+A9*(B9**1.3))/(A1*(B1**0.3)+A2*(B2**0.3)+A3*(B3**0.3)+A4*(B4**0.3)+A5*(B5**0.3)+A6*(B6**0.3)+A7*(B7**0.3)+A8*(B8**0.3)+A9*(B9**0.3))


result (ZeffLenz + "\n")

