[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> another plate



;Hello Every Body
;Here is the code to simulate dynamic heat conduction in a square plate
;after applying 100 degrees to one of its sides,the other sides are kept at
;zero temperature.The numerical solution is the same as that of "Applied 
;Numerical Methods" by Carnahan et al;John Wiley & Sons 1969.
;The steady state final solution complies with Laplass's second order 
;differential equation on a square plane.
;It is Highly recommended to see a similar example given by George Mills
;in Mswlogo examples in the file plate.lgo where you can find remarkable
;clear style with excellent comments.
;The program draws isometric 3-d view,it will run under Ucblogo & Mswlogo
;as is. Under Ucblogo it takes about 30 seconds to finish.
;Best Regards.
;Mhelhefny
;------------------------------
to go
initialize cs ht mesh :a
mean :a
pu setxy -360 170 label (se [convergence reached after] repcount [iterations])
type [press any key] make "kk rc cs mesh :a
end

to grid1 :a
for [i 1 :m][setpc item :i :col for [j 2 :m][
make "pp mditem se :i :j :a mysetxyz :i*35 112+ :pp*4 :j*35 pd]pu]
end

to grid2 :a
for [j 2 :m][setpc item :j :col for [i 1 :m][
make "pp mditem se :i :j :a mysetxyz :i*35 112+ :pp*4 :j*35 pd]pu]
end

to initialize
make "m 9
make "col [5 4 2 4 5 6 7 3 6]
make "a mdarray se 9 9
for [i 1 9][for [j 1 9][ifelse :j=1[mdsetitem se :i :j :a 100][
mdsetitem se :i :j :a 0]]]
end

to mean :a
make "w 0
repeat 50[make "w :w+1 for [i 2 :m-1][for [j 2 :m-1][
make "left mditem se :i-1 :j :a  make "right mditem se :i+1 :j :a
make "up mditem se :i :j-1 :a    make "down mditem se :i :j+1 :a 
make "t1 mditem se :i :j :a      make "t2 (:left+ :right+ :up+ :down)/4 
make "e abs :t2- :t1 if :e<.002 [stop] mdsetitem se :i :j :a :t2]] mesh :a]
end

to mesh :a
pu grid1 :a grid2 :a
end

to mysetxyz :a :b :c
;library procedure
setxy (:a- :c)*cos 30 :b- (:a+ :c)*sin 30
end
;--------------------------
---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home