Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## jmol-users

 [Jmol-users] Convert cartesian to fractional From: Aidan Heerdegen - 2007-05-24 05:22:28 ```Bob, I can convert fractional coords to cartesian with a simple a = {1/1 0 0} is there (or could there be) a simple way to do the same in reverse? I wish to obtain the fractional coordinates of my molecule (which I currently do like so {molecule=1}.xyz). Can I get the same information but in fractional coordinates? I am trying to do something similar to Alan Hewat, i.e. only show atoms defined by fractional unit cell extents, e.g -1.2 < h < 1.8, -0.8 < k < 0.8, -0.2 < l < 1.4. I can achieve something akin to this with a series of select within statements, but I really want to include/exclude whole molecules based on the location of their centre. Thanks Aidan ```
 Re: [Jmol-users] Convert cartesian to fractional From: Bob Hanson - 2007-05-24 13:10:43 ```Aidan Heerdegen wrote: >Bob, > >I can convert fractional coords to cartesian with a simple > >a = {1/1 0 0} > >is there (or could there be) a simple way to do the same in reverse? >I wish to obtain the fractional coordinates of my molecule (which I >currently do like so {molecule=1}.xyz). Can I get the same >information but in fractional coordinates? > > > First, "get the same information but in fractional coordinates." Yes: x = {molecule=1}.label("%X %Y %Z") Now, that gets you a STRING that looks like this: ... 0.46969998 1.0 1.0 0.14659995 0.73309994 0.8809 1.4697001 0.0 0.0 1.4135001 0.2669 0.11910001 1.2669002 0.4135 0.54756665 .... From which you could extract the information. >I am trying to do something similar to Alan Hewat, i.e. only show >atoms defined by fractional unit cell extents, e.g -1.2 < h < 1.8, >-0.8 < k < 0.8, -0.2 < l < 1.4. I can achieve something akin to this >with a series of select within statements, > right; we could make that easier, but I agree, you can do that already. >but I really want to >include/exclude whole molecules based on the location of their centre. > > > Ah, this is another question entirely. If you want say, "display only molecules for which the center is within the following space...," that's not trivial. Let's see.... You can find the center with: centerm = {molecule=1}.xyz Or the individual coordinates: centerx = {molecule=1}.x centery = {molecule=1}.y centerz = {molecule=1}.z And although you cannot express that in fractional coordinates, you can certainly express some fractional coordinate in cartesians: coordxyz = {1/2 1/2 1/2} coordx = 0.0 + {1/2 0 0} coordy = 0.0 + {0 1/2 0} coordz = 0.0 + {0 0 1/2} But, no, I guess you cannot do that. Seems to me your best bet is something like this: set scriptReportingLevel -1 # hmm, undocumented.... nMolecules = {*}.molecule.max; n = 1; select none; message _loop; mx = {molecule=n}.x my = {molecule=n}.y mz = {molecule=n}.z if (mx < 30 ... etc.); select selected or molecule=n # prior to 11.1.43, use "select n_set" endif; n = n + 1; if (n <= nMolecules); goto _loop; endif; set scriptReportingLevel 0 Sorry if that looks complicated, but selecting atoms based on criteria that are not strictly atomic is rather tricky. Bob >Thanks > >Aidan > > >------------------------------------------------------------------------- >This SF.net email is sponsored by DB2 Express >Download DB2 Express C - the FREE version of DB2 express and take >control of your XML. No limits. Just data. Click to get it now. >http://sourceforge.net/powerbar/db2/ >_______________________________________________ >Jmol-users mailing list >Jmol-users@... >https://lists.sourceforge.net/lists/listinfo/jmol-users > > ```
 Re: [Jmol-users] Convert cartesian to fractional From: Aidan Heerdegen - 2007-06-28 05:16:21 ```This is a followup so that others who search this list can find this information. On 24/05/2007, at 11:10 PM, Bob Hanson wrote: > Aidan Heerdegen wrote: >> I wish to obtain the fractional coordinates of my molecule (which I >> currently do like so {molecule=1}.xyz). Can I get the same >> information but in fractional coordinates? > First, "get the same information but in fractional coordinates." Yes: > > x = {molecule=1}.label("%X %Y %Z") > > Now, that gets you a STRING that looks like this: > > ... > 0.46969998 1.0 1.0 > 0.14659995 0.73309994 0.8809 > 1.4697001 0.0 0.0 > 1.4135001 0.2669 0.11910001 > 1.2669002 0.4135 0.54756665 > .... > > From which you could extract the information. Works like a charm. Thanks Bob. I am using javascript to make an "application" of sorts, so I suck that information out and use javascript to get the average fractional position. I noticed 11.2.1 now has a 'FX', 'FY' and 'FZ' comparison operators so now most of this is redundant. I can now do: fracx = {molecule=1}.FX to get the average fractional x position of molecule 1. Nice! For completeness you might want to be able to do this: fracxyz = {molecule=1}.FXYZ (but personally I don't need it) >> but I really want to >> include/exclude whole molecules based on the location of their >> centre. > > Ah, this is another question entirely. If you want say, "display only > molecules for which the center is within the following space...," > that's > not trivial. Well I now do it by assigning to each atom three properties, the fractional x, y and z positions of the molecule to which they belong. Then I can do things like: display property_comfracx >= -1.5 AND property_comfracx <= 2 AND property_comfracy >= -1.2 AND property_comfracy <= 2.2 AND property_comfracz >= -0.1 AND property_comfracz <= 1.1 where (obviously) property_comfracx, property_comfracy and property_comfracz are the three components of the molecule centroid in fractional coordinates. I use properties for other things too. I have my own unitcell definitions so that I can select whole molecules based on the unitcell in which their centroid lies. That sort of thing. This is a very nice feature, thanks Bob. ```