Changeset 1896


Ignore:
Timestamp:
Jun 18, 2015 1:25:47 PM (7 years ago)
Author:
vondreele
Message:

add auto constraint for TwinFr? sum = 1.0
fix TwinFr? derivative - now OK & works

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrIO.py

    r1894 r1896  
    201201        print G2mv.VarRemapShow(varyList,True)
    202202    return errmsg, warnmsg
     203   
     204def makeTwinFrConstr(Phases,Histograms,hapVary):
     205    TwConstr = []
     206    TwFixed = []
     207    for Phase in Phases:
     208        pId = Phases[Phase]['pId']
     209        for Histogram in Phases[Phase]['Histograms']:
     210            hId = Histograms[Histogram]['hId']
     211            phfx = '%d:%d:'%(pId,hId)
     212            if phfx+'TwinFr:0' in hapVary:
     213                TwFixed.append('1.0')     #constraint value
     214                nTwin = len(Phases[Phase]['Histograms'][Histogram]['Twins'])
     215                TwConstr.append({phfx+'TwinFr:'+str(i):'1.0' for i in range(nTwin)})
     216    return TwConstr,TwFixed   
    203217   
    204218def GetRestraints(GPXfile):
  • trunk/GSASIIstrMain.py

    r1886 r1896  
    164164    calcControls['maxSSwave'] = maxSSwave
    165165    hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,Histograms,pFile=printFile)
     166    TwConstr,TwFixed = G2stIO.makeTwinFrConstr(Phases,Histograms,hapVary)
     167    constrDict += TwConstr
     168    fixedList += TwFixed
    166169    calcControls.update(controlDict)
    167170    histVary,histDict,controlDict = G2stIO.GetHistogramData(Histograms,pFile=printFile)
  • trunk/GSASIIstrMath.py

    r1895 r1896  
    10191019                dFdui[iref] = [SA[it]*(dfadui[0][it]+dfbdui[1][it])+SB[it]*(dfbdui[0][it]+dfadui[1][it]) for it in range(nTwin)]
    10201020                dFdua[iref] = [SA[it]*(dfadua[it][0]+dfbdua[it][1])+SB[it]*(dfbdua[it][0]+dfadua[it][1]) for it in range(nTwin)]
    1021                 dFdtw[iref] = 2.*SA+2.*SB
     1021                dFdtw[iref] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2
    10221022            else:
    10231023                dFdfr[iref] = 2.*SA*(dfadfr[0]+dfbdfr[1])*Mdata/len(Uniq)+ \
     
    10621062    if nTwin > 1:
    10631063        for i in range(nTwin):
    1064             dFdvDict[phfx+'TwinFr:'+str(i)] = dFdtw.T[i]
     1064            dFdvDict[phfx+'TwinFr:'+str(i)] = dFdtw.T[i]/4.
    10651065    return dFdvDict
    10661066   
Note: See TracChangeset for help on using the changeset viewer.