Please bare with me if the solution is as simple as 1 2 3, but I'm relatively new to differential equations :)
Now how do I translate this:
Bucket2.new <-- Bucket2.old + time * ( Outflow_1 - Outflow_2 )
Bucket1.new <-- Bucket1.old + time * ( -Outflow_1 )
Bucket2_Initial = 0 // Initial fill value of bucket 2
Bucket1_Initial = 20 // you guessed it
Outflow_2 = Bucket2 * 0.1
Outflow_1 = 0.2 * Bucket1
into a set of differential equations in the shape of something like this that a computer could solve:
bucket1 = ...
bucket2 = ...
where I have initial conditions for the water level of bucket 1 and 2.
Context:
I want to program a simulation software for school and I already found out, how I can solve ordinary differential equations using the "CSharpOdeLibrary" and also, how I can display the calculated values in a graph.
The problem is, that this only works for the sample equations the library provided me with, the lorenz equations. It all works perfectly fine, but I have no clue how I can expand this concept to simulate any real world context.
In this scenario, I have two buckets, both have a hole in them. The water flows through each hole from bucket 1 into bucket 2 onto the ground. Afterwards, I want to have a graph displaying me the water level of each bucket over the time.
Let me try. Differential equations relate speed of change of a variable to its level. In your
the levels are Bucket1 and Bucket2 and speed of change is (Bucket2.new-Bucket2.old)/time. Hence, I would rewrite your equations into
b2'[t]=2/10*b1[t]-1/10*b2[t]
b1'[t]=-2/10*b1[t]
Along with initial conditions, this is a differential equation. Asking mathematica for solution amounts to the following code
s=DSolve[{b2'[t]==2/10*b1[t]-1/10*b2[t],b1'[t]==-2/10*b1[t],b1[0]==20,b2[0]==0},{b1[t],b2[t]},t][1];
b1s[t_] := Evaluate[b1[t] /. s]
b2s[t_] := Evaluate[b2[t] /. s]
Plot[{b1s[t], b2s[t]}, {t, 0, 40}, PlotRange -> {All, {0, 20}}]
and gives
$b_{1}[t]=20e^{-t/5}$
$b_{2}[t]=40e^{-t/5}(-1+e^{t/10})$
which looks like this
Replacing your 2/10 by a, 1/10 by b and 20 by c, the solution is
$b_{1}[t]=ce^{-at}$
$b_{2}[t]=-ace^{(-at-bt)}(-e^{at}+e^{bt})/(a-b)$
Once you have the solutions, plotting them in any software you prefer to use should be a simple matter.