next up previous contents index
Nächste Seite: DCL-Maske Aufwärts: Berechnungsprogramm Vorherige Seite: Berechnungsprogramm   Inhalt   Index


AutoLISP-Programm


;Calculat velocity in function of slope under consideration of wind,
;resistance of rolling and power.
;Written to evaluate rollingresearches in the "Kuhtrift".
;The distribution is strongley welcomed.
;Please report improvements and bugs to the author. 
;Olaf Schultz, May 1995
;EMail: O.Schultz@tu-harburg.d400.de	Voice:0049 040 775143
;Mail: Buxtehuder Stra"se 57, 21073 Hamburg, Germany

;Program needs trift.dcl for the inputmenu

(defun c:trift ()
 (setvar "cmdecho" 0)
 (erzlay "kosys" 7 "continuous") 	(erzlay "hoehe" 3 "continuous")
 (erzlay "geschwindigkeit" 4 "continuous")
 (erzlay "leist_d_v" 1 "continuous")	(erzlay "leist_d_h" 2 "continuous")
 (erzlay "leist_wind" 7 "continuous")	(erzlay "leist_roll" 5 "continuous")
 (erzlay "leist_fahrer" 15 "continuous")
 (setq texthoe 2.0)					;textgroesse f"ur Beschriftung
 (setq lscale 1.5)					;Skalenstrichl"ange

 (if (member m_fahrer '(nil 0)) (setq m_fahrer "70.0"))	;Fahrermasse
 (if (member m_rad '(nil 0)) (setq m_rad "15.0"))	;Fahrradmasse
 (if (member korrekt '(nil 0)) (setq korrekt "1.015"))	;Laufradkorrektur
 (if (member cwa '(nil 0)) (setq cwa "0.3"))		;c_w*A
 (if (member cr_v '(nil 0)) (setq cr_v "0.00467"))	;cr_v
 (if (member cr_h '(nil 0)) (setq cr_h "0.003"))	;cr_h
 (if (= t_c nil) (setq t_c "23.0"))			;Lufttemperatur
 (if (member p_l '(nil 0)) (setq p_l "1.013"))		;Luftdruck
 (if (member l '(nil 0)) (setq l "0.97"))		;l
 (if (member h '(nil 0)) (setq h "0.8"))		;h
 (if (member a '(nil 0)) (setq a "0.3"))		;a
 (if (member dt '(nil 0)) (setq dt "0.2"))		;dt
 (if (member max_p '(nil 0)) (setq max_p "1000.0"))	;maximale Teilleistung (fuer Skalierung)
 (if (= v_wind nil) (setq v_wind "0.0"))		;Windgeschwindigkeit
 (if (= pant nil) (setq pant "0.0"))			;Antriebsleistung
 (if (not (member drw_parwo '("0" "1"))) (setq drw_parwo "1"))	;Vorgabe Teilleistungen mitzeichnen
 (if (not (member mit_profil '("0" "1"))) (setq mit_profil "0")) ;Vorgabe Streckenprofl in Gefaelle
 (if (not (member drw_perm '("0" "1"))) (setq drw_perm "1"))	;Vorgabe grdraw

 (setq dcl_id (load_dialog "trift.dcl"))		;dcl-Maske Laden
 (if (not (new_dialog "Eingabefenster" dcl_id)) (exit))
;Wenn Vorgaben real oder integer, dann nach string
 (if (= (type m_fahrer) 'REAL) (setq m_fahrer (rtos m_fahrer)))
 (if (= (type m_rad) 'REAL) (setq m_rad (rtos m_rad)))
 (if (= (type korrekt) 'REAL) (setq korrekt (rtos korrekt)))
 (if (= (type cwa) 'REAL) (setq cwa (rtos cwa)))
 (if (= (type cr_v) 'REAL) (setq cr_v (rtos cr_v)))
 (if (= (type cr_h) 'REAL) (setq cr_h (rtos cr_h)))
 (if (= (type l) 'REAL) (setq l (rtos l)))
 (if (= (type a) 'REAL) (setq a (rtos a)))
 (if (= (type h) 'REAL) (setq h (rtos h)))
 (if (= (type p_l) 'REAL) (setq p_l (rtos p_l)))
 (if (= (type t_c) 'REAL) (setq t_c (rtos t_c)))
 (if (= (type dt) 'REAL) (setq dt (rtos dt)))
 (if (= (type max_p) 'REAL) (setq max_p (rtos max_p)))
 (if (= (type pant) 'REAL) (setq pant (rtos pant)))
 (if (= (type v_wind) 'REAL) (setq v_wind (rtos v_wind)))

;Dialogmaskeneingaben vorsetzen
 (set_tile "m_fahrer" m_fahrer)	(set_tile "m_rad" m_rad)
 (set_tile "korrekt" korrekt)	(set_tile "cwa" cwa)	(set_tile "cr_v" cr_v)
 (set_tile "cr_h" cr_h)		(set_tile "t_c" t_c)	(set_tile "p_l" p_l)
 (set_tile "l" l)		(set_tile "h" h)	(set_tile "a" a) 
 (set_tile "dt" dt)		(set_tile "drw_parwo" drw_parwo)
 (set_tile "v_wind" v_wind) 	(set_tile "pant" pant)
 (set_tile "max_p" max_p)	(set_tile "mit_profil" mit_profil)
 (set_tile "drw_perm" drw_perm)
 
 (defun check_real (real_number variable) (if (distof real_number 2)
   (progn (rs_error) real_number)
   (progn (set_tile "error" (strcat "Ungueltiger Wert von " (strcase (substr variable 1 9)) ".")) nil)))
 (defun rs_error() (set_tile "error" ""))
 (defun do_m_rad() (check_real (setq m_rad (get_tile "m_rad")) "m_rad"))
 (defun do_m_fahrer() (check_real (setq m_fahrer (get_tile "m_fahrer")) "m_fahrer"))
 (defun do_korrekt() (check_real (setq korrekt (get_tile "korrekt")) "korrekt"))
 (defun do_cwa() (check_real (setq cwa (get_tile "cwa")) "cwa"))
 (defun do_cr_v() (check_real (setq cr_v (get_tile "cr_v")) "cr_v"))
 (defun do_v_wind() (check_real (setq v_wind (get_tile "v_wind")) "v_wind"))
 (defun do_cr_h() (check_real (setq cr_h (get_tile "cr_h")) "cr_h"))
 (defun do_t_c() (check_real (setq t_c (get_tile "t_c")) "t_c"))
 (defun do_p_l() (check_real (setq p_l (get_tile "p_l")) "p_l"))
 (defun do_l() (check_real (setq l (get_tile "l")) "l"))
 (defun do_h() (check_real (setq h (get_tile "h")) "h"))
 (defun do_a() (check_real (setq a (get_tile "a")) "a"))
 (defun do_dt() (check_real (setq dt (get_tile "dt")) "dt"))
 (defun do_pant() (check_real (setq pant (get_tile "pant")) "pant"))
 (defun do_drw_parwo () (rs_error) (setq drw_parwo (get_tile "drw_parwo")))
 (defun do_drw_perm () (rs_error) (setq drw_perm (get_tile "drw_perm")))
 (defun do_mit_profil () (rs_error) (setq mit_profil (get_tile "mit_profil")))
 (defun do_max_p () (rs_error) (setq max_p (get_tile "max_p")))
 
 (action_tile "m_rad" "(do_m_rad)")	(action_tile "m_fahrer" "(do_m_fahrer)")
 (action_tile "korrekt" "(do_korrekt)")	(action_tile "cwa" "(do_cwa)")
 (action_tile "cr_v" "(do_cr_v)")	(action_tile "cr_h" "(do_cr_h)")
 (action_tile "t_c" "(do_t_c)")		(action_tile "p_l" "(do_p_l)")
 (action_tile "v_wind" "(do_v_wind)")	(action_tile "max_p" "(do_max_p)")
 (action_tile "l" "(do_l)")		(action_tile "h" "(do_h)")
 (action_tile "a" "(do_a)")		(action_tile "dt" "(do_dt)")
 (action_tile "drw_parwo" "(do_drw_parwo)") (action_tile "pant" "(do_pant)")
 (action_tile "accecpt" "(done_dialog)") (action_tile "cancel" "(done_dialog 0)")
 (action_tile "drw_perm" "(do_drw_perm)") (action_tile "mit_profil" "(do_mit_profil)")
 (setq quest (start_dialog))
 (if (= quest 0) (setq abbruch 1) (draw_curve))
 (princ "\nDas war es")
 (princ)
) 

;Eigentliche Zeichenroutine, Eingaben sind alle erledigt
(defun draw_curve ()
 (setq draw_x_max 150.0 draw_y_max 150.0)	;Zeichenfl"ache
 (setq m_fahrer (atof m_fahrer))		(setq m_rad (atof m_rad))
 (setq korrekt (atof korrekt))			(setq v_wind (atof v_wind))
 (setq cwa (atof cwa))	(setq cr_v (atof cr_v))	(setq cr_h (atof cr_h)) 
 (setq t_c (atof t_c)) 	(setq p_l (atof p_l)) 	(setq l (atof l))
 (setq h (atof h))	(setq a (atof a))	(setq dt (atof dt))
 (setq pant (atof pant)) (setq max_p (atof max_p))

 (setq v_kmh 20)				;v_0
 (setq g 9.81 r 287.4)				;Erdanziehung, Gaskonstante Luft
 
 (setq v (/ v_kmh 3.6) t_k (+ t_c 273.15) rho (/ p_l r t_k 0.00001))
 (setq m (* (+ m_rad m_fahrer) korrekt)) 
 (setq time 0 s 0)					;Ausgangswerte

 (setq p (gefaelle 1)) (if (= mit_profil "0") (setq s_max 2000))
 (setq mas_x (/ draw_x_max s_max) mas_y_h (/ draw_y_max h_max)); Skalierung f"ur Weg und H"ohe
 (setq v_max_g (sqrt (* 2 (+ (* 0.5 v v) (* g h_max)))) mas_y_v (/ draw_y_max v_max_g)) ;Skal. f"ur Geschwindigkeit
 (setq v_max v h1 h_max)
 (setq mas_p (/ draw_y_max max_p)) ;Masstab fr Leistung
 (setq pl1 (list 0 (* v mas_y_v)) pl3 (list 0 (* h1 mas_y_h))) 
 (setq plv1 (list 0 0) plh1 plv1 plr1 plv1 plw1 plv1 plant1 (list 0 (* pant mas_p)))
 
 (while (< s s_max)
  (if (= mit_profil "1")
   (setq p (gefaelle s) alpha (atan (/ p 100.0))) (setq p 0 alpha 0))
  (setq n_h (/ (* (+ m_rad m_fahrer) g (- (* a (cos alpha)) (* h (sin alpha)))) l))
  (setq n_v (/ (* (+ m_rad m_fahrer) g (- l (- (* a (cos alpha)) (* h (sin alpha))))) l))
  (setq f_r (+ (* cr_h n_h) (* cr_v n_v)))
  (setq f_w (* cwa rho (+ v_wind v) (+ v_wind v) 0.5))
  (setq d_h (* v -1 dt (sin alpha)) h1 (+ h1 d_h))
  (setq w_v (sqr v) w_h (* 2 g d_h))
  (setq w_r (* 2 f_r v (/ dt m)) w_w (* 2 f_w v (/ dt m)))
  (setq w_ant (* pant -2 (/ dt m)))
  (setq z (- w_v w_h w_r w_w w_ant)) (if (< z 0) (setq z (- 0 z) s s_max))
  (setq ds (* dt (sqrt z)))
  (setq s (+ s ds))
  (setq v_v v v (/ ds dt))
  (if (> v v_max) (setq v_max v s_v_max s))
  (setq time (+ time dt))
  (setq pl2 (list (* s mas_x) (* v mas_y_v)) pl4 (list (* s mas_x) (* h1 mas_y_h))) 
  (if (= drw_perm "1") (progn
   (setvar "clayer" "geschwindigkeit") (command "_line" pl1 pl2 "")
   (setvar "clayer" "hoehe") (command "_line" pl3 pl4 ""))
   (progn (grdraw pl1 pl2 4) (grdraw pl3 pl4 11)))
  (setq pl1 pl2 pl3 pl4)
  (if (= drw_parwo "1") (progn
   (setq px (* s mas_x))
   (setq plv2 (list px (* (- (sqr v) (sqr v_v)) m (/ mas_p dt 2))))
   (setq plh2 (list px (* -1 m g d_h (/ mas_p dt))))
   (setq plr2 (list px (* f_r v mas_p)))
   (setq plw2 (list px (* f_w v mas_p)))
   (setq plant2 (list px (* pant mas_p)))
   (if  (= drw_perm "1") (progn
     (setvar "clayer" "leist_d_v") (command "_line" plv1 plv2 "")
     (setvar "clayer" "leist_d_h") (command "_line" plh1 plh2 "")
     (setvar "clayer" "leist_roll") (command "_line" plr1 plr2 "")
     (setvar "clayer" "leist_wind") (command "_line" plw1 plw2 "")
     (setvar "clayer" "leist_fahrer") (command "_line" plant1 plant2 ""))
    (progn (grdraw plv1 plv2 1) (grdraw plh1 plh2 2) (grdraw plr1 plr2 5) (grdraw plw1 plw2 7) (grdraw plant1 plant2 15)))
   (setq plv1 plv2 plh1 plh2 plr1 plr2 plw1 plw2 plant1 plant2)))
 ) 
 (setq out (strcat "\nMaximalgeschwindigkeit mit " (rtos (* 3.6 v_max)) " km/h nach " (rtos s_v_max) " m."))
 (princ out)
;Koordinatenkreuz zeichnen
 (setvar "clayer" "kosys") (command "_line" (list 0 0) (list (* s_max mas_x) 0) "")
 (setvar "clayer" "hoehe") (command "_line" (list 0 0) (list 0 draw_y_max) "")
 (setvar "clayer" "geschwindigkeit") (command "_line" (list (* s_max mas_x) 0) (list (* s_max mas_x) draw_y_max) "")
 (if (= drw_parwo "1") (progn
  (setvar "clayer" "kosys") (command "_line" (list (+ (* s_max mas_x) 10) 0) (list (+ (* s_max mas_x) 10) draw_y_max) "")))
 (setq pi2 (/ pi 2) pi3 (* pi2 3) np '(0 0))
;Beschriftung
 (setq out (strcat "V_max(cwa= "(cutnull (rtos cwa))")=" (cutnull (rtos (* 3.6 v_max)))))
 (command "_text" (list (* s_v_max mas_x) (* mas_y_v v_max)) texthoe "0" out)
 (command "_text" "_j" "_tl" (list draw_x_max 0) texthoe "0" "m") 
 (setq out (strcat "cr_v: " (cutnull (rtos cr_v)) ", cr_h: " (cutnull (rtos cr_h)))) 
 (command "_text" "_j" "_tr" (list (- draw_x_max 1) draw_y_max) texthoe "0" out) 
 (setq out (strcat "h: " (cutnull (rtos h)) ", l: " (cutnull (rtos l)) ", a: " (cutnull (rtos a))))
 (command "_text" "" out)
 (setq out (strcat "Luftdruck: " (cutnull (rtos p_l)) ", Temperatur: " (cutnull (rtos t_c)) "%%dC"))
 (command "_text" "" out)
 (setq out (strcat "Gesamtmasse: " (cutnull (rtos m)) "kg, Laufradkorrektur: " (cutnull (rtos korrekt))))
 (command "_text" "" out )

;Skalenteilung zeichen
 (setq dscale_x 50)						;Skalenunterteilung x
 (setq dscale_y_v 5 dscale_y_h 5 dscale_y_p (/ max_p 10.0))	;Skalenunterteilung y
 (setq dscale_y_p (/ (fix (* dscale_y_p 100)) 100.0))
;x-Achse
 (setq zw dscale_x)
 (setvar "clayer" "kosys")
 (while (< zw s_max)
  (setq pzw1 (list (* mas_x zw) 0) pzw2 (polar pzw1 pi3 lscale))
  (command "_line" pzw1 pzw2 "" "_text" "_j" "_mr" pzw2 texthoe "90" (cutnull (rtos zw)))
  (setq zw (+ zw dscale_x)))
;y-Achse: H"ohe
 (setq zw dscale_y_h) (setvar "clayer" "hoehe")
 (while (< zw h_max)
  (setq pzw1 (list 0 (* mas_y_h zw)) pzw2 (polar pzw1 pi lscale))
  (command "_line" pzw1 pzw2 "" "_text" "_j" "_mr" (polar pzw2 pi (* lscale 0.5)) texthoe 0 (cutnull (rtos zw)))
  (setq zw (+ zw dscale_y_h)))
 (command "_text" "_j" "_mr" (list -1 draw_y_max) texthoe "0" "m")  
;y-Achse: Geschwindigkeit
 (setq zw dscale_y_v) (setvar "clayer" "geschwindigkeit")
 (while (< zw v_max_g)
  (setq pzw1 (list draw_x_max (* mas_y_v zw)) pzw2 (polar pzw1 0 lscale))
  (command "_line" pzw1 pzw2 "")
  (command "_text" "_j" "_ml" (polar pzw2 0 (* lscale 1.5)) texthoe 0 (cutnull (rtos (* 3.6 zw))))
  (setq zw (+ zw dscale_y_v)))
 (command "_text" "_j" "_ml" (list (+ 3 draw_x_max) draw_y_max) texthoe "0" "km/h")  
;y-Achse: Leistungen
 (if (= drw_parwo "1") (progn
  (setq zw dscale_y_p) (setvar "clayer" "kosys")
  (while (< zw max_p)
   (setq pzw1 (list (+ 10 draw_x_max) (* mas_p zw)) pzw2 (polar pzw1 0 lscale))
   (command "_line" pzw1 pzw2 "")
   (command "_text" "_j" "_ml" (polar pzw2 0 (* lscale 1.5)) texthoe 0 (cutnull (rtos zw)))
   (setq zw (+ zw dscale_y_p)))
  (command "_text" "_j" "_ml" (list (+ 13 draw_x_max) draw_y_max) "" "" "W")  
  (setvar "clayer" "leist_d_v") (command "_text" "_j" "_ml" plv2 "" "" "Leistung durch Geschwindigkeitszunahme")
  (setvar "clayer" "leist_d_h") (command "_text" "_j" "_ml" plh2 "" "" "Leistung durch Hoehenverlust")
  (setvar "clayer" "leist_roll") (command "_text"  "_j" "_ml" plr2 "" "" "Rolleistung")
  (setvar "clayer" "leist_wind") (command "_text"  "_j" "_ml" plw2 "" "" "Windleistung")
  (setvar "clayer" "leist_fahrer") (command "_text"  "_j" "_ml" plant2 "" "" "Antriebsleistung")))

)

;gesamten Bereich l"oschen
(defun c:loal (/ p1 p2) (command "_erase" "_cr" (getvar "extmax") (getvar "extmin") ""))

;Layer erzeugen nach CAD User Deutschland 4/5 92 umgeschrieben von Olaf Schultz
(defun erzlay (name farbe ltp / ls te)
 (if (and (= ltp "continuous") (tblsearch "LTYPE" "AUSGEZOGEN")) (setq ltp "ausgezogen"))
 (loadltp ltp)
 (setq ls (tblsearch "LAYER" name))
 (if (= ls nil) (command "layer" "_new" name ""))
 (if (or (/= (assoc 62 te) farbe) (/= (assoc 6 te) ltp)) (command "_layer" "_co" farbe name "_lt" ltp name ""))
)

;Linientp laden
(defun loadltp (ltyp)
 (if (not (or (= ltyp "ausgezogen") (= ltyp "continuous")))
  (if (not (tblsearch "LTYPE" ltyp)) (command "_linetp" "l" ltyp "isc/isc" ""))
 )
)

;endende Nullen in Text kappen (bei Nachkommastellen)
(defun cutnull (text)
 (setq n (strlen text))
 (while (= (substr text n 1) "0") (setq n (1- n)))
 (setq text (substr text 1 n))
)
(defun sqr (x) (* x x))  ;Quadratfunktion

;gibt das aktuelle Gef"alle aus. Prozent von s

(defun gefaelle (s) (gefaelle_trift s))
(defun gefaelle_trift (s / p)
 (setq s_max 602 h_max 40)	;maximale Streckenl"ange und H"ohenunterschied
 (if (< s 50) (setq p 6)
  (if (< s 120) (setq p 2.86)
   (if (< s 170) (setq p 6)  
    (if (< s 270) (setq p 10)
     (if (< s 320) (setq p 14)
      (if (< s 370) (setq p 9)
       (if (< s 420) (setq p 5)
        (if (< s 470) (setq p 6)
         (if (< s 520) (setq p 0.2)
          (if (< s 570) (setq p 1.8)
           (if (< s s_max) (setq p 0.31) (setq p 1.36))))))))))))
 (setq p p)
)
(defun gefaelle_b4 (s / p)
 (setq s_max 5456.78 h_max 300)	;maximale Streckenl"ange und H"ohenunterschied
 (if (< s 313.6) (setq p 6.38)
  (if (< s 566.74) (setq p 7.90)
   (if (< s 757.13) (setq p 10.50)  
    (if (< s 1161.81) (setq p 9.88)
     (if (< s 1285.46) (setq p 16.17)
      (if (< s 1719.16) (setq p 4.61)
       (if (< s 1844.53) (setq p 7.98)
        (if (< s 2699.97) (setq p 1.17)
         (if (< s 2951.48) (setq p 3.64)
          (if (< s 3792.70) (setq p 1.73)
           (if (< s 4117.19) (setq p 4.15)
           (if (< s s_max) (setq p 3.08) (setq p 7.47)))))))))))))
 (setq p p)
)

Sollen andere Gefällestrecken verwendet werden, so definiert man idealerweise ein neues Unterprogramm analog gefaelle_trift und verweist im Unterprogramm gefalle nur darauf und lädt das Programmpaket trift neu.

Abbildung 3: Ausgabe des Lisp-Programmes am Beispiel der Kuhtrift
\begin{figure}\centering
\centering
\includegraphics[width=12cm]{bilder/trift}\end{figure}



Olaf Schultz 2007-01-15