time-varying.scm 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #| -*-Scheme-*-
  2. Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
  3. 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
  4. 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Massachusetts
  5. Institute of Technology
  6. This file is part of MIT/GNU Scheme.
  7. MIT/GNU Scheme is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11. MIT/GNU Scheme is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with MIT/GNU Scheme; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
  18. USA.
  19. |#
  20. ;;; This is used in conjunction with a symplectic test for the C to
  21. ;;; establish that a time-dependent transformation is canonical.
  22. ;;; To compute the K (addition to the Hamiltonian) from a
  23. ;;; time-dependent coordinate transformation F.
  24. ;;; FBE: this is already defined in point-transformation.scm in an equivalent way.
  25. ;; (define* ((F->K F) s)
  26. ;; (* -1 (((partial 0) F) s) (momentum ((F->CT F) s))))
  27. ;;; Tests that K yields a canonical transformation if the C is
  28. ;;; symplectic. (The qp-canonical? code is really a symplectic
  29. ;;; test without factoring out the Hamiltonian.)
  30. (define* ((qp-canonical? C H) s)
  31. (- (J-func ((D H) (C s)))
  32. (* ((D C) s)
  33. (J-func
  34. ((D (compose H C)) s)))))
  35. #|
  36. (define ((canonical-K? C K) s)
  37. (let ((s* (compatible-shape s)))
  38. (- (T-func s*)
  39. (+ (* ((D C) s) (J-func ((D K) s)))
  40. (((partial 0) C) s)))))
  41. (define ((canonical-K? C K) s)
  42. (let ((DCs ((D C) s))
  43. (s* (compatible-shape s)))
  44. (- (T-func s*)
  45. (* DCs ((Hamiltonian->state-derivative K) s)))))
  46. |#
  47. #|
  48. (define ((rotating n) state)
  49. (let ((t (time state))
  50. (q (coordinate state)))
  51. (let ((x (ref q 0))
  52. (y (ref q 1))
  53. (z (ref q 2)))
  54. (coordinate-tuple (+ (* (cos (* n t)) x) (* (sin (* n t)) y))
  55. (- (* (cos (* n t)) y) (* (sin (* n t)) x))
  56. z))))
  57. (define (C-rotating n) (F->CT (rotating n)))
  58. (define ((K n) s)
  59. (let ((q (coordinate s))
  60. (p (momentum s)))
  61. (let ((x (ref q 0)) (y (ref q 1))
  62. (px (ref p 0)) (py (ref p 1)))
  63. (* n (- (* x py) (* y px))))))
  64. (define a-state
  65. (up 't
  66. (coordinate-tuple 'x 'y 'z)
  67. (momentum-tuple 'p_x 'p_y 'p_z)))
  68. (pe ((canonical-K? (C-rotating 'n) (K 'n)) a-state))
  69. (up 0 (up 0 0 0) (down 0 0 0))
  70. ;;; or getting K directly from F
  71. (pe ((canonical-K? (C-rotating 'n) (F->K (rotating 'n))) a-state))
  72. (up 0 (up 0 0 0) (down 0 0 0))
  73. (pe ((- (F->K (rotating 'n))
  74. (K 'n))
  75. a-state))
  76. 0
  77. ;;; not all K's work
  78. (define ((bad-K n) s)
  79. (- ((K n) s)))
  80. (pe ((canonical-K? (C-rotating 'n) (bad-K 'n)) a-state))
  81. (up
  82. 0
  83. (up (+ (* 2 n x (sin (* n t))) (* -2 n y (cos (* n t))))
  84. (+ (* 2 n x (cos (* n t))) (* 2 n y (sin (* n t))))
  85. 0)
  86. (down (+ (* 2 n p_x (sin (* n t))) (* -2 n p_y (cos (* n t))))
  87. (+ (* 2 n p_x (cos (* n t))) (* 2 n p_y (sin (* n t))))
  88. 0))
  89. |#