Commit 87a70a9b authored by Johannes Blaschke's avatar Johannes Blaschke

start computing random fluxes

parent eeae95d6
......@@ -37,7 +37,7 @@
{
"data": {
"text/plain": [
"FluxArray{Float64}([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])"
"FluxArray{Float64}([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])"
]
},
"execution_count": 3,
......@@ -77,7 +77,7 @@
{
"data": {
"text/plain": [
"FluxArray{Float64}([2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])"
"FluxArray{Float64}([2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])"
]
},
"execution_count": 5,
......@@ -97,7 +97,7 @@
{
"data": {
"text/plain": [
"FluxArray{Float64}([2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])"
"FluxArray{Float64}([2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])"
]
},
"execution_count": 6,
......@@ -200,6 +200,66 @@
"f.total"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10-element Array{Float64,1}:\n",
" 0.2360682842072197 \n",
" 0.5793307175394222 \n",
" 0.529037753922956 \n",
" 0.2692179337072087 \n",
" 0.25318067370057373\n",
" 0.1556375949079274 \n",
" 0.961760331302904 \n",
" 0.6771712762431588 \n",
" 0.12442636982784938\n",
" 0.3921258104088836 "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fill_fr!(f)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10-element Array{Float64,1}:\n",
" 0.2360682842072197 \n",
" 0.5793307175394222 \n",
" 0.529037753922956 \n",
" 0.2692179337072087 \n",
" 0.25318067370057373\n",
" 0.1556375949079274 \n",
" 0.961760331302904 \n",
" 0.6771712762431588 \n",
" 0.12442636982784938\n",
" 0.3921258104088836 "
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f.fr"
]
},
{
"cell_type": "code",
"execution_count": null,
......
module FP
export FluxArray, size, reset!
export FluxArray, size, reset!, fill_fr!
import Base.size
import Random.rand!
import Distributions.Normal
struct FluxArray{T}
#
......@@ -14,12 +17,20 @@ struct FluxArray{T}
diffusive::Array{T}
stochastic::Array{T}
fr::Array{T}
left::Array{T}
right::Array{T}
function FluxArray{T}(n) where T
total::Array{T} = zeros(n + 1);
diffusive::Array{T} = zeros(n + 1);
stochastic::Array{T} = zeros(n + 1);
fr::Array{T} = zeros(n);
left::Array{T} = zeros(n);
right::Array{T} = zeros(n);
new{T}(total, diffusive, stochastic)
new{T}(total, diffusive, stochastic, fr, left, right)
end
end
......@@ -27,14 +38,28 @@ function size(flx::FluxArray{T}) where T
return size(flx.total, 1)
end
function size_cc(flx::FluxArray{T}) where T
return size(flx) - 1
end
function reset!(flx::FluxArray{T}, zero::T) where T
for i = 1:size(flx)
flx.total[i] = zero
flx.diffusive[i] = zero
flx.stochastic[i] = zero
end
# for i = 1:size(flx) - 1
# flx.fr[i] = zero;
# flx.left[i] = zero;
# flx.right[i] = zero;
# end
end
function fill_fr!(flx::FluxArray{T}) where T
rand!(flx.fr);
end
#function getFlux(n, h, N, k, D, FP, time)
# #get the diffusive flux for FV solver
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment