From 491789c0fec6dc1226fd408a69b9ba79838331c7 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Fri, 21 Mar 2014 18:17:13 -0400 Subject: [PATCH] Remove obsolete examples for a tagged release. Will be reworked later. --- examples/demoCartesianCoordinates.py | 68 ----------------- examples/expandAndConstrain.py | 106 --------------------------- 2 files changed, 174 deletions(-) delete mode 100755 examples/demoCartesianCoordinates.py delete mode 100755 examples/expandAndConstrain.py diff --git a/examples/demoCartesianCoordinates.py b/examples/demoCartesianCoordinates.py deleted file mode 100755 index bdc6275c..00000000 --- a/examples/demoCartesianCoordinates.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python - -"""Demonstrate ways of building structure from Cartesian Coordinates. -""" - -from diffpy.Structure import Structure -from diffpy.Structure import Lattice -from diffpy.Structure import Atom - - -def listCoordinates(stru): - """List fractional and Cartesian coordinates in a structure. - - stru -- instande of diffpy.Structure - - No return value. - """ - for a in stru: - print "%-2s xyz=(%.4f, %.4f, %.4f) xyz_cartn=(%.4f, %.4f, %.4f)" % ( - (a.element, ) + tuple(a.xyz) + tuple(a.xyz_cartn)) - return - - -# Structure instance has lattice attribute which describes coordinate -# system for fractional coordinates. It defaults to Cartesian system. - -stru1 = Structure(atoms=[ - Atom('C', [0, 0, 0]), - Atom('C', [1, 1, 1]), - Atom('C', [1, 2, 3]), - Atom('C', [3, 2, 1]), - ]) - -print "stru1 uses the default coordinate system" -print "stru1.lattice.abcABG()=" + str(stru1.lattice.abcABG()) -listCoordinates(stru1) -print - -# The placeInLattice method sets a new coordinate system while preserving -# the same Cartesian positions of all atoms. -stru2 = Structure(stru1) -lattice2 = Lattice(5, 6, 7, 60, 70, 80) -stru2.placeInLattice(lattice2) - -print "stru2 is a copy of stru1 placed in differenc lattice" -print "stru2.lattice.abcABG()=" + str(stru2.lattice.abcABG()) -listCoordinates(stru2) -print - -# Finally to place atom at a given Cartesian position, one can -# set its xyz_cartn attribute. - -lattice3 = Lattice(6, 8, 9, 90, 90, 90) -stru3 = Structure(lattice=lattice3) -# add 4 carbon atoms -stru3.addNewAtom("C") -stru3.getLastAtom().xyz_cartn = (0, 0, 0) -stru3.addNewAtom("C") -stru3[-1].xyz_cartn = (1, 1, 1) -stru3.addNewAtom("C") -stru3.getLastAtom().xyz_cartn = (1, 2, 3) -stru3.addNewAtom("C") -stru3.getLastAtom().xyz_cartn = (3, 2, 1) - -print "stru3 atom coordinates were defined using xyz_cartn" -print "stru3.lattice.abcABG()=" + str(stru3.lattice.abcABG()) -listCoordinates(stru3) -print diff --git a/examples/expandAndConstrain.py b/examples/expandAndConstrain.py deleted file mode 100755 index 05c105e6..00000000 --- a/examples/expandAndConstrain.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python - -'''Demonstration of SymmetryUtilities to expand a position -and generate symmetry constraints for the fractional coordinates. -The equations can be also printed as pdffit2 constraint commands. -''' - -import sys -import os.path -import re -import numpy - -from diffpy.Structure.SymmetryUtilities import * -from diffpy.Structure.SpaceGroups import GetSpaceGroup - -# Get and process coordinates -print "Enter xyz coordinates (can be fractions): " -reply = raw_input('> ') -# split reply on commas or whitespace -words = re.split('[,\s]+', reply.strip()) -# prepend "1.0*" to avoid integer division -xyz = [ eval("1.0*" + e) for e in words[:3] ] - -# Get space group for expansion -print "Enter space group (symbol or number): " -reply = raw_input('> ') -sg_expansion = GetSpaceGroup(reply) -# get optional offset -sg_expoffset = [0.0, 0.0, 0.0] -print "Space group origin offset ( if none): " -reply = raw_input('> ').strip() -if reply: - # split reply on commas or whitespace - words = re.split('[,\s]+', reply) - # prepend "1.0*" to avoid integer division - sg_expoffset = [ eval("1.0*" + e) for e in words[:3] ] - -# Expand coordinate -xyz_expanded, ignore, mltp = expandPosition(sg_expansion, xyz, sg_expoffset) -print -print "Site multiplicity:", mltp -print "Expanded positions:" -for eqxyz in xyz_expanded: - print " ", str(eqxyz) -print - -# Get space group for generating constraints -print "Enter constraining space group: " -reply = raw_input('> ') -sg_constrainment = GetSpaceGroup(reply) -# get optional offset -sg_consoffset = [0.0, 0.0, 0.0] -print "Space group origin offset ( if none): " -reply = raw_input('> ').strip() -if reply: - # split reply on commas or whitespace - words = re.split('[,\s]+', reply) - # prepend "1.0*" to avoid integer division - sg_consoffset = [ eval("1.0*" + e) for e in words[:3] ] - -# Generate constraint equations -print repr(sg_consoffset) -symcon = SymmetryConstraints(sg_constrainment, xyz_expanded, - sgoffset=sg_consoffset) -print -print "Position formulas:" -for eq in symcon.positionFormulas(): - print " (%r, %r, %r)" % (eq["x"], eq["y"], eq["z"]) -print "Parameters:" -for symbol, value in symcon.pospars: - print " ", symbol, value - -# PDFFIT2 macros -print -print "Display as PDFFIT macros? (y/n)" -reply = raw_input('> ') -if reply[:1].lower() != "y": - sys.exit() - -# generate symbol for every possible coordinate -numcoordinates = len(symcon.pospars) -firstpar = 11 -parsymbols = ["@%i" % (i + firstpar) for i in range(numcoordinates)] - -# create constraints using these symbols -eqns = symcon.positionFormulasPruned(parsymbols) - -# print constrain commands -hashline = 78 * '#' -print hashline - -for siteindex, eq in enumerate(eqns): - sortedkeys = sorted(eq.keys()) - for smbl in sortedkeys: - print "constrain(%s(%i), %r)" % (smbl, siteindex, eq[smbl]) - -# print setpar commands -for symbol, value in zip(parsymbols, symcon.posparValues()): - print "setpar(%s, %s)" % (symbol.lstrip('@'), value) - -if not symcon.pospars: - print "# special fixed positions, no constraints" - -print hashline - -# End of file