Data update

This commit is contained in:
Ingy döt Net 2025-06-11 20:16:52 -04:00
parent 72eb4943cb
commit 4d5544505c
2347 changed files with 62432 additions and 16731 deletions

View file

@ -4,34 +4,34 @@ func analytic T0 t .
return TR + (T0 - TR) * pow 2.71828 (K * t)
.
ytxt = 95
proc draw_analytic a b . .
color 009
move 80 ytxt
proc draw_analytic a b .
gcolor 009
gtext 80 ytxt "analytic"
ytxt -= 5
text "analytic"
for t = a to b
line t analytic 100 t
yp = y
y = analytic 100 t
if t > a : gline t - 1 yp t y
.
.
drawgrid
linewidth 0.3
textsize 3
glinewidth 0.3
gtextsize 3
draw_analytic 0 100
#
func newton_cooling temp .
return K * (temp - TR)
.
proc draw_euler y0 a b step col . .
color col
move 80 ytxt
proc draw_euler y t t2 step col .
gcolor col
gtext 80 ytxt "step: " & step
ytxt -= 5
text "step: " & step
t = a
y = y0
while t < b
line t y
repeat
t += step
yp = y
y += step * newton_cooling y
gline t - step yp t y
until t >= t2
.
.
draw_euler 100 0 100 10 900

View file

@ -0,0 +1,15 @@
// make global variables with :: because while is only locally scoped
tn1::100
tn::100
// to store solution
sol::()
// these are constant, so only local scope
k:-0.07
time:100
steps:10
h:time%steps
tr:20
// applying x+h to 0 outside to end while loop
// bind to a variable to surpress output
var: {x<100}{tn1::tn+h*k*(tn-tr);sol::sol,tn;tn::tn1;x+h}\0
sol

View file

@ -0,0 +1,36 @@
package main
import "core:fmt"
import "core:math"
ivp_euler ::proc(y:f32,step:i32,end:i32){
y:=y
t:=i32(0)
for ;t<=end;t+=step{
if(t%10==0){fmt.printfln("%.3f", y)}
y+=f32(step)*cooling(f32(t),y)
}
}
cooling :: proc(t:f32,temp:f32)-> f32{
return -0.07* (temp-20.0)
}
analytic :: proc(){
for t := 0; t <= 100; t += 10{
fmt.printfln("%.3f",20+80*math.exp_f32(f32(-0.07)*f32(t)))
}
}
main :: proc() {
fmt.println("Step: 2 Seconds")
ivp_euler(100.0, 2,100)
fmt.println("Step: 5 Seconds")
ivp_euler(100.0, 5, 100)
fmt.println("Step: 10 Seconds")
ivp_euler(100.0, 10, 100)
fmt.println("Analytic")
analytic()
}

View file

@ -0,0 +1,10 @@
t:0
time:100
k:-0.07
tr:20
sol:()
steps:10
h:time%steps
tn:100
while [t<time;tn1:tn + h*(k)*(tn-tr);sol:sol,tn1;tn:tn1;t:t+h]
sol