2

存在一个称为 meep 的电磁模拟器,它以狡猾的解释器形式提供前端。模拟器由一堆方案宏组成。

我试图弄清楚以下错误的含义。代码取自教程。当我将教程包装在一个过程中时,我得到一个运行时错误,我不确定解释器(诡计)告诉我什么。

不工作的代码

(define diffthick
  (lambda (n) ; n doesn nothing
    (
     (set! geometry-lattice (make lattice (size 16 8 no-size)))
     (set! geometry (list
                      (make block (center 0 0) (size infinity 1 infinity)
                            (material (make dielectric (epsilon 12))))))
     (set! sources (list
                     (make source
                           (src (make continuous-src (frequency 0.15)))
                           (component Ez)
                           (center -7 0))))
     (set! pml-layers (list (make pml (thickness 1.0))))
     (set! resolution 10)
     (run-until 200
                (at-beginning output-epsilon)
                (at-end output-efield-z))
     )
    )
  )
(diffthick 3)

工作代码(无程序)

(set! geometry-lattice (make lattice (size 16 8 no-size)))
(set! geometry (list
                (make block (center 0 0) (size infinity 1 infinity)
                      (material (make dielectric (epsilon 12))))))
(set! sources (list
               (make source
                 (src (make continuous-src (frequency 0.15)))
                 (component Ez)
                 (center -7 0))))

(set! pml-layers (list (make pml (thickness 1.0))))
(set! resolution 10)
(run-until 200
           (at-beginning output-epsilon)
           (at-end output-efield-z))

错误

creating output file "./eps-000000.00.h5"...
creating output file "./ez-000200.00.h5"...
run 0 finished at t = 200.0 (4000 timesteps)

Backtrace:
In standard input:
  21: 0* [diffthick 3]
   3: 1  [#<unspecified> #<unspecified> #<unspecified> ...]

standard input:3:5: In expression ((set! geometry-lattice #) (set! geometry #) (set! sources #) ...):
standard input:3:5: Wrong type to apply: #<unspecified>
ABORT: (misc-error)

在职的

-----------
creating output file "./eps-000000.00.h5"...
creating output file "./ez-000200.00.h5"...
run 0 finished at t = 200.0 (4000 timesteps)

在一天结束的时候,我觉得某事被评估了两次。但我不确定那是什么东西。

4

1 回答 1

5

该错误表示代码正在尝试应用结果,(set! geometry-lattice #)就好像它是一个函数一样,但set!结果却#<unspecified>相反。发生这种情况是因为set!s 系列被包裹在括号中。

您可能正在寻找

(begin
  (set! geometry-lattice ...)
  ...
  (run-until ...))

或者干脆去掉那对额外的括号,因为 lambda 主体隐含地包裹在begin.

于 2013-01-08T23:00:33.610 回答