Changeset 25511 in project


Ignore:
Timestamp:
11/16/11 15:28:28 (10 years ago)
Author:
Ivan Raikov
Message:

signal-diagram and flsim: additions to lsode integration

Location:
release/4
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • release/4/flsim/trunk/flsim.scm

    r25237 r25511  
    470470
    471471 
    472 (define (prelude/Octave #!key (solver 'rk4b))
     472(define (prelude/Octave #!key (solver 'lsode))
    473473`(
    474474#<<EOF
     
    556556)
    557557       ("global " ,solver #\; ,nl)
    558        (,solver = #\@ ,(case solver ((rk3) 'ode23) ((rk4b rk4a) 'ode45) ((rkf45) 'ode54) (else 'lsode)) #\; ,nl)
    559 
    560        ,(if (member solver '(rk3 rk4b rk4a rkf45))
    561 `(
     558       (,solver = #\@ ,(case solver
     559                         ((rk3) 'ode23) ((rk4b rk4a) 'ode45) ((rkf45) 'ode54)
     560                         (else 'lsode)) #\; ,nl)
     561
     562       ,(cond
     563
     564         ((member solver '(rk3 rk4b rk4a rkf45))
     565
     566               `(
    562567#<<EOF
    563568global reltol abstol dt;
     
    574579       "  [t,y] = " ,solver "(f,[x,x+h],y,P); " ,nl
    575580       "  res = y(2);" ,nl end ,nl
    576 )
    577 
    578 `(
     581       ))
     582              (else
     583
     584               `(
    579585#<<EOF
    580586lsode_options("relative tolerance",1e-1);
    581587lsode_options("absolute tolerance",1e-2);
    582 lsode_options("initial step size",1e-3);
     588
    583589
    584590EOF
    585        "function res = integrate1d (f,x,y,h)" ,nl
     591       "function res = integrate1d (f,x,y0,h)" ,nl
    586592       "  global " ,solver ";" ,nl
    587        "  y = " ,solver "(@(t,yvec)(f(yvec,t)),y,[x,x+h]); " ,nl
     593       "  y = " ,solver "(@(yvec,t) f(t,yvec),y0,[x,x+h]); " ,nl
    588594       "  res = y(2);" ,nl end ,nl
    589 )
    590    )
     595       )
     596   ))
    591597 ))
    592598))
    593599
    594 
    595600         
    596601
  • release/4/flsim/trunk/flsim.setup

    r25235 r25511  
    44  (make-pathname #f fn ##sys#load-dynamic-extension))   
    55
    6 (define version 2.0)
     6(define version 2.1)
    77
    88(make (
     
    7777(copy-file-to-flsim-dir "sml-lib/rk/rk.mlb")
    7878
     79(copy-file-to-flsim-dir "octave-lib/ode15s.m")
    7980
     81
     82
  • release/4/signal-diagram/trunk/examples/Izhikevich03.scm

    r25492 r25511  
    172172                 (name  (car name.model))
    173173                 (model (cdr name.model)))
    174             (codegen name model language: 'octave pre: pre solver: #f)
     174            (codegen name model language: 'octave pre: pre solver: 'lsode)
    175175            (recur (cdr models) #f)
    176176            )))
  • release/4/signal-diagram/trunk/signal-diagram.scm

    r25510 r25511  
    11821182(define (codegen/Octave name f #!key (initial #f) (pre #t) (solver #f))
    11831183
    1184   (if (and solver (not (member solver '(rkfe rk3 rk4a rk4b rkhe rkbs rkf45))))
     1184  (if (and solver (not (member solver '(lsode rkfe rk3 rk4a rk4b rkhe rkbs rkf45))))
    11851185      (error 'codegen/Octave "unknown solver" solver))
    11861186 
     
    12611261(define (codegen/scheme name f #!key (initial #f) (pre #t) (solver 'rk4b))
    12621262
    1263   (if (and solver (not (member solver '(rkfe rk3 rk4a rk4b rkhe rkbs rkf45 ode15s))))
     1263  (if (and solver (not (member solver '(lsode rkfe rk3 rk4a rk4b rkhe rkbs rkf45))))
    12641264      (error 'codegen/scheme "unknown solver" solver))
    12651265
Note: See TracChangeset for help on using the changeset viewer.