I think it's a combination of two problems.

print @targang.add("\t").add(conang)

is not doing what you think. I know, it's tricky. That says, "find the
variable with the name given in the variable targang and array-add it
with.....  That's because the print command has only one argument - a math
expression. So you would just use

print targang.add("\t").add(conang)

BUT, ".add" is also not what you think. It's really for arrays. targang is
just a number. Just use + .....
HOWEVER, in Jmol the type of variable is set by the first variable in the
line, so since you want a string here and targang is an integer, you need:

print "" + targang + "\t" + conang

That forces the expression to be a string.

The idea is that we want to be able to do this:

3 + "5" = 8

but we also want to do this:

"5" + 3 = "53"

So,

a) Generally you won't use @varName in math expressions; just use that
syntax in commands that take a variety of parameters.

b) Don't use .add unless you are creating new columns in arrays.

c) Coerce string in PRINT with "" + ......

And for that matter, watch out for integer math.

$ print 31/5
6
$ print 31/5.0
6.2
$ print 31\5.0
6

Hmm. I see there is an inconsistency there...

$ print 3 + "5.2"
8
$ print 3-"5.2"
-2.1999998
$ print 3*"5.2"
15
$ print 3/"5.2"
0.5769231

I think the - and / there are bugs.


On Sat, Dec 21, 2013 at 5:22 PM, Whitwell, George <[email protected]>wrote:

>  Greetings,
>
>
>
> I've no doubt that there is a simple explanation for each of these items;
> however, I haven't been able to search any out.
>
>
>
> From the following script:
>
>
>
> zap; load SYNC "file:///C:/Compchem/s-pentane/spentane.xyz"
>
> rotdeg = 120
>
> var steps=360/rotdeg
>
> measure {C5}{C3}{C1}{H6}
>
> targang = 0.00
>
> conang = getproperty("measurementinfo[1].value")
>
> for (var i=0;i<@steps;i++) {
>
> targang = targang + rotdeg
>
> newrot = targang - conang
>
> rotate branch {C3} {C1} @newrot @newrot        // this command will fail
> if the last 2 params have different sign
>
> conang = getproperty("measurementinfo[1].value")
>
> print @targang.add("\t").add(conang)
>
> print "before ".add(@targang).add("\t").add(conang)
>
> script inline ("minimize constraint {C5}{C3}{C1}{H6} @targang")
>
> //minimize  (similar, but more verbose results when run)
>
> conang = getproperty("measurementinfo[1].value")
>
> print conang
>
> minimize energy
>
> results = getproperty("modelinfo.model.energy",{*})
>
> }
>
>
>
> I get this output:
>
>
>
> 59.9 °
> NaN120.000015                    -> targang, conang
>
> before 120.0 120.000015       ->"before ", targang, conang
>
> 120.000015
>  Initial MMFF E =     35.017 kJ criterion = 0.004187 max steps = 0
> NaN-119.99998
>
> before 240.0 -119.99998
>
> -119.99998
>  Initial MMFF E =     40.516 kJ criterion = 0.004187 max steps = 0
> NaN-0.0
>
> before 360.0 -0.0
>
> -0.0
>  Initial MMFF E =     20.605 kJ criterion = 0.004187 max steps = 0
>
>
>
> My confusions are:
>
>
>
> Why is targang NaN?  I initialized it as 0.00, can perform math operations
> on it and the rotate command recognizes it as a value.  When I want to
> print it, it apparently is NaN and so needs the start the print sequence
> with a string approach.
>
>
>
> What is the systematic approach to using @ and var?  The @ symbol didn't
> return anything in a documentation search (too fundamental?).  I have seen
> mentions where "you won't need to use @".  I'm afraid my method is strictly
> T&E, "if at first, nature...".  My experience with var is similar.  Jmol
> docs say that it is used to localize an instance of a variable.  My
> empirical observation is more consistent with "if initializing with a math
> operation, var is needed".  I believe in C (C#, at least), it is used to
> allow the compiler to assign type.  Again, by T&E, I use one when Jmol
> gives me red marks, because my script is so short.
>
>
>
> I know that I can get a read-in energy with
> getproperty("modelinfo.model.energy",{*}).  Is it possible to do the same
> from the Jmol MMFF calculation?  Or can I pipe the output from "minimize
> energy" and parse it?
>
>
>
> Thanks for any help,
>
> George
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>


-- 
Robert M. Hanson
Larson-Anderson Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to