Author Topic: opI[].A.opI[] product with SpinDynamica 2.9.1 (and 2.8.3)  (Read 3001 times)

JyrkiRantaharju

  • Member
  • *
  • Posts: 36
    • View Profile
opI[].A.opI[] product with SpinDynamica 2.9.1 (and 2.8.3)
« on: April 21, 2014, 02:05:48 PM »
Dear all,

It seems that opI[].A.opI[]  product, where A is a matrix, can only be evaluated with SpinDynamica 2.9.1 (and 2.8.3) if A is diagonal. I attached example notebook to demonstrate this.

Also, SpinDynamica 2.9.1 seems to require that paths of both the SpinDynamica and spindynamica folders are added  to the $Path symbol, before evaluating Needs["SpinDynamica`"].

Best regards,
Jyrki.
« Last Edit: April 21, 2014, 03:16:48 PM by Jyrki Rantaharju »

JyrkiRantaharju

  • Member
  • *
  • Posts: 36
    • View Profile
Re: opI[].A.opI[] product with SpinDynamica 2.9.1 (and 2.8.3)
« Reply #1 on: April 21, 2014, 08:38:47 PM »
The "bug" that causes the problem with opI[].A.opI[] product seems to exist also in SpinDynamica 2.8.2, but not in SpinDynamica 2.8.1.

« Last Edit: April 21, 2014, 08:41:38 PM by Jyrki Rantaharju »

JyrkiRantaharju

  • Member
  • *
  • Posts: 36
    • View Profile
Re: opI[].A.opI[] product with SpinDynamica 2.9.1 (and 2.8.3)
« Reply #2 on: April 26, 2014, 07:52:51 PM »
It seems that Times[opI[__],opI[__]] was iterpret as  Dot[opI[__],opI[__]] up to SpinDynamica version 2.8.1, which allowed the correct evaluation of opI[].A.opI[] products. I found the below code from SpinOperators notebook of SpinDynamica 2.8.1.
Code: [Select]
opI /: HoldPattern@Times[n3___?NumericQ, op2 : opI[___], n2___?NumericQ,  op1_?OperatorQ, n1___?NumericQ] := Times[n3, n2, n1, op2.op1];In newer versions of SpinDynamica the above code seems to be replaced by code
Code: [Select]
opI /: HoldPattern[Times[a___, _opI, b___]] /;Or @@ (OperatorQ /@ {a, b}) := (Message[Operator::times]; $Failed);which makes Times[opI[__],opI[__]] to have value $Failed.

JyrkiRantaharju

  • Member
  • *
  • Posts: 36
    • View Profile
Re: opI[].A.opI[] product with SpinDynamica 2.9.1 (and 2.8.3)
« Reply #3 on: April 26, 2014, 08:56:23 PM »
I found the code below from SpinOperators notebook of SpinDynamica 2.9.1.
Code: [Select]
Unprotect[Dot];
HoldPattern@Dot[opIj : {_opI ..}, opIk : {_opI ..}] := Inner[Dot, opIj, opIk, Plus];
Protect[Dot];
generalizing it to the code below
Code: [Select]
Unprotect[Dot];
HoldPattern@Dot[opj : {_?OperatorQ ..}, opk : {_?OperatorQ ..}] := Inner[Dot, opj, opk, Plus];
Protect[Dot];
would fix the problem.

I noticed that opI[].opI[] products evaluates normally even without the above kind of codes included in the section AngularMomentumOperator opI/ Angular momentum vector operator and dot products of SpinOperators notebook.
« Last Edit: April 26, 2014, 09:17:14 PM by Jyrki Rantaharju »

MalcolmHLevitt

  • Administrator
  • Member
  • *****
  • Posts: 103
    • View Profile
Re: opI[].A.opI[] product with SpinDynamica 2.9.1 (and 2.8.3)
« Reply #4 on: August 11, 2014, 04:31:09 PM »
Hello Jyrki. This bug has been fixed in v2.10.1.
all the best
Malcolm

JyrkiRantaharju

  • Member
  • *
  • Posts: 36
    • View Profile
Re: opI[].A.opI[] product with SpinDynamica 2.9.1 (and 2.8.3)
« Reply #5 on: August 22, 2014, 03:12:18 PM »
Hello Malcolm,

thanks for fixing the bug. Evaluation of syntax opI[].A.opI[] seems to work now without any errors, but evaluation of syntax Dot[opI[],Dot[A,opI[]]] still fails.
This is not a problem for me, I just thought that I should let you know.


Best, Jyrki.

MalcolmHLevitt

  • Administrator
  • Member
  • *****
  • Posts: 103
    • View Profile
Re: opI[].A.opI[] product with SpinDynamica 2.9.1 (and 2.8.3)
« Reply #6 on: September 24, 2014, 10:19:22 PM »
Hi Jyrki, this has been fixed (amongst other things) in SDv2.10.2.