Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs #186

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ using Documenter, JUDI, Weave
# Convert example to documentation markdown file
ex_path = "$(JUDI.JUDIPATH)/../examples/scripts"
doc_path = "$(JUDI.JUDIPATH)/../docs"
weave("$(ex_path)/modeling_basic_2D.jl"; out_path="$(doc_path)/src/tutorials/07_quickstart.md", doctype="github")
weave("$(ex_path)/imaging_conditions.jl"; out_path="$(doc_path)/src/tutorials/08_imaging_conditions.md", doctype="github")
weave("$(ex_path)/modeling_basic_2D.jl"; out_path="$(doc_path)/src/tutorials/quickstart.md", doctype="github")
weave("$(ex_path)/imaging_conditions.jl"; out_path="$(doc_path)/src/tutorials/imaging_conditions.md", doctype="github")

# Create documentation
makedocs(sitename="JUDI documentation",
Expand Down
632 changes: 632 additions & 0 deletions examples/notebooks/07_preconditionners.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/TimeModeling/Preconditioners/DataPreconditioners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ struct TimeDifferential{T, K} <: DataPreconditioner{T, T}
recGeom::Geometry
end

TimeDifferential(g::Geometry{T}, order::Integer) where T = TimeDifferential{T, order}(n_samples(g), g)
TimeDifferential(g::Geometry{T}, order::Number) where T = TimeDifferential{T, order}(n_samples(g), g)

judiTimeDerivative(v::judiVector{T, AT}, order::Integer) where {T, AT} = TimeDifferential(v.geometry, order)
judiTimeDerivative(g::Geometry{T}, order::Integer) where {T} = TimeDifferential(g, order)
judiTimeDerivative(v::judiVector{T, AT}, order::Number) where {T, AT} = TimeDifferential(v.geometry, order)
judiTimeDerivative(g::Geometry{T}, order::Number) where {T} = TimeDifferential(g, order)

judiTimeIntegration(v::judiVector{T, AT}, order::Integer) where {T, AT} = TimeDifferential(v.geometry, -order)
judiTimeIntegration(g::Geometry{T}, order::Integer) where {T} = TimeDifferential(g, -order)
judiTimeIntegration(v::judiVector{T, AT}, order::Number) where {T, AT} = TimeDifferential(v.geometry, -order)
judiTimeIntegration(g::Geometry{T}, order::Number) where {T} = TimeDifferential(g, -order)

# Real diagonal operator
conj(D::TimeDifferential{T, K}) where {T, K} = D
Expand Down
12 changes: 6 additions & 6 deletions src/TimeModeling/Preconditioners/ModelPreconditioners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ struct DepthScaling{T, N, K} <: ModelPreconditioner{T, T}
end

function judiDepthScaling(model::AbstractModel; K=.5f0)
N = length(model.n)
depth = reshape(range(0f0, stop=(model.n[end] - 1) * model.d[end], length=model.n[end]), ones(Int64, N-1)..., :)
return DepthScaling{Float32, N, K}(prod(model.n), depth)
N = length(size(model))
depth = reshape(range(0f0, stop=(size(model)[end] - 1) * spacing(model)[end], length=size(model)[end]), ones(Int64, N-1)..., :)
return DepthScaling{Float32, N, K}(prod(size(model)), depth)
end

matvec(D::DepthScaling{T, N, K}, x::Vector{T}) where {T, N, K} = vec(reshape(x, :, size(D.depth, N)) .* D.depth[:]'.^K)
Expand Down Expand Up @@ -60,7 +60,7 @@ judiTopmute(n::NTuple{N, Integer}, wb::Integer, taperwidth::Integer) where {N} =

function judiTopmute(model::AbstractModel; taperwidth=10)
wb = find_water_bottom(model.m.data)
return TopMute(prod(model.n), wb, taperwidth)
return TopMute(prod(size(model)), wb, taperwidth)
end


Expand Down Expand Up @@ -129,9 +129,9 @@ struct judiIllumination{DDT, M, K, R} <: ModelPreconditioner{DDT, DDT}
end

function judiIllumination(model::AbstractModel; mode="u", k=1, recompute=true)
n = prod(model.n)
n = prod(size(model))
# Initialize the illumination as the identity
illum = Dict(s=>PhysicalParameter(model.n, model.d, model.o, ones(Float32, model.n)) for s in split(mode, ""))
illum = Dict(s=>PhysicalParameter(size(model), spacing(model), origin(model), ones(Float32, size(model))) for s in split(mode, ""))
I = judiIllumination{Float32, Symbol(mode), k, recompute}("Illumination", illum, n)
init_illum(model, I)
return I
Expand Down
73 changes: 28 additions & 45 deletions src/TimeModeling/Types/ModelStructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,51 +258,6 @@ end
NpyArray(p::PhysicalParameter{T, N}, revdims::Bool) where {T<:AbstractFloat, N} = NpyArray(p.data, revdims)

###################################################################################################
# Isotropic acoustic

"""
Model
n::NTuple{N, Int64}
d::NTuple{N, Float32}
o::NTuple{N, Float32}
nb::Integer
params::Dict
rho::Array

Model structure for seismic velocity models.

`n`: number of gridpoints in (x,y,z) for 3D or (x,z) for 2D

`d`: grid spacing in (x,y,z) or (x,z) (in meters)

`o`: origin of coordinate system in (x,y,z) or (x,z) (in meters)

`nb`: number of absorbing boundary points in each direction

`params`: Physical parameters such has squared slowness, denisty or THomesne parameters

Constructor
===========

The parameters `n`, `d`, `o` and `m` are mandatory, whith `nb` and other physical parameters being optional input arguments.

Model(n, d, o, m; nb=40, rho=1, epsilon=0, delta=0, theta=0, phi=0)

where

`m`: velocity model in slowness squared (s^2/km^2)

`epsilon`: Epsilon thomsen parameter ( between -1 and 1)

`delta`: Delta thomsen parameter ( between -1 and 1 and delta < epsilon)

`theta`: Anisotopy dip in radian

`phi`: Anisotropy asymuth in radian

`rho`: density (g / m^3)

"""
const ModelParam{T, N} = Union{T, PhysicalParameter{T, N}}

# Acoustic
Expand Down Expand Up @@ -352,6 +307,34 @@ _mparams(m::AbstractModel) = first.(_params(m))
_scalar(::Nothing, ::Type{T}, def=1) where T = T(def)
_scalar(v::Number, ::Type{T}, def=1) where T = T(v)

"""
Model(n, d, o, m; epsilon=nothing, delta=nothing, theta=nothing,
phi=nothing, rho=nothing, qp=nothing, vs=nothing, nb=40)


The parameters `n`, `d`, `o` and `m` are mandatory, whith `nb` and other physical parameters being optional input arguments.

where

`m`: velocity model in slowness squared (s^2/km^2)

`epsilon`: Epsilon thomsen parameter ( between -1 and 1)

`delta`: Delta thomsen parameter ( between -1 and 1 and delta < epsilon)

`theta`: Anisotopy dip in radian

`phi`: Anisotropy asymuth in radian

`rho`: density (g / m^3)

`qp`: P-wave attenuation for visco-acoustic models

`vs`: S-wave velocity for elastic models.

`nb`: Number of ABC points

"""
function Model(n, d, o, m::Array{mT, N}; epsilon=nothing, delta=nothing, theta=nothing,
phi=nothing, rho=nothing, qp=nothing, vs=nothing, nb=40) where {mT<:AbstractFloat, N}

Expand Down