source: project/ode/trunk/examples/stranslate.scm @ 8365

Last change on this file since 8365 was 8365, checked in by Ivan Raikov, 13 years ago

Added stalin-related extension.

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#!/bin/sh
2#|  -*- Hen -*-
3exec sh -c "csi -s \"$0\" $1 $2 $3 $4 $5 "
4|#
5
6;;
7;; Evaluation of this file yields a translation of the given model to
8;; Stalin Scheme.
9;;
10
11(require-extension args)
12(require-extension ode-macros)
13(require-extension ode-stalin)
14
15(define (logname x)  (string-append (symbol->string x) ".log"))
16(define (dataname x) (string-append (symbol->string x) ".data"))
17
18(define opt_solver 'rkf45)
19(define opt_slen   100.0)
20(define opt_ih     1e-3)
21
22(define args (command-line-arguments))
23
24   
25;; Use args:usage to generate a formatted list of options (from OPTS),
26;; suitable for embedding into help text.
27(define (usage)
28  (print "Usage: stranslate.scm [options...] operands ")
29  (newline)
30  (print "The following options are recognized: ")
31  (newline)
32  (print (parameterize ((args:indent 5)) (args:usage opts)))
33  (exit 1))
34
35
36(define opts
37  `(,(args:make-option (solver)     (required: "SOLVER")   
38                       (string-append "specify solver (euler, rkf45, abm4) (default: " (symbol->string opt_solver) ")")
39                       (set! opt_solver (string->symbol arg)))
40    ,(args:make-option (slen)       (required: "LENGTH")   
41                       (string-append "specify simulation length in ms (default: " (number->string opt_slen) ")")
42                       (set! opt_slen (string->number arg)))
43    ,(args:make-option (initial-h)    (required: "TIMESTEP")   
44                       (string-append "specify initial time step (default: " (number->string opt_ih) ")")
45                       (set! opt_ih (string->number arg)))
46    ,(args:make-option (h help)  #:none               "Print help"
47                       (usage))))
48
49
50(set!-values (options operands)  (args:parse args opts))
51
52(define (stranslate operand solver slen initial-h)
53  (let ((fname (string-append operand ".scm"))
54        (solverfn (string->symbol (string-append "make-ode:" (->string solver)))))
55    (load fname)
56    (let* ((system-name   (eval 'system-name))
57           (system        (eval system-name)))
58      (ode:stalin-translator system solverfn 0.0 slen initial-h ))))
59
60(for-each (lambda (x) (stranslate x opt_solver opt_slen opt_ih)) operands)
Note: See TracBrowser for help on using the repository browser.