Changeset 4404 for trunk/GSASIIpwd.py
- Timestamp:
- Apr 19, 2020 11:52:51 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpwd.py
r4400 r4404 2106 2106 #### RMCutilities 2107 2107 ################################################################################ 2108 2108 2109 2109 def MakeInst(PWDdata,Name,Size,Mustrain,useSamBrd): 2110 2110 inst = PWDdata['Instrument Parameters'][0] … … 2423 2423 fl.write(' > CAVSTR%d :: %d %d %.2f %.2f %.2f %.6f\n'%(iav+1,at1+1,at2+1,avcn[2],avcn[3],avcn[4],avcn[5])) 2424 2424 for File in Files: 2425 if Files[File][0] :2425 if Files[File][0] and Files[File][0] != 'Select': 2426 2426 if 'Xray' in File and 'F(Q)' in File: 2427 2427 fqdata = open(Files[File][0],'r') … … 2462 2462 return fname 2463 2463 2464 def MakefullrmcRun( Name,Phase,RMCPdict):2465 print(' nothing happened yet')2466 rname = Name+'-run.py'2464 def MakefullrmcRun(pName,Phase,RMCPdict): 2465 rname = pName+'-run.py' 2466 Files = RMCPdict['files'] 2467 2467 rundata = '' 2468 rundata += '#### fullrmc $s file; edit by hand if you so choose #####\n'&rname2468 rundata += '#### fullrmc %s file; edit by hand if you so choose #####\n'%rname 2469 2469 rundata += ''' 2470 # fullrmc imports (all that are potentially useful) 2470 2471 import numpy as np 2471 2472 # fullrmc library imports 2473 from fullrmc.Globals import LOGGER, FLOAT_TYPE 2472 from fullrmc.Globals import LOGGER 2474 2473 from fullrmc.Engine import Engine 2475 2474 from fullrmc.Constraints.PairDistributionConstraints import PairDistributionConstraint 2476 2475 from fullrmc.Constraints.PairCorrelationConstraints import PairCorrelationConstraint 2476 from fullrmc.Constraints.StructureFactorConstraints import StructureFactorConstraint 2477 2477 from fullrmc.Constraints.DistanceConstraints import InterMolecularDistanceConstraint 2478 2478 from fullrmc.Constraints.BondConstraints import BondConstraint 2479 2479 from fullrmc.Constraints.AngleConstraints import BondsAngleConstraint 2480 2480 from fullrmc.Constraints.ImproperAngleConstraints import ImproperAngleConstraint 2481 from fullrmc.Core.Collection import convert_Gr_to_gr2482 2481 from fullrmc.Core.MoveGenerator import MoveGeneratorCollector 2483 2482 from fullrmc.Core.GroupSelector import RecursiveGroupSelector … … 2485 2484 from fullrmc.Selectors.OrderedSelectors import DefinedOrderSelector 2486 2485 from fullrmc.Generators.Translations import TranslationGenerator, TranslationAlongSymmetryAxisGenerator 2487 from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutSymmetryAxisGenerator2488 2486 from fullrmc.Generators.Agitations import DistanceAgitationGenerator, AngleAgitationGenerator 2489 2490 # engine file names - replace name with phase name 2491 engineFileName = "name_engine.rmc" 2492 expFileName = "name_pdf.exp" 2493 pdbFileName = "nme.pdb" 2494 freshStart = False #make TRUE for a restart 2495 2496 ''' 2487 from fullrmc.Generators.Rotations import RotationGenerator, RotationAboutAxisGenerator 2488 from fullrmc.Core.Collection import get_principal_axis 2489 # engine setup\n''' 2490 rundata += 'LOGGER.set_log_file_basename(%s)\n'%pName 2491 rundata += 'engineFileName = "%s.rmc"\n'%pName 2492 rundata += 'ENGINE = Engine(path=None)\n' 2493 rundata += 'if not ENGINE.is_engine(engineFileName):\n' 2494 # create engine 2495 rundata += ' ENGINE = Engine(path=engineFileName)\n' 2496 rundata += ' ENGINE.set_pdb(%s)\n'%RMCPdict['atomPDB'] 2497 ## create experimental constraints 2498 for File in Files: 2499 filDat = RMCPdict['files'][File] 2500 if filDat[0] != 'Select': 2501 sfwt = 'neutrons' 2502 if 'Xray' in File: 2503 sfwt = 'xrays' 2504 if 'G(r)' in File: 2505 rundata += ' GofR = PairDistributionConstraint(experimentalData=%s, weighting="%s"\n'%(filDat[0],sfwt) 2506 rundata += ' GofR.set_variance_squared(%f)\n'%filDat[1] 2507 rundata += ' ENGINE.add_constraints([GofR])\n' 2508 else: 2509 rundata += ' FofQ = StructureFactorConstraint(experimentalData=%s, weighting="%s"\n'%(filDat[0],sfwt) 2510 rundata += ' FofQ.set_variance_squared(%f)\n'%filDat[1] 2511 rundata += ' ENGINE.add_constraints([FofQ])\n' 2512 rundata += ' ENGINE.save()\n' 2513 2514 2515 2516 rundata += 'else:\n' 2517 rundata += ' ENGINE = ENGINE.load(path=engineFileName)\n' 2518 2519 2497 2520 rfile = open(rname,'w') 2498 2521 rfile.writelines(rundata) 2499 2522 rfile.close() 2523 2524 return rname 2500 2525 2501 2526 … … 2515 2540 Cell = newPhase['General']['Cell'][1:7] 2516 2541 A,B = G2lat. cell2AB(Cell) 2517 fname = Name+' .pdb'2542 fname = Name+'_cbb.pdb' 2518 2543 fl = open(fname,'w') 2519 2544 fl.write('REMARK this file is generated using GSASII\n') … … 2529 2554 Natm = np.count_nonzero(Natm-1) 2530 2555 nat = 0 2531 for atm in Atseq: 2556 if RMCPdict['byMolec']: 2557 NPM = RMCPdict['Natoms'] 2532 2558 for iat,atom in enumerate(Atoms): 2533 if atom[1] == atm: 2534 nat += 1 2535 XYZ = np.inner(A,np.array(atom[3:6])-XYZptp) #shift origin to middle & make Cartesian 2536 fl.write('ATOM %5d %-4s RMC%6d%12.3f%8.3f%8.3f 1.00 0.00 %-2s\n'%( 2537 nat,atom[0],nat,XYZ[0],XYZ[1],XYZ[2],atom[1].lower())) 2559 XYZ = np.inner(A,np.array(atom[3:6])-XYZptp) #shift origin to middle & make Cartesian 2560 fl.write('ATOM %5d %-4s RMC%6d%12.3f%8.3f%8.3f 1.00 0.00 %-2s\n'%( 2561 1+nat%NPM,atom[0],1+nat//NPM,XYZ[0],XYZ[1],XYZ[2],atom[1].lower())) 2562 nat += 1 2563 else: 2564 for atm in Atseq: 2565 for iat,atom in enumerate(Atoms): 2566 if atom[1] == atm: 2567 XYZ = np.inner(A,np.array(atom[3:6])-XYZptp) #shift origin to middle & make Cartesian 2568 fl.write('ATOM %5d %-4s RMC%6d%12.3f%8.3f%8.3f 1.00 0.00 %-2s\n'%( 2569 1+nat,atom[0],1+nat,XYZ[0],XYZ[1],XYZ[2],atom[1].lower())) 2570 nat += 1 2538 2571 fl.close() 2539 2572 return fname … … 2542 2575 fname = 'make_pdb.py' 2543 2576 outName = RMCPdict['moleculePdb'].split('.') 2544 outName[0] += ' bb'2577 outName[0] += '_rbb' 2545 2578 outName = '.'.join(outName) 2579 RMCPdict['atomPDB'] = outName #might be empty if pdbparser run fails 2546 2580 fl = open(fname,'w') 2547 2581 fl.write('from pdbparser.pdbparser import pdbparser\n')
Note: See TracChangeset
for help on using the changeset viewer.