Commit 9f597476 authored by Johannes Blaschke's avatar Johannes Blaschke

cleanup module hirearchy

parent 1efb2d33
......@@ -8,7 +8,7 @@
{
"data": {
"text/plain": [
"Main.ModFluxArray"
"Main.FHD"
]
},
"execution_count": 1,
......@@ -17,7 +17,7 @@
}
],
"source": [
"include(\"src/flux_array.jl\")"
"include(\"src/fhd.jl\")"
]
},
{
......@@ -26,7 +26,7 @@
"metadata": {},
"outputs": [],
"source": [
"using .ModFluxArray"
"using .FHD"
]
},
{
......@@ -45,6 +45,26 @@
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"FluxArray{Float64}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"FluxArray{Float64}"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"n = DistributionArray{Float64}(0., 1., N);\n",
......@@ -53,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
......@@ -72,7 +92,7 @@
" 0.0"
]
},
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
......@@ -84,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
......@@ -94,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 22,
"metadata": {},
"outputs": [
{
......@@ -105,7 +125,7 @@
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.1936697622933632\n",
" 0.8892007282354997\n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
......@@ -113,7 +133,7 @@
" 0.0 "
]
},
"execution_count": 7,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
......@@ -124,26 +144,26 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10-element Array{Float64,1}:\n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.8063302377066368\n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 "
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.11079927176450033\n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 "
]
},
"execution_count": 8,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
......@@ -154,7 +174,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 24,
"metadata": {},
"outputs": [
{
......@@ -173,7 +193,7 @@
" 0.0"
]
},
"execution_count": 9,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
......@@ -184,7 +204,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
......@@ -193,27 +213,27 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11-element Array{Float64,1}:\n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 193.6697622933632\n",
" -806.3302377066368\n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 "
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 122.48749433947626\n",
" -877.5125056605237 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 \n",
" 0.0 "
]
},
"execution_count": 11,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
......@@ -224,7 +244,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
......@@ -233,27 +253,27 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11-element Array{Float64,1}:\n",
" 1.662956306086986 \n",
" 0.0 \n",
" -0.0 \n",
" -0.0 \n",
" 4.240011808025856 \n",
" 2.710972258785979 \n",
" -0.0 \n",
" 0.0 \n",
" -0.0 \n",
" -0.0 \n",
" -0.3416384648516665"
" 0.769796229343863 \n",
" -0.0 \n",
" -0.0 \n",
" -0.0 \n",
" -4.0441835514004545 \n",
" -2.5447437949849974 \n",
" -0.0 \n",
" -0.0 \n",
" -0.0 \n",
" -0.0 \n",
" 0.36347271419150995"
]
},
"execution_count": 13,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
......@@ -264,7 +284,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
......@@ -273,27 +293,27 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11-element Array{Float64,1}:\n",
" 0.0 \n",
" 0.0 \n",
" -0.0 \n",
" -0.0 \n",
" 4.240011808025856\n",
" 2.710972258785979\n",
" -0.0 \n",
" 0.0 \n",
" -0.0 \n",
" -0.0 \n",
" 0.0 "
" 0.0 \n",
" -0.0 \n",
" -0.0 \n",
" -0.0 \n",
" -4.0441835514004545\n",
" -2.5447437949849974\n",
" -0.0 \n",
" -0.0 \n",
" -0.0 \n",
" -0.0 \n",
" 0.0 "
]
},
"execution_count": 15,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
......
#module DistributionArrayModule
# export DistributionArray, size
"""
DistributionArrays store the distribution (probablity) `p` data, together with
the cell-center `xc` and face-center `xf` coodrdinates. This is essentially a
cheap histogram.
"""
mutable struct DistributionArray{T}
xc::Array{T};
xf::Array{T};
p::Array{T};
function DistributionArray{T}(xlo::T, xhi::T, n::Integer) where T
p::Array{T} = zeros(n);
xf::Array{T} = collect(range(xlo, stop = xhi, length = n+1));
dx::T = (xhi-xlo)/n;
xc::Array{T} = xf[1:n] .+ dx/2;
new{T}(xc, xf, p)
end
end
function size(d::DistributionArray{T}) where T
return size(d.p, 1)
end
# end
\ No newline at end of file
module FHD
include("flux_array.jl")
#import .FluxArrayModule
include("distribution_array.jl")
#import .DistributionArrayModule
include("sample.jl")
#import .SampleModule
export FluxArray, DistributionArray
export size, reset!, fill_fr!, fill_lr!, fill_df!, fill_sf!, apply_bc!
#size(d::FluxArray{T}) where T = FluxArrayModule.size(d)
#size(d::DistributionArray{T}) where T = DistributionArrayModule.size(d)
end
\ No newline at end of file
module StochFluxArray
# module FluxArrayModule
export DistributionArray
export size
export FluxArray, reset!, fill_fr!, fill_lr!, fill_df!, fill_sf!, apply_bc!
# export FluxArray, size, reset!, fill_fr!, fill_lr!, fill_df!, fill_sf!, apply_bc!
import Base.size
import Random.rand!
import Distributions.Normal
include("sample.jl")
import .Sample
"""
DistributionArrays store the distribution (probablity) `p` data, together with
the cell-center `xc` and face-center `xf` coodrdinates. This is essentially a
cheap histogram.
"""
mutable struct DistributionArray{T}
xc::Array{T};
xf::Array{T};
p::Array{T};
function DistributionArray{T}(xlo::T, xhi::T, n::Integer) where T
p::Array{T} = zeros(n);
xf::Array{T} = collect(range(xlo, stop = xhi, length = n+1));
dx::T = (xhi-xlo)/n;
xc::Array{T} = xf[1:n] .+ dx/2;
new{T}(xc, xf, p)
end
end
function size(d::DistributionArray{T}) where T
return size(d.p, 1)
end
#include("sample.jl")
#import .SampleModule
"""
......@@ -181,7 +150,4 @@ function fill_ft!(flx::FluxArray{T}, h::T, k::T) where T
end
end
end
\ No newline at end of file
# end
\ No newline at end of file
module Sample
# module SampleModule
export Proposal, rejection_sample
# export Proposal, rejection_sample
import Random.rand
......@@ -39,4 +39,4 @@ function rejection_sample(x::Array{T}, p::Array{T}, P::T, trials::Integer=1000)
return Proposal(T(0), false);
end
end
\ No newline at end of file
# end
\ No newline at end of file
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