expression in variables

27 views
Skip to first unread message

Paul

unread,
Dec 12, 2013, 8:45:02 AM12/12/13
to spinev-...@googlegroups.com
Can we use expression in variables
such as

N=2
p=N*2
pulse_2_1_[1:p]=10

I want to vary the parameter N as scan parameter

Thanks
Paul

Rongchun Zhang

unread,
Dec 12, 2013, 8:51:09 AM12/12/13
to spinev-...@googlegroups.com
No. You have to use scan_par
Refer to the manual


--
You received this message because you are subscribed to the Google Groups "spinev-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spinev-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Best regards,
Rongchun

**************************************************
张荣纯 Rongchun Zhang
Room 4002, Chemistry Building, 
Biophysics and Department of Chemistry,
University of Michigan, Ann Arbor, MI, US.
Mobile: (01)734-353-9636
Email: zrc...@gmail.com
           rozh...@umich.edu
**************************************************

Mikhail Veshtort

unread,
Dec 12, 2013, 9:12:07 AM12/12/13
to spinev-...@googlegroups.com
Hi Paul,

You can certainly do something to that end, but not in the way you see it.
You should understand that things like pulse_2_1_[1:3]=10 are actually a shorthand for
pulse_2_1_1=10
pulse_2_1_2=10
pulse_2_1_3=10
So, hoping to vary p in your example would mean that you want to compute different expressions for each value of the scan parameter. This is, of course, impossible.

However, if for each value of p you simply want to assign different values to components of some vector, this can be easily done using expressions like ["1:p"]. So, for example,
pulse_2_1(["1:p"]')=10 is a perfectly legal expression. See the Matrices section in the Manual (page 9).

Mikhail


Message has been deleted

Paul

unread,
Dec 12, 2013, 9:17:44 AM12/12/13
to spinev-...@googlegroups.com
Thanks for your reply but my pulse program is such that I cannot use scan parameters
I have 80 pulses for which I want to set 4 pulses to be of 5 us and the rest to be zero
In the next I want to change the value of 14 pulses to be 5 us while the rest to be zero

So I have created a matrix of zeros in the pulse.pp file and want to change the pulse lengths systematically

May be I am not clear but it is hard to explain here I guess

Thanks for the reply once again
Paul

Paul

unread,
Dec 12, 2013, 9:27:27 AM12/12/13
to spinev-...@googlegroups.com
I did something like this
p=["1:N"]
pulse_2_1_p=5

and it gave me illegal expression error. I will try out your way

Thanks for the reply. Will update in a minute
Paul

Paul

unread,
Dec 12, 2013, 9:31:37 AM12/12/13
to spinev-...@googlegroups.com
Hi Mikhail,

Nope it gives me the error
Error: vectorized expression format: in line
[1:p]

Here is my script

****** The System *******
spectrometer(MHz)  700
spinning_freq(kHz) 10
channels           C13  H1
nuclei             C13  H1  H1  H1 
atomic_coords      ch2h.cor
cs_isotropic       0.0 -0.3 0.5 0.5 
csa_parameters     ch2h2.csa
j_coupling         *
quadrupole         *
dip_switchboard    ch2h.dip
csa_switchboard    *
exchange_nuclei    *
bond_len_nuclei    *
bond_ang_nuclei    *
tors_ang_nuclei    *
groups_nuclei      *
******* Pulse Sequence ******************************
CHN 1
timing(usec)      (0)256x200
power(kHz)         0
phase(deg)         0
freq_offs(kHz)     0
CHN 2         
timing(usec)      (../spinev_input/tppmpitppm.pp)
power(kHz)         *
phase(deg)         *
freq_offs(kHz)     *
****** Variables ************************************
N=1
p=N*2
***q=["42:41+p"]
***r=["1:2:p-1"]
***s=["2:2:p"]
pulse_2_1(["1:p"]')=5
pulse_2_1_[42:43]=5
power_2_1_[1:81]=100
phase_2_1_[1:41:42]=15
phase_2_1_[2:41:43]=-15
pulse_1_1_1=N*4*5+5
******* Options **************************************
rho0               I1x
observables        F1p
EulerAngles        rep168
n_gamma            16
line_broaden(Hz)   6
zerofill           *
FFT_dimensions     1
options            -v2 -re


On Thursday, December 12, 2013 7:42:07 PM UTC+5:30, Mikhail Veshtort wrote:
Message has been deleted

Mikhail Veshtort

unread,
Dec 12, 2013, 9:51:19 AM12/12/13
to spinev-...@googlegroups.com
Right... I think that you just need to put ["..."] in parentheses for the matrix transpose to work: pulse_2_1((["1:p"])').

You should try to debug this kind issues yourself, actually. The easiest way here would be to run "spinev -calc" and experiment with various expressions to see what exactly gives an error. Or you could do this within the input file.

Mikhail

Paul

unread,
Dec 12, 2013, 1:02:21 PM12/12/13
to spinev-...@googlegroups.com
Well I have tried all sorts of permutations and combinations with the -calc option and input file. Even if the calc option gives things as you expect, running the scripts gives an error.
Before posting this query I have tried a lot and I have been using spinevolution for a long time and have not faced something like this.

May be I am wrong but it was quite baffling to me.
and the option pulse_2_1((["1:p"])') does not work, though the expression is quite valid in spinev -calc

Thanks and regards
Paul

Mikhail Veshtort

unread,
Dec 13, 2013, 3:05:26 AM12/13/13
to spinev-...@googlegroups.com
Hi Paul,

It turns out that for some reason the program does not accept expressions like A(["1:p"]). I don't have time now to figure out why exactly this happens, but this can be easily circumvented by using an intermediate variable. In your specific case, you can do
X=(["1:p"])'
pulse_2_1(X)=5

Best regards,
Mikhail
Reply all
Reply to author
Forward
0 new messages