Changeset 2316 for trunk/GSASIIobj.py
- Timestamp:
- Jun 12, 2016 8:22:48 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIobj.py
r2308 r2316 1661 1661 (list of 1-3 str values)''' 1662 1662 1663 self.distance_stuff = None # to be used for defining atom distances 1664 self.distance_atoms = None # to be used for defining atom distances 1665 1663 1666 def LoadExpression(self,expr,exprVarLst,varSelect,varName,varValue,varRefflag): 1664 1667 '''Load the expression and associated settings into the object. Raises … … 1939 1942 if not isinstance(self.eObj.assgnVars[v], basestring): 1940 1943 self.eObj.assgnVars[v] = self.eObj.assgnVars[v][0] 1944 self.parmDict = {} 1945 '''A copy of the parameter dictionary, for distance and angle computation 1946 ''' 1941 1947 1942 1948 def SetupCalc(self,parmDict): … … 1944 1950 Adds the free parameter values to the parameter dict (parmDict). 1945 1951 ''' 1952 if self.eObj.expression.startswith('Dist'): 1953 return 1946 1954 self.fxnpkgdict = self.eObj.CheckVars() 1947 1955 # all is OK, compile the expression … … 2011 2019 :param list parmDict: a dict of values some of which may be in use here 2012 2020 ''' 2021 if self.eObj.expression.startswith('Dist'): 2022 self.parmDict = parmDict 2023 return 2013 2024 for var in parmDict: 2014 2025 if var in self.lblLookup: … … 2030 2041 then the result will be ``4.0``. 2031 2042 ''' 2043 if self.eObj.expression.startswith('Dist'): 2044 dist = 0 2045 #dist = CalcDist(self.eObj.distance_stuff, self.eObj.distance_atoms, self.parmDict) 2046 return dist 2032 2047 if self.compiledExpr is None: 2033 2048 raise Exception,"EvalExpression called before SetupCalc" … … 2061 2076 obj.freeVars = {'A': [u'A', 0.5, True]} 2062 2077 #obj.CheckVars() 2078 calcobj = ExpressionCalcObj(obj) 2079 2080 obj1 = ExpressionObj() 2081 obj1.expression = "A*np.exp(B)" 2082 obj1.assgnVars = {'B': '0::Afrac:*'} 2083 obj1.freeVars = {'A': [u'Free Prm A', 0.5, True]} 2084 #obj.CheckVars() 2085 calcobj1 = ExpressionCalcObj(obj1) 2086 2087 obj2 = ExpressionObj() 2088 obj2.distance_stuff = np.array([[0,1],[1,-1]]) 2089 obj2.expression = "Dist(1,2)" 2090 GSASIIpath.InvokeDebugOpts() 2063 2091 parmDict2 = {'0::Afrac:0':[0.0,True], '0::Afrac:1': [1.0,False]} 2064 calcobj = ExpressionCalcObj(obj) 2092 calcobj2 = ExpressionCalcObj(obj2) 2093 calcobj2.SetupCalc(parmDict2) 2094 showEQ(calcobj2) 2095 2096 parmDict1 = {'0::Afrac:0':1.0, '0::Afrac:1': 1.0} 2097 print '\nDict = ',parmDict1 2098 calcobj.SetupCalc(parmDict1) 2099 showEQ(calcobj) 2100 calcobj1.SetupCalc(parmDict1) 2101 showEQ(calcobj1) 2102 2103 parmDict2 = {'0::Afrac:0':[0.0,True], '0::Afrac:1': [1.0,False]} 2104 print 'Dict = ',parmDict2 2065 2105 calcobj.SetupCalc(parmDict2) 2066 2106 showEQ(calcobj) 2067 2068 obj.expression = "A*np.exp(B)" 2069 obj.assgnVars = {'B': '0::Afrac:*'} 2070 obj.freeVars = {'A': [u'Free Prm A', 0.5, True]} 2071 #obj.CheckVars() 2072 parmDict1 = {'0::Afrac:0':1.0, '0::Afrac:1': 1.0} 2073 calcobj = ExpressionCalcObj(obj) 2074 calcobj.SetupCalc(parmDict1) 2075 showEQ(calcobj) 2076 2077 calcobj.SetupCalc(parmDict2) 2078 showEQ(calcobj) 2107 calcobj1.SetupCalc(parmDict2) 2108 showEQ(calcobj1) 2109 calcobj2.SetupCalc(parmDict2) 2110 showEQ(calcobj2)
Note: See TracChangeset
for help on using the changeset viewer.