Changeset 4417 for trunk/GSASIIpwd.py
- Timestamp:
- May 12, 2020 5:03:59 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpwd.py
r4416 r4417 2625 2625 from fullrmc.Constraints.DihedralAngleConstraints import DihedralAngleConstraint 2626 2626 from fullrmc.Core.MoveGenerator import MoveGeneratorCollector 2627 from fullrmc.Generators.Swaps import SwapPositionsGenerator 2627 2628 from fullrmc.Core.GroupSelector import RecursiveGroupSelector 2628 2629 from fullrmc.Selectors.RandomSelectors import RandomSelector … … 2632 2633 from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutAxisGenerator 2633 2634 from fullrmc.Core.Collection import get_principal_axis 2635 from fullrmc.debugStuff import * 2636 InvokeDebugOpts() 2637 SwapGen = {} 2634 2638 # engine setup\n''' 2635 2639 rundata += 'LOGGER.set_log_file_basename("%s")\n'%pName … … 2662 2666 wtDict['Struct'] = filDat[1] 2663 2667 rundata += ' ENGINE.add_constraints(InterMolecularDistanceConstraint())\n' 2664 if len(BondList): 2665 rundata += ' B_CONSTRAINT = BondConstraint()\n' 2666 rundata += ' ENGINE.add_constraints(B_CONSTRAINT)\n' 2667 if len(AngleList): 2668 rundata += ' A_CONSTRAINT = BondsAngleConstraint()\n' 2669 rundata += ' ENGINE.add_constraints(A_CONSTRAINT)\n' 2670 if len(RMCPdict['Torsions']): 2671 rundata += ' T_CONSTRAINT = DihedralAngleConstraint()\n' 2672 rundata += ' ENGINE.add_constraints(T_CONSTRAINT)\n' 2668 if RMCPdict['byMolec']: 2669 if len(BondList): 2670 rundata += ' B_CONSTRAINT = BondConstraint()\n' 2671 rundata += ' ENGINE.add_constraints(B_CONSTRAINT)\n' 2672 if len(AngleList): 2673 rundata += ' A_CONSTRAINT = BondsAngleConstraint()\n' 2674 rundata += ' ENGINE.add_constraints(A_CONSTRAINT)\n' 2675 if len(RMCPdict['Torsions']): 2676 rundata += ' T_CONSTRAINT = DihedralAngleConstraint()\n' 2677 rundata += ' ENGINE.add_constraints(T_CONSTRAINT)\n' 2673 2678 rundata += ' ENGINE.save()\n' 2674 2679 rundata += 'else:\n' … … 2678 2683 rundata += 'for constraint in Constraints:\n' 2679 2684 rundata += ' strcons = str(type(constraint))\n' 2680 if len(BondList): 2681 rundata += ' if "BondConstraint" in strcons:\n' 2682 rundata += ' constraint.set_variance_squared(%f)\n'%RMCPdict['Bond Weight'] 2683 rundata += ' constraint.create_bonds_by_definition(bondsDefinition={"%s":[\n'%Res 2684 for bond in BondList: 2685 rundata += ' %s'%bond 2686 rundata += ' ]})\n' 2687 if len(AngleList): 2688 rundata += ' elif "BondsAngleConstraint" in strcons:\n' 2689 rundata += ' constraint.set_variance_squared(%f)\n'%RMCPdict['Angle Weight'] 2690 rundata += ' constraint.create_angles_by_definition(anglesDefinition={"%s":[\n'%Res 2691 for angle in AngleList: 2692 rundata += ' %s'%angle 2693 rundata += ' ]})\n' 2694 if len(RMCPdict['Torsions']): 2695 rundata += ' elif "DihedralAngleConstraint" in strcons:\n' 2696 rundata += ' constraint.set_variance_squared(%f)\n'%RMCPdict['Torsion Weight'] 2697 rundata += ' constraint.create_angles_by_definition(anglesDefinition={"%s":[\n'%Res 2698 for torsion in RMCPdict['Torsions']: 2699 rundata += ' %s\n'%str(tuple(torsion)) 2700 rundata += ' ]})\n' 2701 rundata += ' elif "InterMolecular" in strcons:\n' 2685 rundata += ' if "InterMolecular" in strcons:\n' 2702 2686 rundata += ' constraint.set_default_distance(%f)\n'%RMCPdict['min Contact'] 2703 2687 rundata += ' elif "PairDistribution" in strcons:\n' … … 2710 2694 if RMCPdict['FitScale']: 2711 2695 rundata += ' constraint.set_adjust_scale_factor((10, 0.01, 100.))\n' 2712 rundata += 'ENGINE.set_groups_as_atoms()\n' 2696 if RMCPdict['byMolec']: 2697 if len(BondList): 2698 rundata += ' elif "BondConstraint" in strcons:\n' 2699 rundata += ' constraint.set_variance_squared(%f)\n'%RMCPdict['Bond Weight'] 2700 rundata += ' constraint.create_bonds_by_definition(bondsDefinition={"%s":[\n'%Res 2701 for bond in BondList: 2702 rundata += ' %s'%bond 2703 rundata += ' ]})\n' 2704 if len(AngleList): 2705 rundata += ' elif "BondsAngleConstraint" in strcons:\n' 2706 rundata += ' constraint.set_variance_squared(%f)\n'%RMCPdict['Angle Weight'] 2707 rundata += ' constraint.create_angles_by_definition(anglesDefinition={"%s":[\n'%Res 2708 for angle in AngleList: 2709 rundata += ' %s'%angle 2710 rundata += ' ]})\n' 2711 if len(RMCPdict['Torsions']): 2712 rundata += ' elif "DihedralAngleConstraint" in strcons:\n' 2713 rundata += ' constraint.set_variance_squared(%f)\n'%RMCPdict['Torsion Weight'] 2714 rundata += ' constraint.create_angles_by_definition(anglesDefinition={"%s":[\n'%Res 2715 for torsion in RMCPdict['Torsions']: 2716 rundata += ' %s\n'%str(tuple(torsion)) 2717 rundata += ' ]})\n' 2713 2718 if len(RMCPdict['Swaps']): 2714 print(RMCPdict['Swaps']) 2715 2716 # allElements = ENGINE.allElements 2717 # niSwapList = [[idx] for idx in range(len(allElements)) if allElements[idx]=='ni'] 2718 # tiSwapList = [[idx] for idx in range(len(allElements)) if allElements[idx]=='ti'] 2719 # # create swap generator 2720 # toNiSG = SwapPositionsGenerator(swapList=niSwapList) 2721 # toTiSG = SwapPositionsGenerator(swapList=tiSwapList) 2722 2723 2724 rundata += 'ENGINE.run(restartPdb="%s",numberOfSteps=%d, saveFrequency=1000)\n'%(restart,RMCPdict['Cycles']) 2719 rundata += ' allNames = ENGINE.allNames\n' 2720 for swap in RMCPdict['Swaps']: 2721 rundata += ' SwapA = [[idx] for idx in range(len(allNames)) if allNames[idx]=="%s"]\n'%swap[0] 2722 rundata += ' SwapB = [[idx] for idx in range(len(allNames)) if allNames[idx]=="%s"]\n'%swap[1] 2723 rundata += ' SwapGen["%s-%s"] = [SwapPositionsGenerator(swapList=SwapA),SwapPositionsGenerator(swapList=SwapB),%.2f]\n'%(swap[0],swap[1],swap[2]) 2725 2724 rundata += 'ENGINE.save()\n' 2726 2725 rundata += '#setup runs for fullrmc\n' 2727 2728 2729 2730 2731 2732 2733 2734 2726 2727 rundata += 'for _ in range(%d):\n'%RMCPdict['Cycles'] 2728 rundata += ' ENGINE.set_groups_as_atoms()\n' 2729 rundata += ' ENGINE.run(restartPdb="%s",numberOfSteps=10000, saveFrequency=1000)\n'%restart 2730 rundata += ' for swaps in SwapGen:\n' 2731 rundata += ' AB = swaps.split("-")\n' 2732 rundata += ' ENGINE.set_groups_as_atoms()\n' 2733 rundata += ' for g in ENGINE.groups:\n' 2734 rundata += ' if allNames[g.indexes[0]]==AB[0]:\n' 2735 rundata += ' g.set_move_generator(SwapGen[swaps][0])\n' 2736 rundata += ' elif allNames[g.indexes[0]]==AB[1]:\n' 2737 rundata += ' g.set_move_generator(SwapGen[swaps][1])\n' 2738 rundata += ' sProb = SwapGen[swaps][2]\n' 2739 rundata += ' ENGINE.run(restartPdb="%s",numberOfSteps=10000*sProb, saveFrequency=1000)\n'%restart 2740 rundata += ' ENGINE.set_groups_as_atoms()\n' 2741 rundata += ' ENGINE.run(restartPdb="%s",numberOfSteps=10000*(1.-sProb), saveFrequency=1000)\n'%restart 2742 rundata += 'ENGINE.close()\n' 2735 2743 rfile = open(rname,'w') 2736 2744 rfile.writelines(rundata)
Note: See TracChangeset
for help on using the changeset viewer.