The error says the code is trying to apply the result of (set! geometry-lattice #)
as if it's a function, but the set!
results in #<unspecified>
instead. This happens because the series of set!
s are wrapped in parens.
You're probably looking for
(begin
(set! geometry-lattice ...)
...
(run-until ...))
Or just get rid of that extra pair of parens, since lambda bodies are implicitly wrapped in a begin
.