Commit c25a94e0 authored by Johannes Blaschke's avatar Johannes Blaschke

add left and right fluxes

parent 87a70a9b
......@@ -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], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 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], Distributions.Normal{Float64}(μ=0.0, σ=1.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], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 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], Distributions.Normal{Float64}(μ=0.0, σ=1.0))"
]
},
"execution_count": 5,
......@@ -93,26 +93,6 @@
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"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], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 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,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
......@@ -120,7 +100,7 @@
"11"
]
},
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
......@@ -131,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [
{
......@@ -151,7 +131,7 @@
" 0.0"
]
},
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
......@@ -162,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
......@@ -171,7 +151,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [
{
......@@ -191,7 +171,7 @@
" 0.0"
]
},
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
......@@ -202,26 +182,26 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"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 "
" 0.3719488756174305 \n",
" 0.7078439875853346 \n",
" 0.14686744039919186 \n",
" 0.7371645339687076 \n",
" 0.28061514908409957 \n",
" 0.06665763097169641 \n",
" 0.3619721310699473 \n",
" 0.5156590411935236 \n",
" 0.9600217110629821 \n",
" 0.0028426574179554187"
]
},
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
......@@ -232,26 +212,26 @@
},
{
"cell_type": "code",
"execution_count": 13,
"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 "
" 0.3719488756174305 \n",
" 0.7078439875853346 \n",
" 0.14686744039919186 \n",
" 0.7371645339687076 \n",
" 0.28061514908409957 \n",
" 0.06665763097169641 \n",
" 0.3619721310699473 \n",
" 0.5156590411935236 \n",
" 0.9600217110629821 \n",
" 0.0028426574179554187"
]
},
"execution_count": 13,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
......@@ -260,6 +240,96 @@
"f.fr"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10-element Array{Float64,1}:\n",
" 0.15640224893447258 \n",
" -0.8567724114538633 \n",
" -0.03319116142866772 \n",
" -0.015849254780078256 \n",
" 0.8756940245445292 \n",
" 0.05592573265792126 \n",
" -0.43241475945139746 \n",
" -0.3858741762658584 \n",
" 0.31423851240411305 \n",
" -0.0027535889452761316"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fill_lr!(f)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10-element Array{Float64,1}:\n",
" -0.225580551433496 \n",
" -0.4954587637915302 \n",
" 0.43257977013920135 \n",
" 0.6598113417294635 \n",
" -0.8498029315267405 \n",
" 0.7326503841221602 \n",
" -0.415898912958631 \n",
" 1.8333641220723385 \n",
" 0.034033453904415645\n",
" -1.9254946253093828 "
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f.left"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10-element Array{Float64,1}:\n",
" 0.42049394200976353 \n",
" -1.2103972435742056 \n",
" -0.22599400751080537 \n",
" -0.021500294777815575\n",
" 3.1206227725149867 \n",
" 0.8389997040499078 \n",
" -1.1946078781624154 \n",
" -0.7483126357539075 \n",
" 0.32732438108735384 \n",
" -0.9686671801826372 "
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f.right"
]
},
{
"cell_type": "code",
"execution_count": null,
......
module FP
export FluxArray, size, reset!, fill_fr!
export FluxArray, size, reset!, fill_fr!, fill_lr!
import Base.size
import Random.rand!
......@@ -20,7 +20,9 @@ struct FluxArray{T}
fr::Array{T}
left::Array{T}
right::Array{T}
distribution
function FluxArray{T}(n) where T
total::Array{T} = zeros(n + 1);
diffusive::Array{T} = zeros(n + 1);
......@@ -30,7 +32,9 @@ struct FluxArray{T}
left::Array{T} = zeros(n);
right::Array{T} = zeros(n);
new{T}(total, diffusive, stochastic, fr, left, right)
d = Normal(0, 1);
new{T}(total, diffusive, stochastic, fr, left, right, d)
end
end
......@@ -49,18 +53,18 @@ function reset!(flx::FluxArray{T}, zero::T) where T
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 fill_lr!(flx::FluxArray{T}) where T
rand!(flx.distribution, flx.left) .* (1 .- flx.fr)
rand!(flx.distribution, flx.right) .* 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