licenses
sequencelengths 1
3
| version
stringclasses 677
values | tree_hash
stringlengths 40
40
| path
stringclasses 1
value | type
stringclasses 2
values | size
stringlengths 2
8
| text
stringlengths 25
67.1M
| package_name
stringlengths 2
41
| repo
stringlengths 33
86
|
---|---|---|---|---|---|---|---|---|
[
"MIT"
] | 0.1.1 | 731532d7a03845a784a5a5e4e9a7b4993830032c | code | 756 | # Copied from Test package, for testing test failures
mutable struct NoThrowTestSet <: Test.AbstractTestSet
results::Vector
NoThrowTestSet(desc) = new([])
end
Test.record(ts::NoThrowTestSet, t::Test.Result) = (push!(ts.results, t); t)
Test.finish(ts::NoThrowTestSet) = ts.results
# User-defined struct with custom show for testing
struct TestStruct
a::Int
b::Float64
end
Base.show(io::IO, s::TestStruct) = print(io, "S(", s.a, ", ", s.b, ")")
# Remove ANSI color codes from a string
destyle = x -> replace(x, r"\e\[\d+m" => "")
# Evaluate occursin(x, str), but replaces every `\e` with a regex that matches an
# ANSI color code.
ansire = x -> Regex(replace(x, '\e' => raw"\e\[\d+m"))
ansioccursin = (x, str) -> occursin(ansire(x), str) | PrettyTests | https://github.com/tpapalex/PrettyTests.jl.git |
|
[
"MIT"
] | 0.1.1 | 731532d7a03845a784a5a5e4e9a7b4993830032c | code | 359 | using PrettyTests
using PrettyTests
using Test
const PT = PrettyTests
PT.disable_failure_styling() # Will be enabled for some tests, but mostly don't want for tests
@testset "PrettyTests.jl" begin
include("nothrowtestset.jl") # structs used in testing of test macros
include("helpers.jl")
include("test_sets.jl")
include("test_all.jl")
end
| PrettyTests | https://github.com/tpapalex/PrettyTests.jl.git |
|
[
"MIT"
] | 0.1.1 | 731532d7a03845a784a5a5e4e9a7b4993830032c | code | 42700 | @testset "test_all.jl" begin
@testset "pushkeywords!(ex, kws)" begin
@testset "without keywords" begin
# Test that returns input if there are no keywords added to case
cases = [
:(a == b),
:(a .< b),
:(!(a == b)),
:(.!(a .≈ b)),
:(f()),
:(f.(a)),
:(!f()),
:(.!f.(a))
]
@testset "ex: $ex" for ex in cases
modex = PT.pushkeywords!(ex)
@test modex === ex
end
end
@testset "with keywords" begin
# Add :(x = 1) keyword to case
cases = [
:(a ≈ b) => :(≈(a, b, x = 1)),
:(a .≈ b) => :(.≈(a, b, x = 1)),
:(g()) => :(g(x = 1)),
:(!g()) => :(!g(x = 1)),
:(g.(a)) => :(g.(a, x = 1)),
:(.!g.(a)) => :(.!g.(a, x = 1)),
]
@testset "push (x=1) to ex: $ex" for (ex, res) in cases
mod_ex = PT.pushkeywords!(ex, :(x = 1))
@test mod_ex == res
end
# Add :(x = 1, y = 2) keywords to case
cases = [
:(g()) => :(g(x = 1, y = 2))
:(.!g.(a)) => :(.!g.(a, x = 1, y = 2))
]
@testset "push (x=1,y=2) to ex: $ex" for (ex, res) in cases
mod_ex = PT.pushkeywords!(ex, :(x = 1), :(y=2))
@test mod_ex == res
end
end
@testset "does not accept keywords" begin
# Throws error because case does not support keywords
cases = [
:(a),
:(:a),
:(a && b),
:(a .|| b),
:([a,b]),
:((a,b)),
:(a <: b)
]
@testset "ex: $ex" for ex in cases
@test_throws ErrorException("invalid test macro call: @test_all $ex does not accept keyword arguments") PT.pushkeywords!(ex, :(x = 1))
end
end
@testset "invalid keyword syntax" begin
# Throws error because case is not valid keyword syntax
cases = [
:(a),
:(:a),
:(a == 1),
:(g(x)),
]
@testset "kw: $kw" for kw in cases
@test_throws ErrorException("invalid test macro call: $kw is not valid keyword syntax") PT.pushkeywords!(:(g()), kw)
end
# Same but where only some keywords are invalid
@testset "kws: (x = 1, $kw)" for kw in cases
@test_throws ErrorException PT.pushkeywords!(:(g()), :(x = 1), kw)
end
end
end
@testset "preprocess_test_all(ex)" begin
@testset "convert to comparison" begin
# Case is converted to :comparison call
cases = [
:(a .== b) => Expr(:comparison, :a, :.==, :b),
:(.≈(a, b)) => Expr(:comparison, :a, :.≈, :b),
:(a .≈ b) => Expr(:comparison, :a, :.≈, :b),
:(a .∈ b) => Expr(:comparison, :a, :.∈, :b),
:(a .⊆ b) => Expr(:comparison, :a, :.⊆, :b),
:(a .<: b) => Expr(:comparison, :a, :.<:, :b),
:(a .>: b) => Expr(:comparison, :a, :.>:, :b),
]
@testset "ex: $ex" for (ex, res) in cases
proc_ex = PT.preprocess_test_all(ex)
@test proc_ex == res
@test proc_ex !== res # returns new expression
end
end
@testset "change parameters kws to trailing" begin
# Parameter kws in case are moved to trailing arguments
cases = [
# Displayable, not vectorized
:(isnan(x; a=1)) => :(isnan(x, a=1)),
:(isnan(x, a=1; b=1)) => :(isnan(x, a=1, b=1)),
:(isnan(x; a=1, b=1)) => :(isnan(x, a=1, b=1)),
# Displayable, vectorized
:(isnan.(x; a=1)) => :(isnan.(x, a=1)),
:(isnan.(x, a=1; b=1)) => :(isnan.(x, a=1, b=1)),
:(isnan.(x; a=1, b=1)) => :(isnan.(x, a=1, b=1)),
# Approx cases
:(≈(x, y; a=1)) => :(≈(x, y, a=1)),
:(≈(x, y, a=1; b=1)) => :(≈(x, y, a=1, b=1)),
:(.≈(x, y; a=1)) => :(.≈(x, y, a=1)),
:(.≈(x, y, a=1; b=1)) => :(.≈(x, y, a=1, b=1)),
]
@testset "ex: $ex" for (ex, res) in cases
proc_ex = PT.preprocess_test_all(ex)
@test proc_ex == res
@test proc_ex !== res # returns new expression
end
end
@testset "no preprocess_test_alling" begin
# Expression remains unchanged
cases = [
:a,
:(:a),
:(a == b),
:(a .== b .== c),
Expr(:comparison, :a, :.==, :b),
:(g(x; a = 1)),
:(isnan(x)), # Displayable call, but no keywords
:(isnan(x, a = 1)), # Displayable call, but already trailing keywords
:(isnan.(x)), # Displayable, but no keywords
:(isnan.(x, a = 1)) # Displayable, but already trailing keywords
]
@testset "ex: $ex" for ex in cases
@test PT.preprocess_test_all(deepcopy(ex)) == ex
@test PT.preprocess_test_all(ex) === ex
end
end
end
@testset "expression classifiers" begin
@testset "isvecnegationexpr(ex)" begin
cases = [
# True
:(.!a) => true,
:(.!(a .== b)) => true,
:(.!g(x)) => true,
:(.!g.(x)) => true,
:(.!isnan.(x)) => true,
# False
:(a .== b) => false,
:(!a) => false,
:(!g(x)) => false,
:(!(a == b)) => false,
]
@testset "ex: $ex ===> $res" for (ex, res) in cases
ex = PT.preprocess_test_all(ex)
@test PT.isvecnegationexpr(ex) === res
end
end
@testset "isveclogicalexpr(ex)" begin
cases = [
# True
:(a .& b) => true,
:(a .| b) => true,
:(a .⊽ b) => true,
:(a .⊻ b) => true,
:(a .& b .| c) => true,
:(a .⊽ g.(x) .⊻ c) => true,
# False
:(a & b) => false,
:(a || b) => false,
:(a ⊻ b) => false,
:(a .== b) => false,
]
@testset "ex: $ex ===> $res" for (ex, res) in cases
ex = PT.preprocess_test_all(ex)
@test PT.isveclogicalexpr(ex) === res
end
end
@testset "isveccomparisonexpr(ex)" begin
cases = [
# True
:(a .== b) => true,
:(a .≈ b) => true,
:(a .>: b) => true,
:(a .<: b) => true,
:(a .∈ b) => true,
# False (other)
:(a == b) => false,
:(a .== b <= c) => false,
:(a .&& b) => false,
:(a .|| b) => false,
]
@testset "$ex => $res" for (ex, res) in cases
ex = PT.preprocess_test_all(ex)
@test PT.isveccomparisonexpr(ex) === res
end
end
@testset "isvecapproxexpr(ex)" begin
cases = [
# True
:(.≈(a, b, atol=1)) => true,
:(.≉(a, b, atol=1)) => true,
# False (splats)
:(.≈(a..., atol=1)) => false,
:(.≈(a, b..., atol=1)) => false,
:(.≉(a..., b, atol=1)) => false,
# False (other)
:(≈(a, b, atol=1)) => false,
:(≉(a, b, atol=1)) => false,
:(a == b) => false,
:(a .== b <= c) => false,
:(a .&& b) => false,
:(a .|| b) => false,
]
@testset "ex: $ex ===> $res" for (ex, res) in cases
ex = PT.preprocess_test_all(ex)
@test PT.isvecapproxexpr(ex) === res
end
end
@testset "isvecdisplayexpr(ex)" begin
cases = [
# True
:(isnan.(x)) => true,
:(isreal.(x)) => true,
:(occursin.(a, b)) => true,
:(isapprox.(a, b, atol=1)) => true,
# False (not vectorized)
:(isnan(x)) => false,
:(isapprox(a, b, atol=1)) => false,
# False (splats)
:(isnan.(a...)) => false,
:(isapprox.(a..., atol=1)) => false,
# False (other)
:(g.(x)) => false,
:(a .== b) => false,
]
@testset "ex: $ex ===> $res" for (ex, res) in cases
ex = PT.preprocess_test_all(ex)
@test PT.isvecdisplayexpr(ex) === res
end
end
end
@testset "recurse_process!()" begin
escape! = (ex, args; kws...) -> PT.recurse_process!(deepcopy(ex), args; kws...)
stringify! = fmt_io -> PT.stringify!(fmt_io)
@testset "basecase" begin
cases = [
:(1),
:(a),
:(:a),
:([1,2]),
:(Int[a,b]),
:(a[1]),
:(g(x)),
:(g.(x,a=1;b=b)),
:(a:length(b)),
:(a...),
:(√a),
:(A'),
:(10 * TOL),
]
@testset "ex: $ex" for ex in cases
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == Expr[esc(ex)]
@test res == :(ARG[1])
@test stringify!(str) == sprint(Base.show_unquoted, ex)
@test stringify!(fmt) == "{1:s}"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == Expr[esc(ex), esc(ex)]
@test res == :(ARG[2])
@test stringify!(str) == sprint(Base.show_unquoted, ex)
@test stringify!(fmt) == "{2:s}"
end
cases = [
:(a + b),
:(a .- b),
:(a && b),
:(a * b)
]
@testset "ex: $ex" for ex in cases
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == Expr[esc(ex)]
@test res == :(ARG[1])
@test stringify!(str) == sprint(Base.show_unquoted, ex)
@test stringify!(fmt) == "{1:s}"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == Expr[esc(ex), esc(ex)]
@test res == :(ARG[2])
@test stringify!(str) == "(" * sprint(Base.show_unquoted, ex) * ")"
@test stringify!(fmt) == "{2:s}"
end
end
@testset "keywords" begin
kw = Expr(:kw, :a, 1)
@testset "kw: $(kw.args[1]) = $(kw.args[2])" begin
args = Expr[]
res, str, fmt = escape!(kw, args)
@test args == [esc(:(Ref(1)))]
@test res == Expr(:kw, :a, :(ARG[1].x))
@test stringify!(str) == "a=1"
@test stringify!(fmt) == "a={1:s}"
res, str, fmt = escape!(kw, args)
@test args == [esc(:(Ref(1))), esc(:(Ref(1)))]
@test res == Expr(:kw, :a, :(ARG[2].x))
@test stringify!(str) == "a=1"
@test stringify!(fmt) == "a={2:s}"
end
kw = Expr(:kw, :atol, :(1+TOL))
@testset "kw: $(kw.args[1]) = $(kw.args[2])" begin
args = Expr[]
res, str, fmt = escape!(kw, args)
@test args == [esc(:(Ref(1+TOL)))]
@test res == Expr(:kw, :atol, :(ARG[1].x))
@test stringify!(str) == "atol=1 + TOL"
@test stringify!(fmt) == "atol={1:s}"
res, str, fmt = escape!(kw, args)
@test args == [esc(:(Ref(1+TOL))), esc(:(Ref(1+TOL)))]
@test res == Expr(:kw, :atol, :(ARG[2].x))
@test stringify!(str) == "atol=1 + TOL"
@test stringify!(fmt) == "atol={2:s}"
end
end
@testset "negation" begin
ex = :(.!a)
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == Expr[esc(:a)]
@test res == Expr(:call, esc(:.!), :(ARG[1]))
@test stringify!(str) == ".!a"
@test stringify!(fmt) == "!{1:s}"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == Expr[esc(:a), esc(:a)]
@test res == Expr(:call, esc(:.!), :(ARG[2]))
@test stringify!(str) == ".!a"
@test stringify!(fmt) == "!{2:s}"
end
end
@testset "logical" begin
ex = :(a .& b)
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b])
@test res == Expr(:call, esc(:.&), :(ARG[1]), :(ARG[2]))
@test stringify!(str) == "a .& b"
@test stringify!(fmt) == "{1:s} & {2:s}"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == Expr[esc(:a), esc(:b), esc(:a), esc(:b)]
@test res == Expr(:call, esc(:.&), :(ARG[3]), :(ARG[4]))
@test stringify!(str) == "(a .& b)"
@test stringify!(fmt) == "({3:s} & {4:s})"
end
ex = :(a .| b .| c)
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b, :c])
inner_res = Expr(:call, esc(:.|), :(ARG[1]), :(ARG[2]))
@test res == Expr(:call, esc(:.|), inner_res, :(ARG[3]))
@test stringify!(str) == "a .| b .| c"
@test stringify!(fmt) == "{1:s} | {2:s} | {3:s}"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == esc.([:a, :b, :c, :a, :b, :c])
inner_res = Expr(:call, esc(:.|), :(ARG[4]), :(ARG[5]))
@test res == Expr(:call, esc(:.|), inner_res, :(ARG[6]))
@test stringify!(str) == "(a .| b .| c)"
@test stringify!(fmt) == "({4:s} | {5:s} | {6:s})"
end
ex = :(a .& b .⊻ c .⊽ d .| e)
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b, :c, :d, :e])
inner_res = Expr(:call, esc(:.&), :(ARG[1]), :(ARG[2]))
inner_res = Expr(:call, esc(:.⊻), inner_res, :(ARG[3]))
inner_res = Expr(:call, esc(:.⊽), inner_res, :(ARG[4]))
@test res == Expr(:call, esc(:.|), inner_res, :(ARG[5]))
@test stringify!(str) == "a .& b .⊻ c .⊽ d .| e"
@test stringify!(fmt) == "{1:s} & {2:s} ⊻ {3:s} ⊽ {4:s} | {5:s}"
end
ex = :(.⊽(a, b, c))
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b, :c])
@test res == Expr(:call, esc(:.⊽), :(ARG[1]), :(ARG[2]), :(ARG[3]))
@test stringify!(str) == "a .⊽ b .⊽ c"
@test stringify!(fmt) == "{1:s} ⊽ {2:s} ⊽ {3:s}"
end
end
@testset "comparison" begin
ex = :(a .== b)
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b])
@test res == Expr(:comparison, :(ARG[1]), esc(:.==), :(ARG[2]))
@test stringify!(str) == "a .== b"
@test stringify!(fmt) == "{1:s} == {2:s}"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == esc.([:a, :b, :a, :b])
@test res == Expr(:comparison, :(ARG[3]), esc(:.==), :(ARG[4]))
@test stringify!(str) == "(a .== b)"
@test stringify!(fmt) == "({3:s} == {4:s})"
end
ex = :(a .≈ b .> c)
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=false)
@test args == esc.([:a, :b, :c])
@test res == Expr(:comparison, :(ARG[1]), esc(:.≈), :(ARG[2]), esc(:.>), :(ARG[3]))
@test stringify!(str) == "(a .≈ b .> c)"
@test stringify!(fmt) == "({1:s} ≈ {2:s} > {3:s})"
end
ex = :(a .<: b .>: c)
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b, :c])
@test res == Expr(:comparison, :(ARG[1]), esc(:.<:), :(ARG[2]), esc(:.>:), :(ARG[3]))
@test stringify!(str) == "a .<: b .>: c"
@test stringify!(fmt) == "{1:s} <: {2:s} >: {3:s}"
end
end
@testset "approx" begin
ex = :(.≈(a, b, atol=10*TOL))
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b, :(Ref(10*TOL))])
@test res == Expr(:call, esc(:.≈),
:(ARG[1]), :(ARG[2]),
Expr(:kw, :atol, :(ARG[3].x)))
@test stringify!(str) == ".≈(a, b, atol=10TOL)"
@test stringify!(fmt) == "{1:s} ≈ {2:s} (atol={3:s})"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == esc.([:a, :b, :(Ref(10*TOL)), :a, :b, :(Ref(10*TOL))])
@test res == Expr(:call, esc(:.≈),
:(ARG[4]), :(ARG[5]),
Expr(:kw, :atol, :(ARG[6].x)))
@test stringify!(str) == ".≈(a, b, atol=10TOL)"
@test stringify!(fmt) == "≈({4:s}, {5:s}, atol={6:s})"
end
ex = :(.≉(a, b, rtol=1, atol=1))
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b, :(Ref(1)), :(Ref(1))])
@test res == Expr(:call, esc(:.≉),
:(ARG[1]), :(ARG[2]),
Expr(:kw, :rtol, :(ARG[3].x)),
Expr(:kw, :atol, :(ARG[4].x)))
@test stringify!(str) == ".≉(a, b, rtol=1, atol=1)"
@test stringify!(fmt) == "{1:s} ≉ {2:s} (rtol={3:s}, atol={4:s})"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == esc.([:a, :b, :(Ref(1)), :(Ref(1)), :a, :b, :(Ref(1)), :(Ref(1))])
@test res == Expr(:call, esc(:.≉),
:(ARG[5]), :(ARG[6]),
Expr(:kw, :rtol, :(ARG[7].x)),
Expr(:kw, :atol, :(ARG[8].x)))
@test stringify!(str) == ".≉(a, b, rtol=1, atol=1)"
@test stringify!(fmt) == "≉({5:s}, {6:s}, rtol={7:s}, atol={8:s})"
end
end
@testset "displayable function" begin
ex = :(isnan.(a))
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a])
@test res == Expr(:., esc(:isnan), Expr(:tuple, :(ARG[1])))
@test stringify!(str) == "isnan.(a)"
@test stringify!(fmt) == "isnan({1:s})"
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :a])
@test res == Expr(:., esc(:isnan), Expr(:tuple, :(ARG[2])))
@test stringify!(str) == "isnan.(a)"
@test stringify!(fmt) == "isnan({2:s})"
end
ex = :(isnan.(a = 1))
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:(Ref(1))])
@test res == Expr(:., esc(:isnan), Expr(:tuple, Expr(:kw, :a, :(ARG[1].x))))
@test stringify!(str) == "isnan.(a=1)"
@test stringify!(fmt) == "isnan(a={1:s})"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == esc.([:(Ref(1)), :(Ref(1))])
@test res == Expr(:., esc(:isnan), Expr(:tuple, Expr(:kw, :a, :(ARG[2].x))))
@test stringify!(str) == "isnan.(a=1)"
@test stringify!(fmt) == "isnan(a={2:s})"
end
ex = :(isnan.())
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([])
@test res == Expr(:., esc(:isnan), Expr(:tuple))
@test stringify!(str) == "isnan.()"
@test stringify!(fmt) == "isnan()"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == esc.([])
@test res == Expr(:., esc(:isnan), Expr(:tuple))
@test stringify!(str) == "isnan.()"
@test stringify!(fmt) == "isnan()"
end
ex = :(isapprox.(a, b, atol=1))
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b, :(Ref(1))])
@test res == Expr(:., esc(:isapprox), Expr(:tuple, :(ARG[1]), :(ARG[2]), Expr(:kw, :atol, :(ARG[3].x))))
@test stringify!(str) == "isapprox.(a, b, atol=1)"
@test stringify!(fmt) == "isapprox({1:s}, {2:s}, atol={3:s})"
res, str, fmt = escape!(ex, args; outmost=false)
@test args == esc.([:a, :b, :(Ref(1)), :a, :b, :(Ref(1))])
@test res == Expr(:., esc(:isapprox), Expr(:tuple, :(ARG[4]), :(ARG[5]), Expr(:kw, :atol, :(ARG[6].x))))
@test stringify!(str) == "isapprox.(a, b, atol=1)"
@test stringify!(fmt) == "isapprox({4:s}, {5:s}, atol={6:s})"
end
ex = :(isapprox.(a, b, atol=1, rtol=1))
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :b, :(Ref(1)), :(Ref(1))])
@test res == Expr(:., esc(:isapprox), Expr(:tuple, :(ARG[1]), :(ARG[2]), Expr(:kw, :atol, :(ARG[3].x)), Expr(:kw, :rtol, :(ARG[4].x))))
@test stringify!(str) == "isapprox.(a, b, atol=1, rtol=1)"
@test stringify!(fmt) == "isapprox({1:s}, {2:s}, atol={3:s}, rtol={4:s})"
end
end
@testset "complicated expressions" begin
ex = :(a .& f.(b) .& .!isnan.(x) .& .≈(y, z, atol=TOL))
@testset "ex: $ex" begin
args = Expr[]
res, str, fmt = escape!(ex, args; outmost=true)
@test args == esc.([:a, :(f.(b)), :x, :y, :z, :(Ref(TOL))])
inner_res1 = :(ARG[1])
inner_res2 = Expr(:call, esc(:.&), inner_res1, :(ARG[2]))
inner_res3 = Expr(:call, esc(:.!), Expr(:., esc(:isnan), Expr(:tuple, :(ARG[3]))))
inner_res4 = Expr(:call, esc(:.&), inner_res2, inner_res3)
inner_res5 = Expr(:call, esc(:.≈), :(ARG[4]), :(ARG[5]), Expr(:kw, :atol, :(ARG[6].x)))
@test res == Expr(:call, esc(:.&), inner_res4, inner_res5)
@test stringify!(str) == "a .& f.(b) .& .!isnan.(x) .& .≈(y, z, atol=TOL)"
@test stringify!(fmt) == "{1:s} & {2:s} & !isnan({3:s}) & ≈({4:s}, {5:s}, atol={6:s})"
end
end
@testset "styling" begin
f = ex -> begin
args = Expr[]
_, str, fmt = PT.recurse_process!(ex, args; outmost=true)
PT.stringify!(str), PT.stringify!(fmt)
end
PT.enable_failure_styling()
# Base case
str, fmt = f(:(a))
@test occursin(ansire("\ea\e"), str)
@test occursin(ansire("\e{1:s}\e"), fmt)
str, fmt = f(:(a .+ b))
@test occursin(ansire("\ea \\.\\+ b\e"), str)
@test occursin(ansire("\e{1:s}\e"), fmt)
str, fmt = f(:(g.(x, a=1)))
@test occursin(ansire("\eg\\.\\(x, a = 1\\)\e"), str)
@test occursin(ansire("\e{1:s}\e"), fmt)
str, fmt = f(:([1,2,3]))
@test occursin(ansire("\e\\[1, 2, 3\\]\e"), str)
@test occursin(ansire("\e{1:s}\e"), fmt)
# keywords
str, fmt = f(Expr(:kw, :a, 1))
@test occursin(ansire("a=\e1\e"), str)
@test occursin(ansire("a=\e{1:s}\e"), fmt)
str, fmt = f(Expr(:kw, :atol, :(1+TOL)))
@test occursin(ansire("atol=\e1 \\+ TOL\e"), str)
@test occursin(ansire("atol=\e{1:s}\e"), fmt)
# negation
str, fmt = f(:(.!a))
@test occursin(ansire("\\.!\ea\e"), str)
# logical
str, fmt = f(:(a .& b))
@test occursin(ansire("\ea\e \\.& \eb\e"), str)
@test occursin(ansire("\e{1:s}\e & \e{2:s}\e"), fmt)
str, fmt = f(:(a .| b .⊻ c))
@test occursin(ansire("\ea\e \\.| \eb\e .⊻ \ec\e"), str)
@test occursin(ansire("\e{1:s}\e | \e{2:s}\e ⊻ \e{3:s}\e"), fmt)
# comparison
str, fmt = f(:(a .& b .| c))
@test occursin(ansire("\ea\e \\.& \eb\e \\.| \ec\e"), str)
@test occursin(ansire("\e{1:s}\e & \e{2:s}\e | \e{3:s}\e"), fmt)
# approx
str, fmt = f(:(.≈(a, b, atol=10*TOL)))
@test occursin(ansire("\\.≈\\(\ea\e, \eb\e, atol=\e10TOL\e\\)"), str)
@test occursin(ansire("\e{1:s}\e ≈ \e{2:s}\e \\(atol=\e{3:s}\e\\)"), fmt)
# displayable function
str, fmt = f(:(isnan.(x)))
@test occursin(ansire("isnan\\.\\(\ex\e\\)"), str)
@test occursin(ansire("isnan\\(\e{1:s}\e\\)"), fmt)
str, fmt = f(:(isnan.(x, a=1)))
@test occursin(ansire("isnan\\.\\(\ex\e, a=\e1\e\\)"), str)
@test occursin(ansire("isnan\\(\e{1:s}\e, a=\e{2:s}\e\\)"), fmt)
PT.disable_failure_styling()
end
end
@testset "printing utilities" begin
@testset "get/set max print failures" begin
@test_throws AssertionError PT.set_max_print_failures(-1)
PT.set_max_print_failures(10)
@test PT.set_max_print_failures(5) == 10
@test PT.set_max_print_failures(nothing) == 5
@test PT.set_max_print_failures() == typemax(Int)
end
@testset "stringify_idxs()" begin
I = CartesianIndex
@test PT.stringify_idxs([1,2,3]) == ["1", "2", "3"]
@test PT.stringify_idxs([1,100,10]) == [" 1", "100", " 10"]
@test PT.stringify_idxs([I(1,1), I(1,10), I(100,1)]) == [
" 1, 1", " 1,10", "100, 1"]
end
@testset "print_failures()" begin
printfunc = (args...) -> sprint(PT.print_failures, args...)
# Without abbreviating output
f = (io, idx) -> print(io, 2 * idx)
@test printfunc(1:3, f) == "\n[1]: 2\n[2]: 4\n[3]: 6"
@test printfunc(1:3, f, "*") == "\n*[1]: 2\n*[2]: 4\n*[3]: 6"
f = (io, idx) -> print(io, sum(idx.I))
idxs = CartesianIndex.([(1,10), (10,1)])
@test printfunc(idxs, f) == "\n[ 1,10]: 11\n[10, 1]: 11"
# With abbreviating output
f = (io, idx) -> print(io, idx)
PT.set_max_print_failures(5)
@test printfunc(1:9, f) == "\n[1]: 1\n[2]: 2\n[3]: 3\n⋮\n[8]: 8\n[9]: 9"
PT.set_max_print_failures(2)
@test printfunc(1:9, f) == "\n[1]: 1\n⋮\n[9]: 9"
PT.set_max_print_failures(1)
@test printfunc(1:9, f, "*") == "\n*[1]: 1\n*⋮"
PT.set_max_print_failures(0)
@test printfunc(1:9, f) == ""
PT.set_max_print_failures(10)
end
@testset "NonBoolTypeError" begin
f = evaled -> destyle(PT.NonBoolTypeError(evaled).msg)
# Non-array
@test f(1) == "1 ===> $Int"
@test f(:a) == "a ===> Symbol"
@test f(TestStruct(1, π)) == "S(1, 3.14159) ===> TestStruct"
@test f(Set{Int16}(1:1)) == "Set([1]) ===> Set{Int16}"
# Arrays
msg = f([1,2])
@test contains(msg, "2-element Vector{$Int} with 2 non-Boolean values:")
@test contains(msg, "[1]: 1 ===> $Int\n")
@test contains(msg, "[2]: 2 ===> $Int")
msg = f([true, :a, false, TestStruct(1, π)])
@test contains(msg, "4-element Vector{Any} with 2 non-Boolean values:")
@test contains(msg, "[2]: :a ===> Symbol")
@test contains(msg, "[4]: S(1, 3.14159) ===> TestStruct")
msg = f(1:3)
@test contains(msg, "3-element UnitRange{$Int} with 3 non-Boolean values:")
end
end
@testset "eval_test_all()" begin
@testset "method error when evaling all()" begin
f = (evaled) -> PT.eval_test_all(evaled, [evaled], "", LineNumberNode(1))
cases = [
:a,
TestStruct(1,1)
]
@testset "evaled: $case" for case in cases
@test_throws MethodError f(case)
end
end
@testset "non-Boolean in evaled argument" begin
f = (evaled) -> PT.eval_test_all(evaled, [evaled], "", LineNumberNode(1))
cases = [
1,
1:3,
[true, :a],
[TestStruct(1,1), false],
]
@testset "evaled: $case" for case in cases
@test_throws PT.NonBoolTypeError f(case)
end
end
@testset "passing all()" begin
f = (evaled) -> PT.eval_test_all(evaled, [evaled], "", LineNumberNode(1))
cases = [
true,
[true, true],
1 .== [1,1],
Set([]),
Set([true]),
Dict([]),
.≈(1, [1, 2], atol=2)
]
@testset "evaled: $case" for case in cases
res = f(case)
@test res isa Test.Returned
@test res.value === true
@test res.data === nothing
end
end
f = (evaled, terms, fmt) -> begin
res = PT.eval_test_all(evaled, terms, fmt, LineNumberNode(1))
@assert res isa Test.Returned
return destyle(res.data)
end
@testset "evaled === false" begin
msg = f(1 .== 2, [1, 2], "{1:s} == {2:s}")
@test startswith(msg, "false")
@test contains(msg, "Argument: 1 == 2 ===> false")
end
@testset "evaled isa BitArray" begin
a, b = [1,1], [1,2]
msg = f(a .== b, [a, b], "{1:s} == {2:s}")
@test startswith(msg, "false")
@test contains(msg, "Argument: 2-element BitVector, 1 failure:")
@test contains(msg, "[2]: 1 == 2 ===> false")
a, b = 1, [1, 2, missing]
msg = f(a .== b, [a, b], "{1:s} == {2:s}")
@test startswith(msg, "false")
@test occursin(r"Argument: 3-element Vector.*, 1 missing and 1 failure:", msg)
@test contains(msg, "[2]: 1 == 2 ===> false")
@test contains(msg, "[3]: 1 == missing ===> missing")
end
end
@testset "@test_all" begin
@testset "Pass" begin
a = [1,2,3]
b = a .+ 0.01
c = a .+ 1e-10
TOL = 0.1
@test_all true
@test_all fill(true, 5)
@test_all Dict()
@test_all Set([true])
@test_all a .=== a
@test_all a .== 1:3
@test_all a .<= b
@test_all 5:7 .>= b
@test_all a .≈ c
@test_all a .≉ b
@test_all [Real, Integer] .>: Int16
@test_all [1:2, 1:3, 1:4] .⊆ Ref(0:5)
@test_all occursin.(r"a|b", ["aa", "bb", "ab"])
@test_all a .≈ b atol=TOL
@test_all a .≉ b atol=1e-8
@test_all Bool[1,0,1] .| Bool[1,1,0]
@test_all Bool[1,0,0] .⊻ Bool[0,1,0] .⊻ Bool[0,0,1]
end
@testset "Fail" begin
messages = []
let fails = @testset NoThrowTestSet begin
# 1
@test_all 1:3 .== 2:4
push!(messages, [
"Expression: all(1:3 .== 2:4)",
"Evaluated: false",
"Argument: 3-element BitVector, 3 failures:",
"[1]: 1 == 2 ===> false",
"[2]: 2 == 3 ===> false",
"[3]: 3 == 4 ===> false",
])
# 2
@test_all [1 2] .== [1, 2]
push!(messages, [
"Expression: all([1 2] .== [1, 2])",
"Evaluated: false",
"Argument: 2×2 BitMatrix, 2 failures:",
"[2,1]: 1 == 2 ===> false",
"[1,2]: 2 == 1 ===> false",
])
# 3
a, b = Bool[1,0], Bool[1,1]
@test_all a .⊻ b
push!(messages, [
"Expression: all(a .⊻ b)",
"Evaluated: false",
"Argument: 2-element BitVector, 1 failure:",
"[1]: true ⊻ true ===> false",
])
# 4
@test_all 1:4 .∈ Ref(1:3)
push!(messages, [
"Expression: all(1:4 .∈ Ref(1:3))",
"Evaluated: false",
"Argument: 4-element BitVector, 1 failure:",
"[4]: 4 ∈ 1:3 ===> false",
])
# 5
a = Set([false])
@test_all a
push!(messages, [
"Expression: all(a)",
"Evaluated: false",
"Argument: Set{Bool} with 1 element, 1 failure",
])
# 6
a = [1,2,missing]
@test_all a .== 1
push!(messages, [
"Expression: all(a .== 1)",
"Evaluated: false",
"Argument: 3-element Vector{Union{Missing, Bool}}, 1 missing and 1 failure:",
"[2]: 2 == 1 ===> false",
"[3]: missing == 1 ===> missing",
])
# 7
@test_all 1 .== 2
push!(messages, [
"Expression: all(1 .== 2)",
"Evaluated: false",
"Argument: 1 == 2 ===> false",
])
# 8
a = [1,NaN,3]
@test_all .!isnan.(a)
push!(messages, [
"Expression: all(.!isnan.(a))",
"Evaluated: false",
"Argument: 3-element BitVector, 1 failure:",
"[2]: !isnan(NaN) ===> false",
])
# 9
a = [0.9, 1.0, 1.1]
@test_all a .≈ 1 atol=1e-2
push!(messages, [
"Expression: all(.≈(a, 1, atol=0.01))",
"Evaluated: false",
"Argument: 3-element BitVector, 2 failures:",
"[1]: 0.9 ≈ 1 (atol=0.01) ===> false",
"[3]: 1.1 ≈ 1 (atol=0.01) ===> false",
])
# 10
@test_all false
push!(messages, [
"Expression: all(false)",
"Evaluated: false",
"Argument: false ===> false",
])
# 11
a = [[1,2], 1, 1:2]
@test_all a .== Ref(1:2)
push!(messages, [
"Expression: all(a .== Ref(1:2))",
"Evaluated: false",
"Argument: 3-element BitVector, 1 failure:",
"[2]: 1 == 1:2 ===> false",
])
# 12
@test_all [1] .== missing
push!(messages, [
"Expression: all([1] .== missing)",
"Evaluated: missing",
"Argument: 1-element Vector{Missing}, 1 missing:",
"[1]: 1 == missing ===> missing",
])
# 13
@test_all 1 .== missing
push!(messages, [
"Expression: all(1 .== missing)",
"Evaluated: missing",
"Argument: 1 == missing ===> missing",
])
# 14
a = [-1, 2, 1]
@test_all ifelse.(a .< 0, -a .% 2, a .% 2) .== 1
push!(messages, [
"Expression: all(ifelse.(a .< 0, -a .% 2, a .% 2) .== 1)",
"Evaluated: false",
"Argument: 3-element BitVector, 1 failure:",
"[2]: ifelse(2 < 0, 0, 0) == 1 ===> false",
])
end
@testset "ex[$i]: $(fail.orig_expr)" for (i, fail) in enumerate(fails)
@test fail isa Test.Fail
@test fail.test_type === :test
str = sprint(show, fail)
for msg in messages[i]
@test contains(str, msg)
end
end
end # let fails
end
@testset "skip/broken=false" begin
a = 1
@test_all 1 .== 1 broken=false
@test_all 1 .== 1 skip=false
@test_all 1 .== 1 broken=a==2
@test_all 1 .== 1 skip=!isone(1)
end
@testset "skip=true" begin
let skips = @testset NoThrowTestSet begin
# 1
@test_all 1 .== 1 skip=true
# 2
@test_all 1 .== 2 skip=true
# 3
@test_all 1 .== error("fail gracefully") skip=true
end
@testset "skipped[$i]" for (i, skip) in enumerate(skips)
@test skip isa Test.Broken
@test skip.test_type === :skipped
end
end # let skips
end
@testset "broken=true" begin
let brokens = @testset NoThrowTestSet begin
# 1
@test_all 1 .== 2 broken=true
# 2
@test_all 1 .== error("fail gracefully") broken=true
end
@testset "broken[$i]" for (i, broken) in enumerate(brokens)
@test broken isa Test.Broken
@test broken.test_type === :test
end
end # let brokens
let unbrokens = @testset NoThrowTestSet begin
# 1
@test_all 1 .== 1 broken=true
end
@testset "unbroken[$i]" for (i, unbroken) in enumerate(unbrokens)
@test unbroken isa Test.Error
@test unbroken.test_type === :test_unbroken
end
end # let unbrokens
end
@testset "Error" begin
messages = []
let errors = @testset NoThrowTestSet begin
# 1
@test_all A
push!(messages, ["UndefVarError:"])
# 2
@test_all sqrt.([1,-1])
push!(messages, ["DomainError"])
# 3
@test_all error("fail ungracefully")
push!(messages, ["fail ungracefully"])
# 4
end
@testset "error[$i]" for (i, error) in enumerate(errors)
@test error isa Test.Error
@test error.test_type === :test_error
for msg in messages[i]
@test contains(sprint(show, error), msg)
end
end
end
end
@testset "evaluate arguments once" begin
g = Int[]
f = (x) -> (push!(g, 1); x)
@test_all f([1,2]) .== 1:2
@test g == [1]
empty!(g)
@test_all occursin.(r"a|b", f(["aa", "bb", "ab"]))
@test g == [1]
end
end
end | PrettyTests | https://github.com/tpapalex/PrettyTests.jl.git |
|
[
"MIT"
] | 0.1.1 | 731532d7a03845a784a5a5e4e9a7b4993830032c | code | 19910 | @testset "test_sets.jl" begin
@testset "printing utilities" begin
@testset "printL/R" begin
fLR = (args...) -> destyle(sprint(PT.printLsepR, args...))
@test fLR("L", "sep", "R") == "L sep R"
@test fLR("L", "sep", "R", " suffix") == "L sep R suffix"
end
@testset "printset()" begin
f = v -> sprint(PT.printset, v, "set", context = PT.failure_ioc())
@test contains(f([1]), "set has 1 element: [1]")
@test contains(f([2,3]), "set has 2 elements: [2, 3]")
@test contains(f(Set([4])), "set has 1 element: [4]")
@test occursin(r"set has 2 elements: \[(5|6), (5|6)\]", f(Set([5,6])))
@test contains(f(Int32[7,8]), "set has 2 elements: [7, 8]")
@test contains(f(Set{Int32}([9])), "set has 1 element: [9]")
@test contains(f([1,π]), "set has 2 elements: [1.0, 3.14159]")
@test contains(f([TestStruct(1,π)]), "set has 1 element: [S(1, 3.14159)]")
end
@testset "stringify_expr_test_sets()" begin
f = PT.stringify_expr_test_sets
@test f(:(a == b)) == "a == b"
@test f(:(a ≠ b)) == "a ≠ b"
@test f(:(a ⊆ b)) == "a ⊆ b"
@test f(:(a ⊇ b)) == "a ⊇ b"
@test f(:(a ⊊ b)) == "a ⊊ b"
@test f(:(a ⊋ b)) == "a ⊋ b"
@test f(:(a ∩ b)) == "a ∩ b == ∅"
@test f(:(1:3 == 1:3)) == "1:3 == 1:3"
@test f(:(Set(3) ≠ [1 2 3])) == "Set(3) ≠ [1 2 3]"
@test f(:([1,2] ∩ [3,4])) == "[1, 2] ∩ [3, 4] == ∅"
# Check that output is styled
PT.enable_failure_styling()
@test ansioccursin("\ea\e == \eb\e", f(:(a == b)))
@test ansioccursin("\eset\e ∩ \earr\e == ∅", f(:(set ∩ arr)))
PT.disable_failure_styling()
end
end
@testset "process_expr_test_sets(ex)" begin
@testset "valid expressions" begin
cases = [
# Left as is
:(L == R) => :(L == R),
:(L ≠ R) => :(L ≠ R),
:(L ⊆ R) => :(L ⊆ R),
:(L ⊇ R) => :(L ⊇ R),
:(L ⊊ R) => :(L ⊊ R),
:(L ⊋ R) => :(L ⊋ R),
:(L ∩ R) => :(L ∩ R),
# Converted
:(L != R) => :(L ≠ R),
:(L ⊂ R) => :(L ⊆ R),
:(L ⊃ R) => :(L ⊇ R),
:(L || R) => :(L ∩ R),
:(issetequal(L, R)) => :(L == R),
:(isdisjoint(L, R)) => :(L ∩ R),
:(issubset(L, R)) => :(L ⊆ R),
# Disjoint syntactic sugar
:(L ∩ R == ∅) => :(L ∩ R),
:(∅ == L ∩ R) => :(L ∩ R),
]
@testset "$ex" for (ex, res) in cases
@test PT.process_expr_test_sets(ex) == res
end
end
@testset "unsupported operator" begin
cases = [
:(a <= b),
:(a .== b),
:(a ∈ b),
:(a ∪ b),
:(a | b)
]
@testset "$ex" for ex in cases
@test_throws ErrorException("invalid test macro call: @test_set unsupported set operator $(ex.args[1])") PT.process_expr_test_sets(ex)
end
end
@testset "invalid expression" begin
cases = [
:(a && b),
:(a == b == c),
:(g(a, b)),
]
@testset "$ex" for ex in cases
@test_throws ErrorException("invalid test macro call: @test_set $ex") PT.process_expr_test_sets(ex)
end
end
end
@testset "eval_test_sets()" begin
@testset "op: ==" begin
f = (lhs, rhs) -> PT.eval_test_sets(lhs, :(==), rhs, LineNumberNode(1))
res = f(Set([1,2,3]), [1,2,3])
@test res.value === true
res = f([2,1,2], [1,2,1,2])
@test res.value === true
res = f([1,2,3], Set([1,2]))
@test res.value === false
@test startswith(res.data, "L and R are not equal.")
@test contains(res.data, "L ∖ R has 1 element: [3]")
@test contains(res.data, "R ∖ L has 0 elements: []")
res = f(4:6, 1:9)
@test res.value === false
@test startswith(res.data, "L and R are not equal.")
@test contains(res.data, "L ∖ R has 0 elements: []")
@test occursin(r"R ∖ L has 6 elements: \[(\d, ){5}\d]", res.data)
end
@testset "op: ≠" begin
f = (lhs, rhs) -> PT.eval_test_sets(lhs, :≠, rhs, LineNumberNode(1))
res = f([1,2,3], Set([1,2]))
@test res.value === true
res = f([1,2,3], [1,1,1])
@test res.value === true
res = f([1,2,3], Set([3,2,1]))
@test res.value === false
@test startswith(res.data, "L and R are equal.")
@test contains(res.data, "L = R has 3 elements: [1, 2, 3]")
res = f([2,1,1,1,1], [1,2])
@test res.value === false
@test startswith(res.data, "L and R are equal.")
@test contains(res.data, "L = R has 2 elements: [2, 1]")
end
@testset "op: ⊆" begin
f = (lhs, rhs) -> PT.eval_test_sets(lhs, :⊆, rhs, LineNumberNode(1))
res = f([1,2,3], [1,2,3])
@test res.value === true
res = f([1,2], Set([1,2,3]))
@test res.value === true
res = f([1,2,2,1], 1:5)
@test res.value === true
res = f([1,2,3], Set([2,1]))
@test res.value === false
@test startswith(res.data, "L is not a subset of R.")
@test contains(res.data, "L ∖ R has 1 element: [3]")
res = f(4:-1:1, [1,2])
@test res.value === false
@test startswith(res.data, "L is not a subset of R.")
@test contains(res.data, "L ∖ R has 2 elements: [4, 3]")
end
@testset "op: ⊇" begin
f = (lhs, rhs) -> PT.eval_test_sets(lhs, :⊇, rhs, LineNumberNode(1))
res = f([1,2,3], [1,2,3])
@test res.value === true
res = f(Set([1,2,3]), [1,2])
@test res.value === true
res = f(1:5, [1,2,2,1])
@test res.value === true
res = f(Set([2,1]), [1,2,3])
@test res.value === false
@test startswith(res.data, "L is not a superset of R.")
@test contains(res.data, "R ∖ L has 1 element: [3]")
res = f([1,2], 4:-1:1)
@test res.value === false
@test startswith(res.data, "L is not a superset of R.")
@test contains(res.data, "R ∖ L has 2 elements: [4, 3]")
end
@testset "op: ⊊" begin
f = (lhs, rhs) -> PT.eval_test_sets(lhs, :⊊, rhs, LineNumberNode(1))
res = f([1,2], [1,2,3])
@test res.value === true
res = f(1:5, 0:10)
@test res.value === true
res = f([1,3,2,3], [1,2,3,1])
@test res.value === false
@test startswith(res.data, "L is not a proper subset of R, it is equal.")
@test contains(res.data, "L = R has 3 elements: [1, 3, 2]")
res = f(Set([1,2,3]), [1,2])
@test res.value === false
@test startswith(res.data, "L is not a proper subset of R.")
@test contains(res.data, "L ∖ R has 1 element: [3]")
res = f([1,2,4,1,1,3], [1,2])
@test res.value === false
@test startswith(res.data, "L is not a proper subset of R.")
@test contains(res.data, "L ∖ R has 2 elements: [4, 3]")
end
@testset "op: ⊋" begin
f = (lhs, rhs) -> PT.eval_test_sets(lhs, :⊋, rhs, LineNumberNode(1))
res = f([1,2,3], [1,2])
@test res.value === true
res = f(0:10, 1:5)
@test res.value === true
res = f([1,2,3,1], [1,3,2,3])
@test res.value === false
@test startswith(res.data, "L is not a proper superset of R, it is equal.")
@test contains(res.data, "L = R has 3 elements: [1, 2, 3]")
res = f([1,2], Set([1,2,3]))
@test res.value === false
@test startswith(res.data, "L is not a proper superset of R.")
@test contains(res.data, "R ∖ L has 1 element: [3]")
res = f([1,2], [1,2,4,1,1,3])
@test res.value === false
@test startswith(res.data, "L is not a proper superset of R.")
@test contains(res.data, "R ∖ L has 2 elements: [4, 3]")
end
@testset "op: ∩" begin
f = (lhs, rhs) -> PT.eval_test_sets(lhs, :∩, rhs, LineNumberNode(1))
res = f([1,2,3], [4,5])
@test res.value === true
res = f(1:5, 6:10)
@test res.value === true
res = f(1, [3,4])
@test res.value === true
res = f([1,2,3], [3,4])
@test res.value === false
@test startswith(res.data, "L and R are not disjoint.")
@test contains(res.data, "L ∩ R has 1 element: [3]")
res = f(1:5, 3:8)
@test res.value === false
@test startswith(res.data, "L and R are not disjoint.")
@test contains(res.data, "L ∩ R has 3 elements: [3, 4, 5]")
end
@testset "styling" begin
# Brief examples to test styling
PT.enable_failure_styling()
f = (lhs, op, rhs) -> PT.eval_test_sets(lhs, op, rhs, LineNumberNode(1)).data
@test ansioccursin("\eL\e and \eR\e are not equal.", f([1,2], :(==), [2,3]))
@test ansioccursin("\eL\e and \eR\e are equal.", f([1,2], :≠, [2,1]))
@test ansioccursin("\eL\e is not a subset of \eR\e.", f([1,2], :⊆, [2,3]))
@test ansioccursin("\eL\e is not a superset of \eR\e.", f([1,2], :⊇, [2,3]))
@test ansioccursin("\eL\e is not a proper subset of \eR\e, it is equal.", f([1,2], :⊊, [2,1]))
@test ansioccursin("\eL\e is not a proper subset of \eR\e.", f([1,2], :⊊, [2,3]))
@test ansioccursin("\eL\e is not a proper superset of \eR\e, it is equal.", f([1,2], :⊋, [2,1]))
@test ansioccursin("\eL\e is not a proper superset of \eR\e.", f([1,2], :⊋, [2,3]))
@test ansioccursin("\eL\e and \eR\e are not disjoint.", f([1,2], :∩, [2,3]))
PT.disable_failure_styling()
end
end
@testset "@test_sets" begin
@testset "Pass" begin
@test_sets 1:2 == [2,1]
@test_sets [1,1] == Set(1)
@test_sets issetequal([1,3,3,1], 1:2:3)
@test_sets ∅ == ∅
@test_sets [1,2] != 1:3
@test_sets Set(1:3) ≠ 2
@test_sets ∅ ≠ [1 2]
@test_sets 1:2 ⊆ [1,2]
@test_sets 3 ⊂ Set(3)
@test_sets issubset([1,2],0:100)
@test_sets ∅ ⊆ 1:2
@test_sets [1,2] ⊇ 1:2
@test_sets Set(3) ⊃ [3]
@test_sets 0:100 ⊇ [42,42]
@test_sets 1:2 ⊇ ∅
@test_sets [1,2] ⊊ 1:3
@test_sets 1 ⊊ [1,2,1]
@test_sets [3] ⊊ Set(1:3)
@test_sets ∅ ⊊ 1
@test_sets [1,2,3] ⊋ 1:2
@test_sets 1:100 ⊋ [42,42]
@test_sets Set(1:3) ⊋ [3]
@test_sets 1 ⊋ ∅
@test_sets [1,2,3] ∩ [4,5]
@test_sets 1:5 || 6:8
@test_sets isdisjoint(3, Set([1,2]))
@test_sets ∅ ∩ ∅ == ∅
@test_sets isdisjoint(∅, 1:2)
@test_sets 1 ∩ [2,3] == ∅
@test_sets ∅ == [4,5] ∩ Set(6)
end
@testset "Fail" begin
messages = []
let fails = @testset NoThrowTestSet begin
# 1
@test_sets [1,2,3] == [1,2,3,4]
push!(messages, [
"Expression: [1, 2, 3] == [1, 2, 3, 4]",
"Evaluated: L and R are not equal.",
])
# 2
a, b = 1, 1
@test_sets a ≠ b
push!(messages, [
"Expression: a ≠ b",
"Evaluated: L and R are equal.",
])
# 3
a = [3,2,1,3,2,1]
@test_sets a ⊆ 2:3
push!(messages, [
"Expression: a ⊆ 2:3",
"Evaluated: L is not a subset of R.",
])
# 4
@test_sets 2:4 ⊇ 1:5
push!(messages, [
"Expression: 2:4 ⊇ 1:5",
"Evaluated: L is not a superset of R.",
])
# 5
b = 1:3
@test_sets [1,2,3] ⊊ b
push!(messages, [
"Expression: [1, 2, 3] ⊊ b",
"Evaluated: L is not a proper subset of R, it is equal.",
])
# 6
@test_sets 1:4 ⊊ 1:3
push!(messages, [
"Expression: 1:4 ⊊ 1:3",
"Evaluated: L is not a proper subset of R.",
])
# 7
SET = Set([5,5,5,6])
@test_sets SET ⊋ [6,5]
push!(messages, [
"Expression: SET ⊋ [6, 5]",
"Evaluated: L is not a proper superset of R, it is equal.",
])
# 8
@test_sets (1,1,1,2) ⊋ (3,2)
push!(messages, [
"Expression: (1, 1, 1, 2) ⊋ (3, 2)",
"Evaluated: L is not a proper superset of R.",
])
# 9
@test_sets [1,1,1,2] ∩ [3,2]
push!(messages, [
"Expression: [1, 1, 1, 2] ∩ [3, 2] == ∅",
"Evaluated: L and R are not disjoint.",
])
# 10
a = [1,2,3]
@test_sets a != [1,2,3]
push!(messages, [
"Expression: a ≠ [1, 2, 3]",
"Evaluated: L and R are equal.",
])
# 11
@test_sets 4 ⊂ Set(1:3)
push!(messages, [
"Expression: 4 ⊆ Set(1:3)",
"Evaluated: L is not a subset of R.",
])
# 12
a = Set(1:3)
@test_sets a ⊃ 4
push!(messages, [
"Expression: a ⊇ 4",
"Evaluated: L is not a superset of R.",
])
# 13
@test_sets 1:3 || 2:4
push!(messages, [
"Expression: 1:3 ∩ 2:4 == ∅",
"Evaluated: L and R are not disjoint.",
])
# 14
a = [1]
@test_sets issetequal(a, 2)
push!(messages, [
"Expression: a == 2",
"Evaluated: L and R are not equal.",
])
# 15
@test_sets isdisjoint(1, 1)
push!(messages, [
"Expression: 1 ∩ 1 == ∅",
"Evaluated: L and R are not disjoint.",
])
# 16
@test_sets issubset(1:5, 3)
push!(messages, [
"Expression: 1:5 ⊆ 3",
"Evaluated: L is not a subset of R.",
])
# 17
@test_sets ∅ ⊋ ∅
push!(messages, [
"Expression: ∅ ⊋ ∅",
"Evaluated: L is not a proper superset of R, it is equal.",
])
# 18
@test_sets ∅ == 1:5
push!(messages, [
"Expression: ∅ == 1:5",
"Evaluated: L and R are not equal.",
])
end
@testset "ex[$i]: $(fail.orig_expr)" for (i, fail) in enumerate(fails)
@test fail isa Test.Fail
@test fail.test_type === :test
str = destyle(sprint(show, fail))
for msg in messages[i]
@test contains(str, msg)
end
end
end # let fails
end
@testset "skip/broken=false" begin
a = 1
@test_sets 1 == 1 broken=false
@test_sets 1 == 1 skip=false
@test_sets 1 == 1 broken=a==2
@test_sets 1 == 1 skip=!isone(1)
end
@testset "skip=true" begin
let skips = @testset NoThrowTestSet begin
# 1
@test_sets 1 == 1 skip=true
# 2
@test_sets 1 == 2 skip=true
# 3
@test_sets 1 == error("fail gracefully") skip=true
end
@testset "skipped[$i]" for (i, skip) in enumerate(skips)
@test skip isa Test.Broken
@test skip.test_type === :skipped
end
end # let skips
end
@testset "broken=true" begin
let brokens = @testset NoThrowTestSet begin
# 1
@test_sets 1 == 2 broken=true
# 2
@test_sets 1 == error("fail gracefully") broken=true
end
@testset "broken[$i]" for (i, broken) in enumerate(brokens)
@test broken isa Test.Broken
@test broken.test_type === :test
end
end # let brokens
let unbrokens = @testset NoThrowTestSet begin
# 1
@test_sets 1 == 1 broken=true
end
@testset "unbroken[$i]" for (i, unbroken) in enumerate(unbrokens)
@test unbroken isa Test.Error
@test unbroken.test_type === :test_unbroken
end
end # let unbrokens
end
@testset "Error" begin
messages = []
let errors = @testset NoThrowTestSet begin
# 1
@test_sets A == B
push!(messages, "UndefVarError")
# 2
@test_sets sqrt(-1) == 3
push!(messages, "DomainError")
# 3
@test_sets 3 == error("fail ungracefully")
push!(messages, "fail ungracefully")
end
@testset "error[$i]" for (i, error) in enumerate(errors)
@test error isa Test.Error
@test error.test_type === :test_error
@test contains(sprint(show, error), messages[i])
end
end
end
@testset "evaluate arguments once" begin
g = Int[]
f = (x) -> (push!(g, x); x)
@test_sets f(1) == 1
@test g == [1]
empty!(g)
@test_sets 1 ≠ f(2)
@test g == [2]
end
end
end | PrettyTests | https://github.com/tpapalex/PrettyTests.jl.git |
|
[
"MIT"
] | 0.1.1 | 731532d7a03845a784a5a5e4e9a7b4993830032c | docs | 1751 | # PrettyTests.jl
[](https://tpapalex.github.io/PrettyTests.jl/dev/)
[](https://github.com/tpapalex/PrettyTests.jl/actions/workflows/CI.yml?query=branch%3Amain)
A Julia package that provides `@test`-like macros with more informative error messages.
The inspiration comes from `python` [asserts](https://docs.python.org/3/library/unittest.html#assert-methods), which customize their error message based on the type of unit test being performed; for example, by showing the differences between two sets or lists that should be equal.
`PrettyTests` exports drop-in replacements for `@test` that are designed to (a) provide concise error messages tailored to specific situations, and (b) conform with the standard [`Test`](https://docs.julialang.org/en/v1/stdlib/Test/) interface so that they fit into to any unit-testing workflow.
## Installation
The package requires Julia `1.7` or higher. It can be installed using Julia's package manager: first type `]` in the REPL, then:
```
pkg> add PrettyTests
```
## Example Usage
```@julia-repl
julia> @test_all [1, 2, 3] .< 2
Test Failed at none:1
Expression: all([1, 2, 3] .< 2)
Evaluated: false
Argument: 3-element BitVector, 2 failures:
[2]: 2 < 2 ===> false
[3]: 3 < 2 ===> false
julia> @test_sets [1, 2, 3] ∩ [2, 3, 4] == ∅
Test Failed at none:1
Expression: [1, 2, 3] ∩ [2, 3, 4] == ∅
Evaluated: L and R are not disjoint.
L ∩ R has 2 elements: [2, 3]
```
More details and functionalities are listed in the package [documentation](https://tpapalex.github.io/PrettyTests.jl/dev/).
| PrettyTests | https://github.com/tpapalex/PrettyTests.jl.git |
|
[
"MIT"
] | 0.1.1 | 731532d7a03845a784a5a5e4e9a7b4993830032c | docs | 19280 | ```@meta
CurrentModule = PrettyTests
```
# Home
[PrettyTests](https://github.com/tpapalex/PrettyTests.jl) extends Julia's basic
unit-testing functionality by providing drop-in replacements for [`Test.@test`]
(@extref Julia) with more informative error messages.
The inspiration for the package comes from [`python`](@extref python assert-methods)
and [`numpy` asserts](@extref numpy numpy.testing), which customize their error messages
depending on the type of test being performed; for example, by showing the
differences between two sets that should be equal or the number of elements that
differ in two arrays.
`PrettyTests` macros are designed to (a) provide clear and concise error messages
tailored to specific situations, and (b) conform with the standard
[`Test`](@extref Julia stdlib/Test) library interface, so that they can fit into any
testing workflow. This guide walks through several examples:
```@contents
Pages = ["index.md"]
Depth = 2:3
```
The package requires Julia `1.7` or higher, and can be installed in the usual way:
type `]` to enter the package manager, followed by `add PrettyTests`.
## `@test_sets` for set-like comparisons
### Set equality
The [`@test_sets`](@ref) macro is used to compare two set-like objects.
It accepts expressions of the form `@test_sets L <op> R`, where `op` is an infix set
comparison operator and `L` and `R` are collections, broadly defined.
In the simplest example, one could test for set equality with the (overloaded) `==`
operator:
```@setup test_sets
using PrettyTests, Test
PrettyTests.enable_failure_styling()
PrettyTests.set_max_print_failures(10)
mutable struct JustPrintTestSet <: Test.AbstractTestSet
results::Vector
JustPrintTestSet(desc) = new([])
end
function Test.record(ts::JustPrintTestSet, t::Test.Result)
str = sprint(show, t, context=:color=>true)
str = replace(str, r"Stacktrace:(.|\n)*$" => "Stacktrace: [...]")
println(str)
push!(ts.results, t)
return t
end
Test.finish(ts::JustPrintTestSet) = nothing
```
```@repl test_sets
a, b = [2, 1, 1], [1, 2];
@testset JustPrintTestSet begin # hide
@test_sets a == b
end # hide
```
This is equivalent to the more verbose `@test issetequal(a, b)`. It is also more
informative in the case of failure:
```@repl test_sets
@testset JustPrintTestSet begin # hide
@test_sets a == 2:4
end # hide
```
The failed test message lists exactly how many and which elements were in the set
differences `L \ R` and `R \ L`, which should have been empty in a passing test.
Note how the collections interpreted as `L` and `R` are color-coded (using ANSI
color escape codes) so that they can be easily identified if the expressions are long:
```@repl test_sets
variable_with_long_name = 1:3;
function_with_long_name = () -> 4:9;
@testset JustPrintTestSet begin # hide
@test_sets variable_with_long_name ∪ Set(4:6) == function_with_long_name()
end # hide
```
!!! info "Disable color output"
To disable colored subexpressions in failure messages use [`disable_failure_styling()`]
(@ref PrettyTests.disable_failure_styling).
The symbol `∅` (typed as `\emptyset<tab>`) can be used as shorthand for `Set()` in any
set expression:
```@repl test_sets
@testset JustPrintTestSet begin # hide
@test_sets Set() == ∅
end # hide
@testset JustPrintTestSet begin # hide
@test_sets [1,1] == ∅
end # hide
```
Because the macro internally expands the input expression to an
[`issetequal`](@extref Julia Base.issetequal) call
(and uses [`setdiff`](@extref Julia Base.setdiff) to print the differences),
it works very flexibly with general collections and iterables:
```@repl test_sets
@testset JustPrintTestSet begin # hide
@test_sets Dict() == Set()
end # hide
@testset JustPrintTestSet begin # hide
@test_sets "baabaa" == "abc"
end # hide
```
### Subsets
Set comparisons beyond equality are also supported, with modified error messages.
For example, [(as in base Julia)](@extref Julia Base.issubset), the expression `L ⊆ R`
is equivalent to `issubset(L, R)`:
```@repl test_sets
@testset JustPrintTestSet begin # hide
@test_sets "baabaa" ⊆ "abc"
end # hide
@testset JustPrintTestSet begin # hide
@test_sets (3, 1, 2, 3) ⊆ (1, 2)
end # hide
```
Note how, in this case, the failure displays only the set difference `L \ R` and omits the
irrelevant `R \ L`.
### Disjointness
The form `L ∩ R == ∅` is equivalent to [`isdisjoint`](@extref Julia Base.isdisjoint)`(L, R)`.
In the case of failure, the macro displays the non-empty intersection `L ∩ R`, as computed
by [intersect](@extref Julia Base.intersect):
```@repl test_sets
@testset JustPrintTestSet begin # hide
@test_sets (1, 2, 3) ∩ (4, 5, 6) == ∅
end # hide
@testset JustPrintTestSet begin # hide
@test_sets "baabaa" ∩ "abc" == ∅
end # hide
```
!!! info "Shorthand disjointness syntax"
Though slightly abusive in terms of notation, the macro will also accept `L ∩ R` and
`L || R` as shorthands for `isdisjoint(L, R)`:
```@repl test_sets
@testset JustPrintTestSet begin # hide
@test_sets "baabaa" ∩ "moooo"
end # hide
@testset JustPrintTestSet begin # hide
@test_sets (1,2) || (3,4)
end # hide
```
## `@test_all` for vectorized tests
### Basic usage
The [`@test_all`](@ref) macro is used for "vectorized"
[`@test`](@extref Julia Test.@test)s. The name derives from the fact that
`@test_all ex` will (mostly) behave like `@test all(ex)`:
```@setup test_all
using PrettyTests, Test
PrettyTests.enable_failure_styling()
PrettyTests.set_max_print_failures(10)
mutable struct JustPrintTestSet <: Test.AbstractTestSet
results::Vector
JustPrintTestSet(desc) = new([])
end
function Test.record(ts::JustPrintTestSet, t::Test.Result)
str = sprint(show, t, context=:color=>true)
str = replace(str, r"Stacktrace:(.|\n)*$" => "Stacktrace: [...]")
println(str)
push!(ts.results, t)
return t
end
#function Base.show(io::IO, t::Test.Fai)
Test.finish(ts::JustPrintTestSet) = nothing
```
```@repl test_all
a = [1, 2, 3, 4];
@testset JustPrintTestSet begin # hide
@test all(a .< 5)
end # hide
@testset JustPrintTestSet begin # hide
@test_all a .< 5
end # hide
```
With one important difference: `@test_all` does not
[short-circuit](@extref Julia Base.all-Tuple{Any}) when it encounters the first `false`
value. It evaluates the full expression and checks that *each element* is not `false`,
printing errors for each "individual" failure:
```@repl test_all
@testset JustPrintTestSet begin # hide
@test_all a .< 2
end # hide
```
The failure message can be parsed as follows:
- The expression `all(a .< 2)` evaluated to `false`
- The argument to `all()` was a `4-element BitVector`
- There were `3` failures, i.e. elements of the argument that were `false`
- These occured at indices `[2]`, `[3]` and `[4]`
Like [`@test`](@extref Julia Test.@test), the macro performed some
introspection to show an *unvectorized* (and color-coded) form of the expression
for each individual failure. For example, the failure at index `[4]` was because
`a[4] = 4`, and `4 < 2` evaluated to `false`.
!!! note "Why not `@testset` for ...?"
One could achieve a similar effect to `@test_all` by using the [`@testset for`]
(@extref Julia Test.@testset) syntax built in to [`Test`](@extref Julia stdlib/Test).
The test `@test_all a .< 2` is basically equivalent to:
```@julia
@testset for i in eachindex(a)
@test a[i] < 2
end
```
When the iteration is relatively simple, `@test_all` should be preferred for its
conciseness. It avoids the need for explicit indexing, e.g. `a[i]`, conforming with
Julia's intuitive broadcasting semantics.
More importantly, all relevant information about the test failures (i.e. how many
and which indices failed) are printed in a single, concise [`Test.Fail`](@extref Julia)
result rather than multiple, redundant messages in nested test sets.
The introspection goes quite a bit deeper than what [`@test`](@extref Julia Test.@test)
supports, handling pretty complicated expressions:
```@repl test_all
x, y, str, func = 2, 4.0, "baa", arg -> arg > 0;
@testset JustPrintTestSet begin # hide
@test_all (x .< 2) .| isnan.(y) .& .!occursin.(r"a|b", str) .| func(-1)
end # hide
```
Note also how, since `ex` evaluated to a scalar in this case, the failure message
ommitted the summary/indexing and printed just the single failure under `Argument:`.
!!! info "Disable color output"
To disable colored subexpressions in failure messages use [`disable_failure_styling()`]
(@ref PrettyTests.disable_failure_styling).
!!! details "Introspection mechanics"
To create individual failure messages, the `@test_all` parser recursively dives
through the [Abstract Syntax Tree (AST)](@extref Julia Surface-syntax-AST) of the
input expression and creates/combines [`python`-like format strings]
(https://github.com/JuliaString/Format.jl) for any of the following "displayable"
forms:
- `:comparison`s or `:call`s with vectorized comparison operators, e.g. `.==`, `.≈`,
`.∈`, etc.
- `:call`s to the vectorized negation operator `.!`
- `:call`s to vectorized bitwise logical operators, e.g. `.&`, `.|`, `.⊻`, `.⊽`
- `:.` (broadcast dot) calls to certain common functions, e.g. `isnan`, `contains`,
`occursin`, etc.
Any (sub-)expressions that do not fall into one of these categories are escaped and
collectively [`broadcast`](@extref Julia Base.Broadcast.broadcast), so that
elements can splatted into the format string at each failing index.
*Note:* Unvectorized forms are not considered displayable by the parser.
This is to avoid certain ambiguities with broadcasting under the current
implementation. This may be changed in future.
##### Example 1
```@repl test_all
x, y = 2, 1;
@testset JustPrintTestSet begin # hide
@test_all (x .< y) .& (x < y)
end # hide
```
In this example, the parser first receives the top-level expression
`(x .< y) .& (x < y)`, which it knows to display as `$f1 & $f2` in unvectorized form.
The sub-format strings `f1` and `f2` must then be determined by recursively parsing
the expressions on either side of `.&`.
On the left side, the sub-expression `x .< y` is also displayable as `($f11 < $f12)`
with format strings `f11` and `f22` given by further recursion. At this level, the
parser hits the base case, since neither `x` nor `y` are displayable forms. The two
expressions are escaped and used as the first and second broadcast arguments, while
the corresponding format strings `{1:s}` and `{2:s}` are passed back up the recursion
to create `f1` as `({1:s} < {2:s})`.
On the right side, `x < y` is *not* displayable (since it is unvectorized) and
therefore escaped as whole to make the third broadcasted argument. The corresponding
format string `{3:s}` is passed back up the recursion, and used as `f2`.
By the end, the parser has created the format string is `({1:s} < {2:s}) & {3:s}`,
with three corresponding expressions `x`, `y`, and `x < y`. Evaluating and collectively
broadcasting the latter results in the scalar 3-tuple `(2, 1, false)`, which matches the
dimension of the evaluated expression (`false`). Since this is a failure, the 3-tuple
is splatted into the format string to create the part of the message that reads
`(2 < 1) & false`.
##### Example 2
```@repl test_all
x, y = [5 6; 7 8], [5 6];
@testset JustPrintTestSet begin # hide
@test_all x .== y
end # hide
```
Here, the top-level expression `x .== y` is displayable, while the two sub-expressions
`x` and `y` are not. The parser creates a format string `{1:s} == {2:s}` with
corresponding expressions `x` and `y`.
After evaluating and broadcasting, the arguments create a `2×2` matrix of 2-tuples
to go with the `2×2 BitMatrix` result. The latter has two `false` elements at indices
`[2,1]` and `[2,2]`, corresponding to the 2-tuples `(7, 5)` and `(8, 6)`. Splatting
each of these into the format string creates the parts of the message that read
`7 == 5` and `8 == 6`.
### More complicated broadcasting
Expressions that involve more complicated broadcasting behaviour are naturally formatted.
For example, if the expression evaluates to a higher-dimensional array (e.g. `BitMatrix`),
individual failures are identified by their [`CartesianIndex`](@extref Julia Cartesian-indices):
```@repl test_all
@testset JustPrintTestSet begin # hide
@test_all [1 0] .== [1 0; 0 1]
end # hide
@testset JustPrintTestSet begin # hide
@test_all occursin.([r"a|b" "oo"], ["moo", "baa"])
end # hide
```
`Ref` can be used to avoid broadcasting certain elements:
```@repl test_all
vals = [1,2,3];
@testset JustPrintTestSet begin # hide
@test_all 1:5 .∈ Ref(vals)
end # hide
```
### Keyword splicing
Like [`@test`](@extref Julia Test.@test), [`@test_all`](@ref) will accept trailing keyword
arguments that will be spliced into `ex` if it is a function call (possibly `.` vectorized).
This is primarily useful to make vectorized approximate comparisons more readable:
```@repl test_all
v = [3, π, 4];
@testset JustPrintTestSet begin # hide
@test_all v .≈ 3.14 atol=0.15
end # hide
```
Splicing works with any callable function, including if it is wrapped in a negation:
```@repl test_all
iszero_mod(x; p=2) = x % p == 0;
@testset JustPrintTestSet begin # hide
@test_all .!iszero_mod.(1:3) p = 3
end # hide
```
### General iterables
Paralleling its [namesake](@extref Julia Base.all-Tuple{Any}), [`@test_all`](@ref)
works with general iterables (as long as they also define [`length`]
(@extref Julia Base.length)):
```@example test_all
struct IsEven vals end
Base.iterate(x::IsEven, i=1) = i > length(x.vals) ? nothing : (iseven(x.vals[i]), i+1);
Base.length(x::IsEven) = length(x.vals)
```
```@repl test_all
@testset JustPrintTestSet begin # hide
@test_all IsEven(1:4)
end # hide
```
If they also define [`keys`](@extref Julia Base.keys) and a corresponding [`getindex`]
(@extref Julia Base.getindex), failures will be printed by index:
```@example test_all
Base.keys(x::IsEven) = keys(x.vals)
Base.getindex(x::IsEven, args...) = getindex(x.vals, args...)
```
```@repl test_all
@testset JustPrintTestSet begin # hide
@test_all IsEven(1:4)
end # hide
```
!!! warning "Short-circuiting and iterables"
Since `@test_all ex` does not short-circuit at the first `false` value, it may
behave differently than `@test all(ex)` in certain edge cases, notably
when iterating over `ex` has side-effects.
Consider the same `IsEven` iterable as above, but with an assertion that each value
is non-negative:
```@example test_all
function Base.iterate(x::IsEven, i=1)
i > length(x.vals) && return nothing
@assert x.vals[i] >= 0
iseven(x.vals[i]), i+1
end
x = IsEven([1, 0, -1])
nothing # hide
```
Evaluating `@test all(x)` will return a [`Test.Fail`](@extref Julia), since the
evaluation of `all(x)` short-circuits after the first iteration and returns `false`:
```@repl test_all
@testset JustPrintTestSet begin # hide
@test all(x)
end # hide
```
Conversely, `@test_all x` will return a [`Test.Error`](@extref Julia) because it
evaluates all iterations and thus triggers the assertion error on the third iteration:
```@repl test_all
@testset JustPrintTestSet begin # hide
@test_all x
end # hide
```
### `Missing` values
The only other major difference between `@test all(ex)` and `@test_all ex` is in how they
deal with missing values. Recall that, in the presence of missing values,
[`all()`](@extref Julia Base.all-Tuple{Any}) will return `false` if any non-missing value
is `false`, or `missing` if all non-missing values are `true`.
Within an [`@test`](@extref Julia Test.@test), the former will return a [`Test.Fail`]
(@extref Julia) result, whereas the latter a [`Test.Error`](@extref Julia), pointing out
that the return value was non-Boolean:
```@repl test_all
@testset JustPrintTestSet begin # hide
@test all([1, missing] .== 2) # [false, missing] ===> false
end # hide
@testset JustPrintTestSet begin # hide
@test all([2, missing] .== 2) # [true, missing] ===> missing
end # hide
```
In the respective cases, [`@test_all`](@ref) will show the result of evaluating `all(ex)`
(`false` or `missing`), but always returns a [`Test.Fail`](@extref Julia) result showing individual
elements that were `missing` along with the ones that were `false`:
```@repl test_all
@testset JustPrintTestSet begin # hide
@test_all [1, missing] .== 2
end # hide
@testset JustPrintTestSet begin # hide
@test_all [2, missing] .== 2
end # hide
```
### Non-Boolean values
Finally, the macro will also produce a customized [`Test.Error`](@extref Julia) result
if the evaluated argument contains any non-Boolean, non-missing values. Where `all()`
would short-circuit and throw a [`Core.TypeError`](@extref Julia) on the first non-Boolean
value, [`@test_all`](@ref) identifies the indices of *all* non-Boolean, non-missing
values:
```@repl test_all
@testset JustPrintTestSet begin # hide
@test_all [true, false, 42, "a", missing]
end # hide
```
## `Test` integrations
```@setup integration
using PrettyTests, Test
PrettyTests.enable_failure_styling()
PrettyTests.set_max_print_failures(10)
mutable struct JustPrintTestSet <: Test.AbstractTestSet
results::Vector
JustPrintTestSet(desc) = new([])
end
function Test.record(ts::JustPrintTestSet, t::Test.Result)
str = sprint(show, t, context=:color=>true)
str = replace(str, r"Stacktrace:(.|\n)*$" => "Stacktrace: [...]")
println(str)
push!(ts.results, t)
return t
end
Test.finish(ts::JustPrintTestSet) = nothing
```
A core feature of `PrettyTests` is that macros integrate seamlessly with
Julia's standard [unit-testing framework](@extref Julia stdlib/Test). They return
one of the standard [`Test.Result`](@extref Julia) objects defined therein, namely:
- [`Test.Pass`](@extref Julia) if the test expression evaluates to `true`.
- [`Test.Fail`](@extref Julia) if it evaluates to `false` (or `missing` in the case of
`@test_all`).
- [`Test.Error`](@extref Julia) if the expression cannot be evaluated.
- [`Test.Broken`](@extref Julia) if the test is marked as broken or skipped (see below).
### Broken/skipped tests
They also support `skip` and `broken` keywords, with identical behavior to
[`@test`](@extref Julia Test.@test):
```@repl integration
@testset JustPrintTestSet begin # hide
@test_sets 1 ⊆ 2 skip=true
end #hide
@testset JustPrintTestSet begin # hide
@test_all 1 .== 2 broken=true
end #hide
@testset JustPrintTestSet begin # hide
@test_all 1 .== 1 broken=true
end #hide
```
### Working with test sets
The macros will also [`record`](@extref Julia Test.record) the result in the test set
returned by [`Test.get_testset()`](@extref Julia Test.get_testset). This means that they
will play nicely with testing workflows that use [`@testset`](@extref Julia Test.@testset):
```@repl integration
@testset "MyTestSet" begin
a = [1, 2]
@test_all a .== 1:2
@test_all a .< 1:2 broken=true
@test_sets a ⊆ 1:2
@test_sets a == 1:3 skip=true
end;
```
| PrettyTests | https://github.com/tpapalex/PrettyTests.jl.git |
|
[
"MIT"
] | 0.1.1 | 731532d7a03845a784a5a5e4e9a7b4993830032c | docs | 209 | ## Macros
```@docs
PrettyTests.@test_sets
PrettyTests.@test_all
```
## Display settings
```@docs
PrettyTests.set_max_print_failures
PrettyTests.disable_failure_styling
PrettyTests.enable_failure_styling
``` | PrettyTests | https://github.com/tpapalex/PrettyTests.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 779 | module SMTPClient
using Distributed
using LibCURL
using Dates
using Base64
using Markdown
import Base: convert
import Sockets: send
export SendOptions, SendResponse, send
export get_body, get_mime_msg
include("utils.jl")
include("types.jl")
include("cbs.jl") # callbacks
include("mail.jl")
include("mime_types.jl")
include("user.jl")
##############################
# Module init/cleanup
##############################
function __init__()
curl_global_init(CURL_GLOBAL_ALL)
global c_curl_write_cb =
@cfunction(curl_write_cb, Csize_t, (Ptr{Cchar}, Csize_t, Csize_t, Ptr{Cvoid}))
global c_curl_read_cb =
@cfunction(curl_read_cb, Csize_t, (Ptr{Cchar}, Csize_t, Csize_t, Ptr{Cvoid}))
atexit() do
curl_global_cleanup()
end
end
end # module SMTPClient
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 784 | ###############################################################################
# Callbacks
###############################################################################
function curl_write_cb(buff::Ptr{Cchar}, s::Csize_t, n::Csize_t, p::Ptr{Cvoid})::Csize_t
ctxt = unsafe_pointer_to_objref(p)
nbytes = s * n
write(ctxt.resp.body, unsafe_string(buff, nbytes))
ctxt.bytes_recd = ctxt.bytes_recd + nbytes
nbytes
end
function writeptr(dst::Ptr{Cchar}, rd::ReadData, n::Csize_t)::Csize_t
src = read(rd.src, n)
n = length(src)
ccall(:memcpy, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt), dst, src, n)
n
end
function curl_read_cb(out::Ptr{Cchar}, s::Csize_t, n::Csize_t, p::Ptr{Cvoid})::Csize_t
ctxt = unsafe_pointer_to_objref(p)
writeptr(out, ctxt.rd, s * n)
end
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 590 | send(url::AbstractString, to::AbstractVector{<:AbstractString},
from::AbstractString, body::IO, opts::SendOptions = SendOptions()) =
do_send(String(url), map(String, collect(to)), String(from), opts, ReadData(body))
function do_send(url::String, to::Vector{String}, from::String, options::SendOptions,
rd::ReadData)
ctxt = nothing
try
ctxt = ConnContext(url = url, rd = rd, options = options)
setmail_from!(ctxt, from)
setmail_rcpt!(ctxt, to)
connect(ctxt)
getresponse!(ctxt)
ctxt.resp
finally
cleanup!(ctxt)
end
end
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 4631 | mime_types = Dict(
[
"abs" => "audio/x-mpeg"
"ai" => "application/postscript"
"aif" => "audio/x-aiff"
"aifc" => "audio/x-aiff"
"aiff" => "audio/x-aiff"
"aim" => "application/x-aim"
"art" => "image/x-jg"
"asf" => "video/x-ms-asf"
"asx" => "video/x-ms-asf"
"au" => "audio/basic"
"avi" => "video/x-msvideo"
"avx" => "video/x-rad-screenplay"
"bcpio" => "application/x-bcpio"
"bin" => "application/octet-stream"
"bmp" => "image/bmp"
"body" => "text/html"
"cdf" => "application/x-cdf"
"cer" => "application/x-x509-ca-cert"
"class" => "application/java"
"cpio" => "application/x-cpio"
"csh" => "application/x-csh"
"css" => "text/css"
"dib" => "image/bmp"
"doc" => "application/msword"
"dtd" => "text/plain"
"dv" => "video/x-dv"
"dvi" => "application/x-dvi"
"eps" => "application/postscript"
"etx" => "text/x-setext"
"exe" => "application/octet-stream"
"gif" => "image/gif"
"gtar" => "application/x-gtar"
"gz" => "application/x-gzip"
"hdf" => "application/x-hdf"
"hqx" => "application/mac-binhex40"
"htc" => "text/x-component"
"htm" => "text/html"
"html" => "text/html"
"ief" => "image/ief"
"jad" => "text/vnd.sun.j2me.app-descriptor"
"jar" => "application/octet-stream"
"java" => "text/plain"
"jnlp" => "application/x-java-jnlp-file"
"jpe" => "image/jpeg"
"jpeg" => "image/jpeg"
"jpg" => "image/jpeg"
"js" => "text/javascript"
"kar" => "audio/x-midi"
"latex" => "application/x-latex"
"m3u" => "audio/x-mpegurl"
"mac" => "image/x-macpaint"
"man" => "application/x-troff-man"
"me" => "application/x-troff-me"
"mid" => "audio/x-midi"
"midi" => "audio/x-midi"
"mif" => "application/x-mif"
"mov" => "video/quicktime"
"movie" => "video/x-sgi-movie"
"mp1" => "audio/x-mpeg"
"mp2" => "audio/x-mpeg"
"mp3" => "audio/x-mpeg"
"mpa" => "audio/x-mpeg"
"mpe" => "video/mpeg"
"mpeg" => "video/mpeg"
"mpega" => "audio/x-mpeg"
"mpg" => "video/mpeg"
"mpv2" => "video/mpeg2"
"ms" => "application/x-wais-source"
"nc" => "application/x-netcdf"
"oda" => "application/oda"
"pbm" => "image/x-portable-bitmap"
"pct" => "image/pict"
"pdf" => "application/pdf"
"pgm" => "image/x-portable-graymap"
"pic" => "image/pict"
"pict" => "image/pict"
"pls" => "audio/x-scpls"
"png" => "image/png"
"pnm" => "image/x-portable-anymap"
"pnt" => "image/x-macpaint"
"ppm" => "image/x-portable-pixmap"
"ps" => "application/postscript"
"psd" => "image/x-photoshop"
"qt" => "video/quicktime"
"qti" => "image/x-quicktime"
"qtif" => "image/x-quicktime"
"ras" => "image/x-cmu-raster"
"rgb" => "image/x-rgb"
"rm" => "application/vnd.rn-realmedia"
"roff" => "application/x-troff"
"rtf" => "application/rtf"
"rtx" => "text/richtext"
"sh" => "application/x-sh"
"shar" => "application/x-shar"
"smf" => "audio/x-midi"
"snd" => "audio/basic"
"src" => "application/x-wais-source"
"sv4cpio" => "application/x-sv4cpio"
"sv4crc" => "application/x-sv4crc"
"swf" => "application/x-shockwave-flash"
"t" => "application/x-troff"
"tar" => "application/x-tar"
"tcl" => "application/x-tcl"
"tex" => "application/x-tex"
"texi" => "application/x-texinfo"
"texinfo" => "application/x-texinfo"
"tif" => "image/tiff"
"tiff" => "image/tiff"
"tr" => "application/x-troff"
"tsv" => "text/tab-separated-values"
"txt" => "text/plain"
"ulw" => "audio/basic"
"ustar" => "application/x-ustar"
"xbm" => "image/x-xbitmap"
"xpm" => "image/x-xpixmap"
"xwd" => "image/x-xwindowdump"
"wav" => "audio/x-wav"
"wbmp" => "image/vnd.wap.wbmp"
"wml" => "text/vnd.wap.wml"
"wmlc" => "application/vnd.wap.wmlc"
"wmls" => "text/vnd.wap.wmlscript"
"wmlscriptc" => "application/vnd.wap.wmlscriptc"
"wrl" => "x-world/x-vrml"
"Z" => "application/x-compress"
"z" => "application/x-compress"
"zip" => "application/zip"
]
) | SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 4029 | mutable struct SendOptions
isSSL::Bool
username::String
passwd::String
verbose::Bool
end
function SendOptions(; isSSL::Bool = false, username::AbstractString = "",
passwd::AbstractString = "", verbose::Bool = false, kwargs...)
kwargs = Dict(kwargs)
if get(kwargs, :blocking, nothing) ≠ nothing
@warn "options `blocking` is deprecated, blocking behaviour is default now, " *
"use `@async send(...)` for non-blocking style."
pop!(kwargs, :blocking)
end
length(keys(kwargs)) ≠ 0 && throw(MethodError("got unsupported keyword arguments"))
SendOptions(isSSL, String(username), String(passwd), verbose)
end
function Base.show(io::IO, o::SendOptions)
println(io, "SSL: ", o.isSSL)
print( io, "verbose: ", o.verbose)
!isempty(o.username) && print(io, "\nusername: ", o.username)
end
mutable struct SendResponse
body::IOBuffer
code::Int
total_time::Float64
SendResponse() = new(IOBuffer(), 0, 0.0)
end
function Base.show(io::IO, o::SendResponse)
println(io, "Return Code: ", o.code)
println(io, "Time: ", o.total_time)
print(io, "Response: ", String(take!(o.body)))
end
mutable struct ReadData{T<:IO}
typ::Symbol
src::T
str::AbstractString
offset::Csize_t
sz::Csize_t
end
ReadData() = ReadData{IOBuffer}(:undefined, IOBuffer(), "", 0, 0)
ReadData(io::T) where {T<:IO} = ReadData{T}(:io, io, "", 0, 0)
ReadData(io::IOBuffer) = ReadData{IOBuffer}(:io, io, "", 0, io.size)
mutable struct ConnContext
curl::Ptr{CURL} # CURL handle
url::String
rd::ReadData
resp::SendResponse
options::SendOptions
close_ostream::Bool
bytes_recd::Int
finalizer::Vector{Function}
end
function ConnContext(; curl = curl_easy_init(),
url::String = "",
rd::ReadData = ReadData(),
resp::SendResponse = SendResponse(),
options::SendOptions = SendOptions())
curl == C_NULL && throw("curl_easy_init() failed")
ctxt = ConnContext(curl, url, rd, resp, options, false, 0, Function[])
@ce_curl curl_easy_setopt curl CURLOPT_URL url
@ce_curl curl_easy_setopt curl CURLOPT_WRITEFUNCTION c_curl_write_cb
@ce_curl curl_easy_setopt curl CURLOPT_WRITEDATA ctxt
@ce_curl curl_easy_setopt curl CURLOPT_READFUNCTION c_curl_read_cb
@ce_curl curl_easy_setopt curl CURLOPT_READDATA ctxt
@ce_curl curl_easy_setopt curl CURLOPT_UPLOAD 1
if options.isSSL
@ce_curl curl_easy_setopt curl CURLOPT_USE_SSL CURLUSESSL_ALL
@ce_curl curl_easy_setopt curl CURLOPT_CAINFO LibCURL.cacert
end
if !isempty(options.username)
@ce_curl curl_easy_setopt curl CURLOPT_USERNAME options.username
@ce_curl curl_easy_setopt curl CURLOPT_PASSWORD options.passwd
end
if options.verbose
@ce_curl curl_easy_setopt curl CURLOPT_VERBOSE 1
end
ctxt
end
function setopt!(ctxt::ConnContext, opt, val)
@ce_curl curl_easy_setopt ctxt.curl opt val
ctxt
end
setmail_from!(ctxt::ConnContext, from::String) =
setopt!(ctxt, CURLOPT_MAIL_FROM, from)
function setmail_rcpt!(ctxt::ConnContext, R::Vector{String})
R′ = foldl(curl_slist_append, R, init = C_NULL)
R′ == C_NULL && error("mail rcpts invalid")
setopt!(ctxt, CURLOPT_MAIL_RCPT, R′)
push!(ctxt.finalizer, () -> curl_slist_free_all(R′))
ctxt
end
function connect(ctxt::ConnContext)
@ce_curl curl_easy_perform ctxt.curl
ctxt
end
cleanup!(::Nothing) = nothing
function cleanup!(ctxt::ConnContext)
curl = ctxt.curl
curl ≠ C_NULL && curl_easy_cleanup(curl)
for f ∈ ctxt.finalizer
f()
end
empty!(ctxt.finalizer)
if ctxt.close_ostream
close(ctxt.resp.body)
ctxt.resp.body = nothing
ctxt.close_ostream = false
end
end
function getresponse!(ctxt::ConnContext)
code = Array{Int}(undef, 1)
@ce_curl curl_easy_getinfo ctxt.curl CURLINFO_RESPONSE_CODE code
total_time = Array{Float64}(undef, 1)
@ce_curl curl_easy_getinfo ctxt.curl CURLINFO_TOTAL_TIME total_time
ctxt.resp.code = code[1]
ctxt.resp.total_time = total_time[1]
end
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 3989 | function encode_attachment(filename::String)
io = IOBuffer()
iob64_encode = Base64EncodePipe(io)
open(filename, "r") do f
write(iob64_encode, f)
end
close(iob64_encode)
filename_ext = split(filename, '.')[end]
if haskey(mime_types, filename_ext)
content_type = mime_types[filename_ext]
else
content_type = "application/octet-stream"
end
if haskey(mime_types, filename_ext) && startswith(mime_types[filename_ext], "image")
content_disposition = "inline"
else
content_disposition = "attachment"
end
# Some email clients, like Spark Mail, have problems when the attachment
# encoded string is very long. This code breaks the payload into lines with
# 75 characters, avoiding those problems.
raw_attachment = String(take!(io))
buf = IOBuffer()
char_count = 0
for c in raw_attachment
write(buf, c)
char_count += 1
if char_count == 75
write(buf, "\r\n")
char_count = 0
end
end
encoded_str =
"Content-Disposition: $content_disposition;\r\n" *
" filename=\"$(basename(filename))\"\r\n" *
"Content-Type: $content_type;\r\n" *
" name=\"$(basename(filename))\"\r\n" *
"Content-ID: <$(basename(filename))>\r\n" *
"Content-Transfer-Encoding: base64\r\n" *
"\r\n" *
"$(String(take!(buf)))\r\n"
return encoded_str
end
# See https://www.w3.org/Protocols/rfc1341/7_1_Text.html about charset
function get_mime_msg(message::String, ::Val{:plain}, charset::String = "UTF-8")
msg =
"Content-Type: text/plain; charset=\"$charset\"\r\n" *
"Content-Transfer-Encoding: quoted-printable\r\n\r\n" *
"$message\r\n"
return msg
end
get_mime_msg(message::String, ::Val{:utf8}) =
get_mime_msg(message, Val(:plain), "UTF-8")
get_mime_msg(message::String, ::Val{:usascii}) =
get_mime_msg(message, Val(:plain), "US-ASCII")
get_mime_msg(message::String) = get_mime_msg(message, Val(:utf8))
function get_mime_msg(message::String, ::Val{:html})
msg =
"Content-Type: text/html;\r\n" *
"Content-Transfer-Encoding: 7bit;\r\n\r\n" *
"\r\n" *
"<html>\r\n<body>" *
message *
"</body>\r\n</html>"
return msg
end
get_mime_msg(message::HTML{String}) = get_mime_msg(message.content, Val(:html))
get_mime_msg(message::Markdown.MD) = get_mime_msg(Markdown.html(message), Val(:html))
#Provide the message body as RFC5322 within an IO
function get_body(
to::Vector{String},
from::String,
subject::String,
msg::String;
cc::Vector{String} = String[],
replyto::String = "",
attachments::Vector{String} = String[]
)
boundary = "Julia_SMTPClient-" * join(rand(collect(vcat('0':'9','A':'Z','a':'z')), 40))
tz = mapreduce(
x -> string(x, pad=2), *,
divrem( div( ( now() - now(Dates.UTC) ).value, 60000 ), 60 )
)
date = join([Dates.format(now(), "e, d u yyyy HH:MM:SS", locale="english"), tz], " ")
contents =
"From: $from\r\n" *
"Date: $date\r\n" *
"Subject: $subject\r\n" *
ifelse(length(cc) > 0, "Cc: $(join(cc, ", "))\r\n", "") *
ifelse(length(replyto) > 0, "Reply-To: $replyto\r\n", "") *
"To: $(join(to, ", "))\r\n"
if length(attachments) == 0
contents *=
"MIME-Version: 1.0\r\n" *
"$msg\r\n\r\n"
else
contents *=
"Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n" *
"MIME-Version: 1.0\r\n" *
"\r\n" *
"This is a message with multiple parts in MIME format.\r\n" *
"--$boundary\r\n" *
msg *
"\r\n--$boundary\r\n" *
join(encode_attachment.(attachments), "\r\n--$boundary\r\n") *
"\r\n--$boundary--\r\n"
end
body = IOBuffer(contents)
return body
end
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 555 | macro ce_curl(f, handle, args...)
local esc_args = [esc(arg) for arg in args]
quote
cc = $(esc(f))($(esc(handle)), $(esc_args...))
if cc != CURLE_OK
err = unsafe_string(curl_easy_strerror(cc))
error(string($f) * "() failed: " * err)
end
end
end
macro ce_curlm(f, handle, args...)
local esc_args = [esc(arg) for arg in args]
quote
cc = $(esc(f))($(esc(handle)), $(esc_args...))
if cc != CURLM_OK
err = unsafe_string(curl_multi_strerror(cc))
error(string($f) * "() failed: " * err)
end
end
end
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 786 | @testset "Errors" begin
@testset "Error message for Humans(TM)" begin
let errmsg = "Couldn't resolve host name"
server = "smtp://nonexists"
body = IOBuffer("test")
try
send(server, ["nobody@earth"], "nobody@earth", body)
@assert false, "send should fail"
catch e
@test occursin(string(errmsg), string(e))
end
end
end
@testset "Non-blocking send" begin
let errmsg = "Couldn't resolve host name"
server = "smtp://nonexists"
body = IOBuffer("test")
t = @async send(server, ["nobody@earth"], "nobody@earth", body)
try
wait(t)
catch e
@test e isa TaskFailedException
@test occursin(errmsg, e.task.exception.msg)
end
end
end
end # @testset "Errors"
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 186 | using Test
import Base64: base64decode
using Markdown
using SMTPClient
@testset "SMTPClient" begin
for t ∈ (:send, :error)
@info "testset: $t..."
include("./$t.jl")
end
end
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | code | 24623 | function test_content(f::Base.Callable, fname)
try
open(fname) do io
f(read(io, String))
end
finally
rm(fname, force = true)
end
end
@testset "Send" begin
logfile = tempname()
server = "smtp://127.0.0.1:1025"
addr = "<[email protected]>"
mock = joinpath(dirname(@__FILE__), "mock.py")
cmd = `python3.7 $mock $logfile`
smtpsink = run(pipeline(cmd, stderr=stdout), wait = false)
sleep(.5) # wait for fake smtp server ready
try
let # send with body::IOBuffer
body = IOBuffer("body::IOBuffer test")
send(server, [addr], addr, body)
test_content(logfile) do s
@test occursin("body::IOBuffer test", s)
end
end
let # send with body::IOStream
mktemp() do path, io
write(io, "body::IOStream test")
seekstart(io)
send(server, [addr], addr, io)
test_content(logfile) do s
@test occursin("body::IOStream test", s)
end
end
end
let # AUTH PLAIN
opts = SendOptions(username = "[email protected]", passwd = "bar")
body = IOBuffer("AUTH PLAIN test")
send(server, [addr], addr, body, opts)
test_content(logfile) do s
@test occursin("AUTH PLAIN test", s)
end
end
let
opts = SendOptions(username = "[email protected]", passwd = "invalid")
body = IOBuffer("invalid password")
@test_throws Exception send(server, [addr], addr, body, opts)
end
let # multiple RCPT TO
body = IOBuffer("multiple rcpt")
rcpts = ["<[email protected]>", "<[email protected]>", "<[email protected]>"]
send(server, rcpts, addr, body)
test_content(logfile) do s
@test occursin("multiple rcpt", s)
@test occursin("X-RCPT: [email protected]", s)
@test occursin("X-RCPT: [email protected]", s)
@test occursin("X-RCPT: [email protected]", s)
end
end
let # non-blocking send
body = IOBuffer("non-blocking send")
task = @async send(server, [addr], addr, body)
wait(task)
test_content(logfile) do s
@test occursin("non-blocking send", s)
end
end
let # SendOptions.verbose no error
opts = SendOptions(verbose = true, username = "[email protected]", passwd = "bar")
body = IOBuffer("SendOptions.verbose")
send(server, [addr], addr, body, opts)
test_content(logfile) do s
@test occursin("SendOptions.verbose", s)
end
end
let # send using get_body
message = "body mime message"
subject = "test message"
mime_message = get_mime_msg(message, Val(:usascii))
body = get_body([addr], addr, subject, mime_message)
send(server, [addr], addr, body)
test_content(logfile) do s
@test occursin("From: $addr", s)
@test occursin("To: $addr", s)
@test occursin("Subject: $subject", s)
@test occursin(message, s)
end
end
let # send using get_body with UTF-8 encoded message
message =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789\r\n" *
"abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ\r\n" *
"–—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд\r\n" *
"∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა\r\n"
subject = "test message in UTF-8"
mime_message = get_mime_msg(message, Val(:utf8))
body = get_body([addr], addr, subject, mime_message)
send(server, [addr], addr, body)
test_content(logfile) do s
@test occursin("From: $addr", s)
@test occursin("To: $addr", s)
@test occursin("Subject: $subject", s)
@test occursin("ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789", s)
@test occursin("abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ", s)
@test occursin("–—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд", s)
@test occursin("∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა", s)
end
end
let # send using get_body with HTML string encoded message
message = HTML(
"""<h2>An important link to look at!</h2>
Here's an <a href="https://github.com/aviks/SMTPClient.jl">important link</a>\r\n"""
)
subject = "test message in HTML"
mime_message = get_mime_msg(message)
body = get_body([addr], addr, subject, mime_message)
send(server, [addr], addr, body)
test_content(logfile) do s
@test occursin("From: $addr", s)
@test occursin("To: $addr", s)
@test occursin("Subject: $subject", s)
@test occursin("Content-Type: text/html;", s)
@test occursin("Content-Transfer-Encoding: 7bit;", s)
@test occursin("<html>", s)
@test occursin("<body>", s)
@test occursin("<h2>An important link to look at!</h2>", s)
@test occursin(
"<a href=\"https://github.com/aviks/SMTPClient.jl\">important link</a>",
s
)
@test occursin("</body>", s)
@test occursin("</html>", s)
end
end
let # send using get_body with HTML string encoded message
message = Markdown.parse(
"""# An important link to look at!
Here's an [important link](https://github.com/aviks/SMTPClient.jl)"""
)
subject = "test message in Markdown"
mime_message = get_mime_msg(message)
body = get_body([addr], addr, subject, mime_message)
send(server, [addr], addr, body)
test_content(logfile) do s
@test occursin("From: $addr", s)
@test occursin("To: $addr", s)
@test occursin("Subject: $subject", s)
@test occursin("Content-Type: text/html;", s)
@test occursin("Content-Transfer-Encoding: 7bit;", s)
@test occursin("<html>", s)
@test occursin("<body>", s)
@test occursin("<h1>An important link to look at!</h1>", s)
@test occursin(
"<a href=\"https://github.com/aviks/SMTPClient.jl\">important link</a>",
s
)
@test occursin("</body>", s)
@test occursin("</html>", s)
end
end
let # send using get_body with extra fields
message = "body mime message with extra fields"
subject = "test message with extra fields"
mime_message = get_mime_msg(message)
from = addr
to = ["<[email protected]>", "<[email protected]>"]
cc = ["<[email protected]>", "<[email protected]>"]
bcc = ["<[email protected]>"]
replyto = addr
body = get_body(to, from, subject, mime_message;
cc = cc, replyto = replyto)
rcpts = vcat(to, cc, bcc)
send(server, rcpts, addr, body)
test_content(logfile) do s
@test occursin("From: $addr", s)
@test occursin("Subject: $subject", s)
@test occursin("Cc: <[email protected]>, <[email protected]>", s)
@test occursin("Reply-To: $addr", s)
@test occursin("To: <[email protected]>, <[email protected]>", s)
@test occursin(message, s)
@test occursin("X-RCPT: [email protected]", s)
@test occursin("X-RCPT: [email protected]", s)
@test occursin("X-RCPT: [email protected]", s)
@test occursin("X-RCPT: [email protected]", s)
@test occursin("X-RCPT: [email protected]", s)
end
end
let # send with attachment
message = "body mime message with attachment"
subject = "test message with attachment"
svg_str = """<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="320pt" height="200pt" viewBox="0 0 320 200" version="1.1">
<g id="surface61">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 67.871094 164.3125 C 67.871094 171.847656 67.023438 177.933594 65.328125 182.566406 C 63.632812 187.203125 61.222656 190.800781 58.09375 193.363281 C 54.96875 195.925781 51.21875 197.640625 46.847656 198.507812 C 42.476562 199.371094 37.613281 199.804688 32.265625 199.804688 C 25.027344 199.804688 19.488281 198.675781 15.648438 196.414062 C 11.804688 194.152344 9.882812 191.441406 9.882812 188.273438 C 9.882812 185.636719 10.953125 183.414062 13.101562 181.605469 C 15.25 179.796875 18.132812 178.894531 21.75 178.894531 C 24.464844 178.894531 26.632812 179.628906 28.25 181.097656 C 29.871094 182.566406 31.210938 184.019531 32.265625 185.449219 C 33.46875 187.03125 34.488281 188.085938 35.316406 188.613281 C 36.144531 189.140625 36.898438 189.40625 37.578125 189.40625 C 39.007812 189.40625 40.101562 188.558594 40.855469 186.863281 C 41.609375 185.167969 41.984375 181.871094 41.984375 176.972656 L 41.984375 84.050781 L 67.871094 76.929688 L 67.871094 164.3125 M 104.738281 79.414062 L 104.738281 139.214844 C 104.738281 140.875 105.058594 142.4375 105.699219 143.90625 C 106.339844 145.375 107.226562 146.640625 108.355469 147.695312 C 109.488281 148.75 110.804688 149.597656 112.3125 150.238281 C 113.820312 150.878906 115.441406 151.199219 117.175781 151.199219 C 119.132812 151.199219 121.359375 150.101562 124.070312 148.203125 C 128.363281 145.195312 130.964844 143.128906 130.964844 140.683594 C 130.964844 140.097656 130.964844 79.414062 130.964844 79.414062 L 156.738281 79.414062 L 156.738281 164.3125 L 130.964844 164.3125 L 130.964844 156.398438 C 127.574219 159.261719 123.957031 161.558594 120.113281 163.292969 C 116.269531 165.027344 112.539062 165.894531 108.921875 165.894531 C 104.703125 165.894531 100.78125 165.195312 97.164062 163.800781 C 93.546875 162.40625 90.382812 160.503906 87.671875 158.09375 C 84.957031 155.683594 82.828125 152.855469 81.28125 149.613281 C 79.738281 146.375 78.964844 142.90625 78.964844 139.214844 L 78.964844 79.414062 L 104.738281 79.414062 M 192.882812 164.3125 L 167.222656 164.3125 L 167.222656 45.277344 L 192.882812 38.15625 L 192.882812 164.3125 M 203.601562 84.050781 L 229.375 76.929688 L 229.375 164.3125 L 203.601562 164.3125 L 203.601562 84.050781 M 283.226562 120.449219 C 280.738281 121.507812 278.230469 122.730469 275.707031 124.125 C 273.183594 125.519531 270.882812 127.046875 268.8125 128.703125 C 266.738281 130.359375 265.0625 132.132812 263.78125 134.015625 C 262.5 135.898438 261.859375 137.859375 261.859375 139.894531 C 261.859375 141.476562 262.066406 143.003906 262.480469 144.472656 C 262.894531 145.941406 263.480469 147.203125 264.234375 148.257812 C 264.988281 149.3125 265.816406 150.160156 266.722656 150.800781 C 267.625 151.441406 268.605469 151.761719 269.660156 151.761719 C 271.769531 151.761719 273.898438 151.121094 276.046875 149.839844 C 278.195312 148.558594 280.585938 146.941406 283.226562 144.980469 L 283.226562 120.449219 M 309.109375 164.3125 L 283.226562 164.3125 L 283.226562 157.527344 C 281.792969 158.734375 280.398438 159.847656 279.042969 160.863281 C 277.6875 161.878906 276.160156 162.765625 274.464844 163.519531 C 272.769531 164.273438 270.867188 164.855469 268.753906 165.273438 C 266.644531 165.6875 264.15625 165.894531 261.296875 165.894531 C 257.375 165.894531 253.851562 165.328125 250.726562 164.199219 C 247.597656 163.066406 244.941406 161.523438 242.757812 159.5625 C 240.570312 157.605469 238.894531 155.285156 237.726562 152.609375 C 236.558594 149.9375 235.972656 147.015625 235.972656 143.851562 C 235.972656 140.609375 236.59375 137.671875 237.839844 135.03125 C 239.082031 132.394531 240.777344 130.023438 242.925781 127.910156 C 245.074219 125.800781 247.578125 123.917969 250.441406 122.257812 C 253.304688 120.601562 256.378906 119.074219 259.65625 117.679688 C 262.933594 116.285156 266.34375 115.007812 269.886719 113.839844 C 273.425781 112.671875 276.933594 111.558594 280.398438 110.503906 L 283.226562 109.824219 L 283.226562 101.460938 C 283.226562 96.035156 282.1875 92.191406 280.117188 89.929688 C 278.042969 87.667969 275.273438 86.539062 271.808594 86.539062 C 267.738281 86.539062 264.910156 87.519531 263.328125 89.476562 C 261.746094 91.4375 260.953125 93.808594 260.953125 96.597656 C 260.953125 98.179688 260.785156 99.726562 260.445312 101.234375 C 260.109375 102.742188 259.523438 104.058594 258.695312 105.191406 C 257.867188 106.320312 256.679688 107.226562 255.132812 107.902344 C 253.589844 108.582031 251.648438 108.921875 249.3125 108.921875 C 245.695312 108.921875 242.757812 107.882812 240.496094 105.8125 C 238.234375 103.738281 237.105469 101.121094 237.105469 97.953125 C 237.105469 95.015625 238.101562 92.285156 240.097656 89.761719 C 242.097656 87.234375 244.789062 85.066406 248.183594 83.261719 C 251.574219 81.449219 255.492188 80.019531 259.9375 78.964844 C 264.382812 77.910156 269.09375 77.382812 274.066406 77.382812 C 280.171875 77.382812 285.429688 77.929688 289.839844 79.019531 C 294.246094 80.113281 297.882812 81.675781 300.746094 83.710938 C 303.609375 85.746094 305.71875 88.195312 307.074219 91.058594 C 308.433594 93.921875 309.109375 97.128906 309.109375 100.667969 L 309.109375 164.3125 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(79.6%,23.5%,20%);fill-opacity:1;" d="M 235.273438 55.089844 C 235.273438 64.757812 227.4375 72.589844 217.773438 72.589844 C 208.105469 72.589844 200.273438 64.757812 200.273438 55.089844 C 200.273438 45.425781 208.105469 37.589844 217.773438 37.589844 C 227.4375 37.589844 235.273438 45.425781 235.273438 55.089844 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(25.1%,38.8%,84.7%);fill-opacity:1;" d="M 72.953125 55.089844 C 72.953125 64.757812 65.117188 72.589844 55.453125 72.589844 C 45.789062 72.589844 37.953125 64.757812 37.953125 55.089844 C 37.953125 45.425781 45.789062 37.589844 55.453125 37.589844 C 65.117188 37.589844 72.953125 45.425781 72.953125 55.089844 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(58.4%,34.5%,69.8%);fill-opacity:1;" d="M 277.320312 55.089844 C 277.320312 64.757812 269.484375 72.589844 259.820312 72.589844 C 250.15625 72.589844 242.320312 64.757812 242.320312 55.089844 C 242.320312 45.425781 250.15625 37.589844 259.820312 37.589844 C 269.484375 37.589844 277.320312 45.425781 277.320312 55.089844 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(22%,59.6%,14.9%);fill-opacity:1;" d="M 256.300781 18.671875 C 256.300781 28.335938 248.464844 36.171875 238.800781 36.171875 C 229.132812 36.171875 221.300781 28.335938 221.300781 18.671875 C 221.300781 9.007812 229.132812 1.171875 238.800781 1.171875 C 248.464844 1.171875 256.300781 9.007812 256.300781 18.671875 "/>
</g>
</svg>
"""
filename = joinpath(tempdir(), "julia_logo_color.svg")
open(filename, "w") do f
write(f, svg_str)
end
readme = open(f->read(f, String), joinpath("..", "README.md"))
mime_message = get_mime_msg(message, Val(:utf8))
attachments = [joinpath("..", "README.md"), filename]
body = get_body([addr], addr, subject, mime_message, attachments = attachments)
send(server, [addr], addr, body)
test_content(logfile) do s
m = match(r"Content-Type:\s*multipart\/mixed;\s*boundary=\"(.+)\"\n", s)
@test m !== nothing
boundary = m.captures[1]
@test occursin("To: $addr", s)
@test occursin("Subject: $subject", s)
@test occursin(message, s)
splt = split(s)
ind = findall(v -> occursin("--$boundary", v), splt)
@test length(ind) == 6
@test String(base64decode(splt[ind[4]-1])) == readme
@test String(base64decode(splt[ind[6]-1])) == svg_str
end
rm(filename)
end
let # send with attachment and markdown message
message = Markdown.parse(
"""# An important link to look at!
Here's an [important link](https://github.com/aviks/SMTPClient.jl)
And don't forget to check out the attached *cool* **julia** logo."""
)
subject = "test message with attachment"
svg_str = """<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="320pt" height="200pt" viewBox="0 0 320 200" version="1.1">
<g id="surface61">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 67.871094 164.3125 C 67.871094 171.847656 67.023438 177.933594 65.328125 182.566406 C 63.632812 187.203125 61.222656 190.800781 58.09375 193.363281 C 54.96875 195.925781 51.21875 197.640625 46.847656 198.507812 C 42.476562 199.371094 37.613281 199.804688 32.265625 199.804688 C 25.027344 199.804688 19.488281 198.675781 15.648438 196.414062 C 11.804688 194.152344 9.882812 191.441406 9.882812 188.273438 C 9.882812 185.636719 10.953125 183.414062 13.101562 181.605469 C 15.25 179.796875 18.132812 178.894531 21.75 178.894531 C 24.464844 178.894531 26.632812 179.628906 28.25 181.097656 C 29.871094 182.566406 31.210938 184.019531 32.265625 185.449219 C 33.46875 187.03125 34.488281 188.085938 35.316406 188.613281 C 36.144531 189.140625 36.898438 189.40625 37.578125 189.40625 C 39.007812 189.40625 40.101562 188.558594 40.855469 186.863281 C 41.609375 185.167969 41.984375 181.871094 41.984375 176.972656 L 41.984375 84.050781 L 67.871094 76.929688 L 67.871094 164.3125 M 104.738281 79.414062 L 104.738281 139.214844 C 104.738281 140.875 105.058594 142.4375 105.699219 143.90625 C 106.339844 145.375 107.226562 146.640625 108.355469 147.695312 C 109.488281 148.75 110.804688 149.597656 112.3125 150.238281 C 113.820312 150.878906 115.441406 151.199219 117.175781 151.199219 C 119.132812 151.199219 121.359375 150.101562 124.070312 148.203125 C 128.363281 145.195312 130.964844 143.128906 130.964844 140.683594 C 130.964844 140.097656 130.964844 79.414062 130.964844 79.414062 L 156.738281 79.414062 L 156.738281 164.3125 L 130.964844 164.3125 L 130.964844 156.398438 C 127.574219 159.261719 123.957031 161.558594 120.113281 163.292969 C 116.269531 165.027344 112.539062 165.894531 108.921875 165.894531 C 104.703125 165.894531 100.78125 165.195312 97.164062 163.800781 C 93.546875 162.40625 90.382812 160.503906 87.671875 158.09375 C 84.957031 155.683594 82.828125 152.855469 81.28125 149.613281 C 79.738281 146.375 78.964844 142.90625 78.964844 139.214844 L 78.964844 79.414062 L 104.738281 79.414062 M 192.882812 164.3125 L 167.222656 164.3125 L 167.222656 45.277344 L 192.882812 38.15625 L 192.882812 164.3125 M 203.601562 84.050781 L 229.375 76.929688 L 229.375 164.3125 L 203.601562 164.3125 L 203.601562 84.050781 M 283.226562 120.449219 C 280.738281 121.507812 278.230469 122.730469 275.707031 124.125 C 273.183594 125.519531 270.882812 127.046875 268.8125 128.703125 C 266.738281 130.359375 265.0625 132.132812 263.78125 134.015625 C 262.5 135.898438 261.859375 137.859375 261.859375 139.894531 C 261.859375 141.476562 262.066406 143.003906 262.480469 144.472656 C 262.894531 145.941406 263.480469 147.203125 264.234375 148.257812 C 264.988281 149.3125 265.816406 150.160156 266.722656 150.800781 C 267.625 151.441406 268.605469 151.761719 269.660156 151.761719 C 271.769531 151.761719 273.898438 151.121094 276.046875 149.839844 C 278.195312 148.558594 280.585938 146.941406 283.226562 144.980469 L 283.226562 120.449219 M 309.109375 164.3125 L 283.226562 164.3125 L 283.226562 157.527344 C 281.792969 158.734375 280.398438 159.847656 279.042969 160.863281 C 277.6875 161.878906 276.160156 162.765625 274.464844 163.519531 C 272.769531 164.273438 270.867188 164.855469 268.753906 165.273438 C 266.644531 165.6875 264.15625 165.894531 261.296875 165.894531 C 257.375 165.894531 253.851562 165.328125 250.726562 164.199219 C 247.597656 163.066406 244.941406 161.523438 242.757812 159.5625 C 240.570312 157.605469 238.894531 155.285156 237.726562 152.609375 C 236.558594 149.9375 235.972656 147.015625 235.972656 143.851562 C 235.972656 140.609375 236.59375 137.671875 237.839844 135.03125 C 239.082031 132.394531 240.777344 130.023438 242.925781 127.910156 C 245.074219 125.800781 247.578125 123.917969 250.441406 122.257812 C 253.304688 120.601562 256.378906 119.074219 259.65625 117.679688 C 262.933594 116.285156 266.34375 115.007812 269.886719 113.839844 C 273.425781 112.671875 276.933594 111.558594 280.398438 110.503906 L 283.226562 109.824219 L 283.226562 101.460938 C 283.226562 96.035156 282.1875 92.191406 280.117188 89.929688 C 278.042969 87.667969 275.273438 86.539062 271.808594 86.539062 C 267.738281 86.539062 264.910156 87.519531 263.328125 89.476562 C 261.746094 91.4375 260.953125 93.808594 260.953125 96.597656 C 260.953125 98.179688 260.785156 99.726562 260.445312 101.234375 C 260.109375 102.742188 259.523438 104.058594 258.695312 105.191406 C 257.867188 106.320312 256.679688 107.226562 255.132812 107.902344 C 253.589844 108.582031 251.648438 108.921875 249.3125 108.921875 C 245.695312 108.921875 242.757812 107.882812 240.496094 105.8125 C 238.234375 103.738281 237.105469 101.121094 237.105469 97.953125 C 237.105469 95.015625 238.101562 92.285156 240.097656 89.761719 C 242.097656 87.234375 244.789062 85.066406 248.183594 83.261719 C 251.574219 81.449219 255.492188 80.019531 259.9375 78.964844 C 264.382812 77.910156 269.09375 77.382812 274.066406 77.382812 C 280.171875 77.382812 285.429688 77.929688 289.839844 79.019531 C 294.246094 80.113281 297.882812 81.675781 300.746094 83.710938 C 303.609375 85.746094 305.71875 88.195312 307.074219 91.058594 C 308.433594 93.921875 309.109375 97.128906 309.109375 100.667969 L 309.109375 164.3125 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(79.6%,23.5%,20%);fill-opacity:1;" d="M 235.273438 55.089844 C 235.273438 64.757812 227.4375 72.589844 217.773438 72.589844 C 208.105469 72.589844 200.273438 64.757812 200.273438 55.089844 C 200.273438 45.425781 208.105469 37.589844 217.773438 37.589844 C 227.4375 37.589844 235.273438 45.425781 235.273438 55.089844 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(25.1%,38.8%,84.7%);fill-opacity:1;" d="M 72.953125 55.089844 C 72.953125 64.757812 65.117188 72.589844 55.453125 72.589844 C 45.789062 72.589844 37.953125 64.757812 37.953125 55.089844 C 37.953125 45.425781 45.789062 37.589844 55.453125 37.589844 C 65.117188 37.589844 72.953125 45.425781 72.953125 55.089844 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(58.4%,34.5%,69.8%);fill-opacity:1;" d="M 277.320312 55.089844 C 277.320312 64.757812 269.484375 72.589844 259.820312 72.589844 C 250.15625 72.589844 242.320312 64.757812 242.320312 55.089844 C 242.320312 45.425781 250.15625 37.589844 259.820312 37.589844 C 269.484375 37.589844 277.320312 45.425781 277.320312 55.089844 "/>
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(22%,59.6%,14.9%);fill-opacity:1;" d="M 256.300781 18.671875 C 256.300781 28.335938 248.464844 36.171875 238.800781 36.171875 C 229.132812 36.171875 221.300781 28.335938 221.300781 18.671875 C 221.300781 9.007812 229.132812 1.171875 238.800781 1.171875 C 248.464844 1.171875 256.300781 9.007812 256.300781 18.671875 "/>
</g>
</svg>
"""
filename = joinpath(tempdir(), "julia_logo_color.svg")
open(filename, "w") do f
write(f, svg_str)
end
readme = open(f->read(f, String), joinpath("..", "README.md"))
mime_message = get_mime_msg(message)
attachments = [joinpath("..", "README.md"), filename]
body = get_body([addr], addr, subject, mime_message, attachments = attachments)
send(server, [addr], addr, body)
test_content(logfile) do s
m = match(r"Content-Type:\s*multipart\/mixed;\s*boundary=\"(.+)\"\n", s)
@test m !== nothing
boundary = m.captures[1]
@test occursin("To: $addr", s)
@test occursin("Subject: $subject", s)
@test occursin("Content-Type: text/html;", s)
@test occursin("Content-Transfer-Encoding: 7bit;", s)
@test occursin("<html>", s)
@test occursin("<body>", s)
@test occursin("<h1>An important link to look at!</h1>", s)
@test occursin(
"<a href=\"https://github.com/aviks/SMTPClient.jl\">important link</a>",
s
)
@test occursin("<em>cool</em>",s)
@test occursin("<strong>julia</strong>",s)
@test occursin("</body>", s)
@test occursin("</html>", s)
splt = split(s)
ind = findall(v -> occursin("--$boundary", v), splt)
@test length(ind) == 6
@test String(base64decode(splt[ind[4]-1])) == readme
@test String(base64decode(splt[ind[6]-1])) == svg_str
end
rm(filename)
end
finally
kill(smtpsink)
rm(logfile, force = true)
end
end # @testset "Send"
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.6.4 | fc2e0dbf5df044c8790fb2d89f5c8684922b93b3 | docs | 9577 | # SMTPClient
[](https://travis-ci.org/aviks/SMTPClient.jl)
[](https://juliahub.com/ui/Packages/SMTPClient/Bx8Fn/)
[](https://juliahub.com/ui/Packages/SMTPClient/Bx8Fn/)
[](https://juliahub.com/ui/Packages/SMTPClient/Bx8Fn/?t=2)
A [CURL](curl.haxx.se) based SMTP client with fairly low level API.
It is useful for sending emails from within Julia code.
Depends on [LibCURL.jl](https://github.com/JuliaWeb/LibCURL.jl/).
The latest version of SMTPClient requires Julia 1.3 or higher. Versions of this package may be
available for older Julia versions, but are not fully supported.
## Installation
```julia
Pkg.add("SMTPClient")
```
The LibCURL native library is automatically installed using Julia's artifact system.
## Raw usage
```julia
using SMTPClient
opt = SendOptions(
isSSL = true,
username = "[email protected]",
passwd = "yourgmailpassword")
#Provide the message body as RFC5322 within an IO
body = IOBuffer(
"Date: Fri, 18 Oct 2013 21:44:29 +0100\r\n" *
"From: You <[email protected]>\r\n" *
"To: [email protected]\r\n" *
"Subject: Julia Test\r\n" *
"\r\n" *
"Test Message\r\n")
url = "smtps://smtp.gmail.com:465"
rcpt = ["<[email protected]>", "<[email protected]>"]
from = "<[email protected]>"
resp = send(url, rcpt, from, body, opt)
```
- Sending from file `IOStream` is supported:
```julia
body = open("/path/to/mail")
```
### Example with HTML formatting
```julia
body = "Subject: A simple test\r\n"*
"Mime-Version: 1.0;\r\n"*
"Content-Type: text/html;\r\n"*
"Content-Transfer-Encoding: 7bit;\r\n"*
"\r\n"*
"""<html>
<body>
<h2>An important link to look at!</h2>
Here's an <a href="https://github.com/aviks/SMTPClient.jl">important link</a>
</body>
</html>\r\n"""
```
### Function to construct the IOBuffer body and for adding attachments
A new function `get_body()` is available to facilitate constructing the IOBuffer for the body of the message and for adding attachments.
The function takes four required arguments: the `to` and `from` email addresses, a `subject` string, and a `msg` string. The `to` argument is a vector of strings, containing one or more email addresses. The `msg` string can be a regular string with the contents of the message or a string in MIME format, following the [RFC5322](https://datatracker.ietf.org/doc/html/rfc5322) specifications, and constructed as a plain text, html text or markdown text.
There are also the optional keyword arguments `cc`, `replyto` and `attachments`. The argument `cc` should be a vector of strings, containing one or more email addresses, while `replyto` is a string expected to contain a single argument, just like `from`. The `attachments` argument should be a list of filenames to be attached to the message.
The attachments are encoded using `Base64.base64encode` and included in the IOBuffer variable returned by the function. The function `get_body()` takes care of identifying which type of attachments are to be included (from the filename extensions) and to properly add them according to the MIME specifications.
In case an attachment is to be added, the `msg` argument must be formatted according to the MIME specifications. In order to help with that, another function, `get_mime_msg(message)`, is provided, which takes the provided message and returns the message with the proper MIME specifications. By default, it assumes plain text with UTF-8 encoding, but plain text with different encodings or HTML text or Markdown text can also be given (see [src/user.jl#L36](src/user.jl#L35) for more details on the implementation).
As for blind carbon copy (Bcc), it is implicitly handled by `send()`. Every recipient in `send()` which is not included in `body` is treated as a Bcc.
Here are a few examples:
#### Message with several types of recipients
```julia
using SMTPClient
opt = SendOptions(
isSSL = true,
username = "[email protected]",
passwd = "yourgmailpassword"
)
url = "smtps://smtp.gmail.com:465"
subject = "SMPTClient.jl"
message = "Don't forget to check out SMTPClient.jl"
to = ["<[email protected]>"]
cc = ["<[email protected]>"]
bcc = ["<[email protected]>"]
from = "You <[email protected]>"
replyto = "<[email protected]>"
body = get_body(to, from, subject, message; cc, replyto)
rcpt = vcat(to, cc, bcc)
resp = send(url, rcpt, from, body, opt)
```
#### Message with attachment
```julia
subject = "Julia logo"
message = "Check out this cool logo!"
attachments = ["julia_logo_color.png"]
mime_msg = get_mime_msg(message)
body = get_body(to, from, subject, mime_msg; attachments)
```
#### HTML message
Note that, by using `get_mime_msg()` with an `HTML{String}` message, the tags `<html>` and `<body>` should not be added.
```julia
subject = "A simple HTML test"
message =
html"""<h2>An important link to look at!</h2>
Here's an <a href="https://github.com/aviks/SMTPClient.jl">important link</a>
"""
mime_msg = get_mime_msg(message)
body = get_body(to, from, subject, mime_msg)
resp = send(server, rcpts, sender, body, opts)
```
#### Markdown message
```julia
using Markdown
subject = "The Julia Programming Language"
message =
Markdown.parse(
"""# The Julia Programming Language
## Julia in a Nutshell
1. **Fast** - Julia was designed from the beginning for [high performance](https://docs.julialang.org/en/v1/manual/types/).
1. **Dynamic** - Julia is [dynamically typed](https://docs.julialang.org/en/v1/manual/types/).
1. **Reproducible** - recreate the same [Julia environment](https://julialang.github.io/Pkg.jl/v1/environments/) every time.
1. **Composable** - Julia uses [multiple dispatch](https://docs.julialang.org/en/v1/manual/methods/) as a paradigm.
1. **General** - One can build entire [Applications and Microservices](https://www.youtube.com/watch?v=uLhXgt_gKJc) in Julia.
1. **Open source** - Available under the [MIT license](https://github.com/JuliaLang/julia/blob/master/LICENSE.md), with the [source code](https://github.com/JuliaLang/julia) on GitHub.
It has *over 5,000* [Julia packages](https://juliahub.com/ui/Packages) and a *variety* of advanced ecosystems. Check out more on [the Julia Programing Language website](https://julialang.org).
"""
)
mime_msg = get_mime_msg(message)
body = get_body(to, from, subject, mime_msg; cc, replyto)
resp = send(server, rcpts, sender, body, opts)
```
#### Previewing the generated message
You can preview your message by displaying the generated `body`, which is an `IOBuffer`.
For instance, you can view the raw message with `println(String(take!(body)))`.
You can also save the message `body` to a `.eml` file for viewing it in a email viewer.
```julia
open("message.eml","w") do io
println(io, String(take!(body)))
end
```
The last example on the previous section shows the following preview on Apple Mail:

### Gmail Notes
Due to the security policy of Gmail,
you need to "allow less secure apps into your account":
- <https://myaccount.google.com/lesssecureapps>
The URL for gmail can be either `smtps://smtp.gmail.com:465` or `smtp://smtp.gmail.com:587`.
(Note the extra `s` in the former.)
Both use SSL, and thus `isSSL` must be set to `true` in `SendOptions`. The latter starts
the connection with plain text, and converts it to secured before sending any data using a
protocol extension called `STARTTLS`. Gmail documentation suggests using this latter setup.
### Troubleshooting
Since this package is a pretty thin wrapper around a low level network protocol, it helps
to know the basics of SMTP while troubleshooting this package. Here is a [quick overview of SMTP](https://utcc.utoronto.ca/usg/technotes/smtp-intro.html). In particular, please pay attention to the difference
between the `envelope headers` and the `message headers`.
If you are having trouble with sending email, set `verbose=true` when creating the `SendOptions` object.
Please always do this before submitting a bugreport to this project.
When sending email over SSL, certificate verification is performed, which requires the presence of a
certificate authority bundle. This package uses the [CA bundle from the Mozilla](https://curl.haxx.se/docs/caextract.html) project. Currently there is no way to specify a private CA bundle. Modify the source if you need this.
## Function Reference
```julia
send(url, to-addresses, from-address, message-body, options)
```
Send an email.
* `url` should be of the form `smtp://server:port` or `smtps://...`.
* `to-address` is a vector of `String`.
* `from-address` is a `String`. All addresses must be enclosed in angle brackets.
* `message-body` must be a RFC5322 formatted message body provided via an `IO`.
* `options` is an object of type `SendOptions`. It contains authentication information, as well as the option of whether the server requires TLS.
```julia
SendOptions(; isSSL = false, verbose = false, username = "", passwd = "")
```
Options are passed via the `SendOptions` constructor that takes keyword arguments.
The defaults are shown above.
- `verbose`: enable `libcurl` verbose mode or not.
- If the `username` is blank, the `passwd` is not sent even if present.
Note that no keepalive is implemented.
New connections to the SMTP server are created for each message.
| SMTPClient | https://github.com/aviks/SMTPClient.jl.git |
|
[
"MIT"
] | 0.1.17 | 27c82b3b48bbff2123518b23b14778d013f080ac | code | 131 | module Jello
include("main.jl")
greet() = print("Hello World!")
export Blob, FourierBlob, ConvBlob, InterpBlob
end # module Jello
| Jello | https://github.com/paulxshen/Jello.jl.git |
|
[
"MIT"
] | 0.1.17 | 27c82b3b48bbff2123518b23b14778d013f080ac | code | 4059 | # - `alg`: `:interpolation` `:fourier`
"""
Blob(sz; contrast=20, alg=:interpolation, T=Float32, rmin=nothing, lsolid=rmin, lvoid=rmin, symmetries=[])
(m::ConvBlob)()
Functor for generating length scale controlled geometry mask, represented as array of values between 0 to 1.0. `ConvBlob` constructor makes the callable functor which can be passed as the model parameter to `Flux.jl`. Caliing it yields geometry whose length, spacing and radii are roughly on order of `lmin`. contrast controls the edge sharpness. Setting `rmin` applies additional morphological filtering which eliminates smaller features and radii
Args
- `sz`: size of mask array
Keyword Args
- `contrast`: edge sharpness
- `rmin`: minimal radii during morphological filtering, can also be `nothing` (no filtering)
- `lsolid`: same as `rmin` but only applied to solid (bright) features
- `lvoid`: ditto
- `symmetries`: symmetry dimensions
"""
function Blob(sz::Base.AbstractVecOrTuple;
lmin=0, lvoid=0, lsolid=0,
symmetries=[], alg=:interp, init=nothing,
frame=0,
F=Float32, T=F, verbose=false)
N = length(sz)
# lmin, lsolid, lvoid = round.(Int, [lmin, lsolid, lvoid])
lmin = max(lmin, lsolid, lvoid)
lmin /= 1.2sqrt(N)
lmin = max(1, lmin)
rmin = round((lmin - 1) / 2 + 0.01)
if isa(frame, Number)
margin = maximum(round.((lsolid, lvoid)))
frame = fill(frame, sz + 2margin)
end
if alg == :interp
psz = round.(Int, sz ./ lmin) + 1
elseif alg == :conv
rfilter = round(1.6rmin)
psz = sz + 2rfilter
end
da = 0.02
if isnothing(init)
a = da * randn(psz)
end
if isa(init, Number)
a = fill((-da) + 2 * da * init, psz)
end
if alg == :conv
if isa(init, Number)
a += 0.5randn(psz) * rmin^(N / 2)
end
a = T.(a)
n = 2rfilter + 1
conv = Conv((n, n), 1 => 1)
conv.weight .= conic(rfilter, 2)
return ConvBlob(a, conv, rmin, symmetries)
elseif alg == :interp
if isa(init, Number)
# a += -0.9sign(init) * rand(T, psz)
end
a = T.(a)
# resize(T.(init), nbasis)
# end
# n = length(a)
# N = prod(sz)
# A = zeros(Int, 3, 2^d * N)
# if lmin == 1
if any(sz .< psz)
A = nothing
else
J = LinearIndices(a)
I = LinearIndices(sz)
A = map(CartesianIndices(Tuple(sz))) do i
_i = I[i]
i = Tuple(i)
i = 1 + (i - 1) .* (size(a) - 1) ./ (sz - 1)
i = Float32.(i)
p = floor(i)
q = ceil(i)
stack(vec([Int32[_i, J[j...], round(1000prod(1 - abs.(i - j)))] for j = Base.product([p[i] == q[i] ? (p[i],) : (p[i], q[i]) for i = 1:length(i)]...)]))
end
A = reduce(hcat, vec(A))'
i, j, v = eachcol(A)
A = sparse(i, j, T(v / 1000))
a = vec(a)
end
# nn = [
# map(getindex.(getindex.(t, 1), i)) do c
# c = min.(c, size(a))
# l[c...]
# end for i = 1:2^d
# ]
# w = [getindex.(getindex.(t, 2), i) for i = 1:2^d]
# nn = w = 0
return InterpBlob(a, A, sz, lmin, lvoid, lsolid, frame, symmetries,)
elseif alg == :fourier
if isnothing(init)
ar = randn(T, nbasis...)
ai = randn(T, nbasis...)
else
ar = zeros(T, nbasis...)
ai = zeros(T, nbasis...)
if init == 1
ar[1] = 1
end
end
if verbose
@info """
Blob configs
Geometry generation
- algorithm: Fourier basis
- Fourier k-space size (# of Fourier basis per dimension): $nbasis
$com
"""
end
return FourierBlob(ar, ai, T(contrast), sz, lsolid, lvoid, symmetries, diagonal_symmetry)
end
end
Blob(sz...; kw...) = Blob(sz; kw...)
| Jello | https://github.com/paulxshen/Jello.jl.git |
|
[
"MIT"
] | 0.1.17 | 27c82b3b48bbff2123518b23b14778d013f080ac | code | 692 | struct ConvBlob
a::AbstractArray
conv
rmin
symmetries
end
@functor ConvBlob (a, conv)
Zygote.Params(m::ConvBlob) = Params([m.a])
Flux.trainable(m::ConvBlob) = (; a=m.a)
# Base.size(m::ConvBlob) = size(m.a)
function (m::ConvBlob)(α::Real=0.03, rmin=0, rsolid=rmin, rvoid=rmin,)
@unpack a, conv, symmetries, = m
T = eltype(a)
α = T(α)
# v = mean(abs.(a))
# if v != 0
# a *= T(0.5) / v
# end
N = ndims(a)
a = reshape(a, size(a)..., 1, 1)
a = conv(a)
a = dropdims(a, dims=(N + 1, N + 2))
# a = tanh.(α * m.rmin * a)
a = step(a, α)
a = (a + 1) / 2
a = smooth(a, rsolid, rvoid)
a = apply(symmetries, a)
end
| Jello | https://github.com/paulxshen/Jello.jl.git |
|
[
"MIT"
] | 0.1.17 | 27c82b3b48bbff2123518b23b14778d013f080ac | code | 2234 | struct FourierBlob
ar::AbstractArray
ai::AbstractArray
contrast
sz
ose
cse
symmetries
diagonal_symmetry
end
@functor FourierBlob (ar, ai)
Base.size(m::FourierBlob) = m.sz
"""
FourierBlob(sz...; nbasis=4, contrast=1, T=Float32, rmin=nothing, rsolid=rmin, rvoid=rmin, symmetries=[], diagonal_symmetry=false)
(m::FourierBlob)()
Functor for generating length scale controlled geometry mask, represented as array of values between 0 to 1.0. `FourierBlob` constructor makes the callable functor which can be passed as the model parameter to `Flux.jl`. Caliing it yields geometry whose length, spacing and radii are roughly on order of `edge length / nbasis`. contrast controls the edge sharpness. Setting `rmin` applies additional morphological filtering which eliminates smaller features and radii
Args
- `sz`: size of mask array
- `contrast`: edge sharpness
- `nbasis`: # of Fourier basis along each dimension
- `rmin`: minimal radii during morphological filtering, can also be `nothing` (no filtering) or `:auto` (automatically set wrt `nbasis`)
- `rsolid`: same as `rmin` but only applied to fill (bright) features
- `rvoid`: ditto
"""
# function FourierBlob(sz...; nbasis=4, init=nothing, contrast=1, T=Float32, rmin=nothing, rsolid=rmin, rvoid=rmin, symmetries=[], diagonal_symmetry=false, verbose=true)
# if length(nbasis) == 1
# nbasis = round.(Int, nbasis ./ minimum(sz) .* sz)
# end
# d = length(sz)
# # a = complex.(randn(T, nbasis...), randn(T, nbasis...))
# end
function (m::FourierBlob)(contrast=m.contrast, σ=x -> 1 / (1 + exp(-x)))
@unpack ar, ai, sz, ose, cse, symmetries, diagonal_symmetry = m
a = complex.(ar, ai)
# margins = round.(Int, sz ./ size(a) .* 0.75)
# i = range.(margins .+ 1, margins .+ sz)
# r = real(ifft(pad(a, 0, fill(0, ndims(a)), sz .+ 2 .* margins .- size(a))))[i...]
r = real(ifft(pad(a, 0, fill(0, ndims(a)), sz .- size(a))))
r = apply(symmetries, r)
# r = σ.(contrast * r)
r = apply(σ, contrast, r)
r = apply(ose, cse, r)
end
function FourierBlob(m::FourierBlob, sz...; contrast=m.contrast,)
FourierBlob(m.ar, m.ai, contrast, sz, m.ose, m.cse, m.symmetries, m.diagonal_symmetry)
end
| Jello | https://github.com/paulxshen/Jello.jl.git |
|
[
"MIT"
] | 0.1.17 | 27c82b3b48bbff2123518b23b14778d013f080ac | code | 653 | struct InterpBlob
a::AbstractArray
A
sz
lmin
lvoid
lsolid
frame
symmetries
end
@functor InterpBlob (a, A)
Zygote.Params(m::InterpBlob) = Params([m.a])
Flux.trainable(m::InterpBlob) = (; a=m.a)
# Base.size(m::InterpBlob) = size(m.a)
function (m::InterpBlob)(sharpness::Real=0.99, lvoid=m.lvoid, lsolid=m.lsolid,)
@unpack a, A, symmetries, sz, lmin, frame = m
T = eltype(a)
α = T(1 - sharpness)
if !isnothing(A)
a = reshape((A) * a, sz)
end
a = apply(symmetries, a)
a = step(a, α)
margin = Int.((size(frame, 1) - sz[1]) / 2)
a = smooth(a, α, lvoid, lsolid, frame, margin)
end
| Jello | https://github.com/paulxshen/Jello.jl.git |
|
[
"MIT"
] | 0.1.17 | 27c82b3b48bbff2123518b23b14778d013f080ac | code | 465 | using Random, FFTW, UnPack, ArrayPadding, LinearAlgebra, Statistics, SparseArrays, Flux, Zygote, Functors, ImageMorphology, Porcupine, ChainRulesCore, NNlib, ImageTransformations
# using ImageTransformations
# using Zygote: Buffer
include("utils.jl")
include("convblob.jl")
include("interpblob.jl")
include("fourierblob.jl")
include("blob.jl")
# m = Blob(4, 4)
# g = gradient(m) do m
# sum(m())
# end
# g[m]
# g = gradient(Params([m.a])) do
# sum(m())
# end | Jello | https://github.com/paulxshen/Jello.jl.git |
|
[
"MIT"
] | 0.1.17 | 27c82b3b48bbff2123518b23b14778d013f080ac | code | 2961 | _ceil(x) = x == floor(Int, x) ? Int(x) + 1 : ceil(Int, x)
function circle(r, d)
r = round(Int, r)
[norm(v) <= r + 0.001 for v = Base.product(fill(-r:r, d)...)] # circle
end
function conic(r, d)
r = round(Int, r)
a = [1 - norm(v) / (r + 1) for v = Base.product(fill(-r:r, d)...)] # circle
a /= sum(a)
end
function se(r, d=2)
centered(circle(round(r), d))
end
function apply(symmetries, r)
if !isempty(symmetries)
for d = symmetries
d = string(d)
if startswith(d, "diag")
r = (r + r') / 2 # diagonal symmetry in this Ceviche challenge
elseif startswith(d, "anti")
r = (r + reverse(r, dims=1)') / 2
# elseif startswith(d ,"anti")
elseif d == "inversion"
r += reverse(r, dims=Tuple(1:ndims(r)))
r /= 2
else
d = ignore_derivatives() do
parse(Int, d)
end
r += reverse(r, dims=d)
r /= 2
end
end
end
r
end
function step(a::AbstractArray{T}, α::Real) where {T}
m = a .> 0
α = T(α)
a = α / 2 * tanh.(a) + (m) * (1 - α / 2) + (1 - m) * (α / 2)
# a = min.(1, a)
# a = max.(-1, a)
end
# function open(a, r)
# A = ignore_derivatives() do
# T = typeof(a)
# m0 = Array(a) .> 0.5
# m = opening(m0, se(r, ndims(a)))
# T(m0 .== m)
# end
# a .* A
# end
# function close(a, r)
# A, B = ignore_derivatives() do
# T = typeof(a)
# m0 = Array(a) .> 0.5
# m = closing(m0, se(r, ndims(a)))
# T(m0 .== m), T(m .> m0)
# end
# a .* A + B
# end
function smooth(a, α, lvoid=0, lsolid=0, frame=nothing, lmin=0)
if lvoid == lsolid == 0
return a
end
rvoid = round(lvoid / 2 + 0.01)
rsolid = round(lsolid / 2 + 0.01)
T = typeof(a)
m0 = Array(a) .> 0.5
m = m0
A, B = ignore_derivatives() do
# for (ro, rc) in zip(ropen:-1:1, rclose:-1:1)
# # for (ro, rc) in zip(1:ropen, 1:rclose)
# # a = openclose(a, ro, rc)
# m = closing(m, se(rc, ndims(a)))
# m = opening(m, se(ro, ndims(a)))
# end
if !isnothing(frame)
o = fill(round(lmin) + 1, ndims(m))
roi = range.(o, o + size(m) - 1)
_m = copy(frame)
_m[roi...] = m
m = _m
end
if rsolid > 0
m = opening(m, se(rsolid, ndims(a)))
end
if rvoid > 0
m = closing(m, se(rvoid, ndims(a)))
end
if !isnothing(frame)
m = m[roi...]
end
m .> m0, m .< m0
end
A, B = T.((A, B))
a + (1 - α) * (A - B)
end
function resize(a, sz)
if length(sz) == 1
return imresize(a, sz, method=ImageTransformations.Lanczos4OpenCV())
end
imresize(a, sz)
end
| Jello | https://github.com/paulxshen/Jello.jl.git |
|
[
"MIT"
] | 0.1.17 | 27c82b3b48bbff2123518b23b14778d013f080ac | docs | 293 | # Jello.jl
Automatic differentiation (AD) and GPU compatible geometry generator with length scale and sharpness control. Applications in topology optimization , inverse design, ... Flux.jl compatible
See [](docs.ipynb)
### Contributors
Paul Shen
[email protected]
Luminescent AI
| Jello | https://github.com/paulxshen/Jello.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 1547 | using StochasticGroundMotionSimulation
using Documenter
DocMeta.setdocmeta!(StochasticGroundMotionSimulation, :DocTestSetup, :(using StochasticGroundMotionSimulation); recursive=true)
makedocs(;
modules=[StochasticGroundMotionSimulation],
authors="Peter Stafford <[email protected]>",
# repo="https://github.com/pstafford/StochasticGroundMotionSimulation.jl/blob/{commit}{path}#L{line}",
sitename="StochasticGroundMotionSimulation.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://pstafford.github.io/StochasticGroundMotionSimulation.jl",
assets=String[],
),
pages=[
"Home" => "index.md",
"Model Components" => [
"Fourier Spectral Parameters" => "fourier_parameters.md",
"Oscillator Parameters" => "sdof_parameters.md",
"Random Vibration Parameters" => "random_vibration_parameters.md",
],
"Module Functionality" => [
"Fourier Components" => [
"Fourier Amplitude Spectrum" => "fourier_spectrum.md",
"Source spectrum" => "source_spectrum.md",
"Path scaling" => "path_scaling.md",
"Site scaling" => "site_scaling.md",
],
"Method Index" => "method_index.md"
]
],
workdir = joinpath(@__DIR__, ".."),
checkdocs = :exports,
# warnonly = Documenter.except(:missing_docs),
)
deploydocs(;
repo="github.com/pstafford/StochasticGroundMotionSimulation.jl.git",
)
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 2200 |
module StochasticGroundMotionSimulation
using Interpolations
using Roots
using ForwardDiff
using ForwardDiff: Dual
using QuadGK
using FastGaussQuadrature
using LinearAlgebra
using StaticArrays
export Oscillator,
FourierParameters,
SourceParameters,
GeometricSpreadingParameters,
NearSourceSaturationParameters,
AnelasticAttenuationParameters,
PathParameters,
SiteParameters,
SiteAmpUnit,
SiteAmpConstant,
SiteAmpBoore2016_760,
SiteAmpAlAtikAbrahamson2021_ask14_620,
SiteAmpAlAtikAbrahamson2021_ask14_760,
SiteAmpAlAtikAbrahamson2021_ask14_1100,
SiteAmpAlAtikAbrahamson2021_bssa14_620,
SiteAmpAlAtikAbrahamson2021_bssa14_760,
SiteAmpAlAtikAbrahamson2021_bssa14_1100,
SiteAmpAlAtikAbrahamson2021_cb14_620,
SiteAmpAlAtikAbrahamson2021_cb14_760,
SiteAmpAlAtikAbrahamson2021_cb14_1100,
SiteAmpAlAtikAbrahamson2021_cy14_620,
SiteAmpAlAtikAbrahamson2021_cy14_760,
SiteAmpAlAtikAbrahamson2021_cy14_1100,
RandomVibrationParameters,
SpectralMoments,
create_spectral_moments,
period,
transfer,
transfer!,
squared_transfer,
squared_transfer!,
site_amplification,
kappa_filter,
magnitude_to_moment,
corner_frequency,
geometric_spreading,
near_source_saturation,
equivalent_point_source_distance,
anelastic_attenuation,
fourier_constant,
fourier_source,
fourier_source_shape,
fourier_path,
fourier_attenuation,
fourier_site,
combined_kappa_frequency,
fourier_spectral_ordinate,
fourier_spectrum,
fourier_spectrum!,
spectral_moment,
spectral_moments,
excitation_duration,
rms_duration,
peak_factor,
rvt_response_spectral_ordinate,
rvt_response_spectrum,
rvt_response_spectrum!
# Write your package code here.
include("oscillator/PJSoscillator.jl")
include("fourier/PJSsiteAmpStructs.jl")
include("fourier/PJSfourierParameters.jl")
include("rvt/PJSspectralMoments.jl")
include("rvt/PJSrandomVibrationParameters.jl")
include("fourier/PJSsite.jl")
include("fourier/PJSsource.jl")
include("fourier/PJSpath.jl")
include("fourier/PJSfourierSpectrum.jl")
include("duration/PJSduration.jl")
include("rvt/PJSintegration.jl")
include("rvt/PJSpeakFactor.jl")
include("rvt/PJSrandomVibration.jl")
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 23286 |
"""
boore_thompson_2014_path_duration(r_ps::T) where {T<:Real}
Boore & Thompson (2014) path duration model (for ACRs).
Note that this model is the same as the Boore & Thompson (2015) model for ACRs.
"""
function boore_thompson_2014_path_duration(r_ps::T) where {T<:Real}
# path duration
if r_ps == 0.0
return zero(T)
elseif r_ps > 0.0 && r_ps <= 7.0
return r_ps / 7.0 * 2.4
elseif r_ps > 7.0 && r_ps <= 45.0
return 2.4 + (r_ps - 7.0) / (45.0 - 7.0) * (8.4 - 2.4)
elseif r_ps > 45.0 && r_ps <= 125.0
return 8.4 + (r_ps - 45.0) / (125.0 - 45.0) * (10.9 - 8.4)
elseif r_ps > 125.0 && r_ps <= 175.0
return 10.9 + (r_ps - 125.0) / (175.0 - 125.0) * (17.4 - 10.9)
elseif r_ps > 175.0 && r_ps <= 270.0
return 17.4 + (r_ps - 175.0) / (270.0 - 175.0) * (34.2 - 17.4)
elseif r_ps > 270.0
return 34.2 + 0.156 * (r_ps - 270.0)
else
return T(NaN)
end
end
"""
boore_thompson_2014(m, r_ps::U, src::SourceParameters{S,T}) where {S<:Float64, T<:Real, U<:Real}
Boore & Thompson (2014) excitation duration model (for ACRs).
Note that this model is the same as the Boore & Thompson (2015) model for ACRs.
"""
function boore_thompson_2014(m, r_ps::U, src::SourceParameters{S,T}) where {S<:Float64,T<:Real,U<:Real}
# source duration
fa, fb, ε = corner_frequency(m, src)
if src.model == :Atkinson_Silva_2000
Ds = 0.5 / fa + 0.5 / fb
else
Ds = 1.0 / fa
end
# path duration
Dp = boore_thompson_2014_path_duration(r_ps)
# checks on return type for type stability
if isnan(Dp)
if T <: Dual
return T(NaN)
elseif U <: Dual
return U(NaN)
else
return S(NaN)
end
else
return Ds + Dp
end
end
boore_thompson_2014(m, r_ps, fas::FourierParameters) = boore_thompson_2014(m, r_ps, fas.source)
"""
boore_thompson_2015_path_duration_acr(r_ps::T) where {T<:Real}
Boore & Thompson (2015) path duration model (for ACRs).
Note that this model is the same as the Boore & Thompson (2014) model for ACRs.
"""
boore_thompson_2015_path_duration_acr(r_ps::T) where {T<:Real} = boore_thompson_2014_path_duration(r_ps)
"""
boore_thompson_2015_path_duration_scr(r_ps::T) where {T<:Real}
Boore & Thompson (2015) path duration model (for SCRs).
"""
function boore_thompson_2015_path_duration_scr(r_ps::T) where {T<:Real}
# path duration
if r_ps == 0.0
return zero(T)
elseif r_ps > 0.0 && r_ps <= 15.0
return r_ps / 15.0 * 2.6
elseif r_ps > 15.0 && r_ps <= 35.0
return 2.6 + (r_ps - 15.0) / (35.0 - 15.0) * (17.5 - 2.6)
elseif r_ps > 35.0 && r_ps <= 50.0
return 17.5 + (r_ps - 35.0) / (50.0 - 35.0) * (25.1 - 17.5)
elseif r_ps > 50.0 && r_ps <= 125.0
return 25.1
elseif r_ps > 125.0 && r_ps <= 200.0
return 25.1 + (r_ps - 125.0) / (200.0 - 125.0) * (28.5 - 25.1)
elseif r_ps > 200.0 && r_ps <= 392.0
return 28.5 + (r_ps - 200.0) / (392.0 - 200.0) * (46.0 - 28.5)
elseif r_ps > 392.0 && r_ps <= 600.0
return 46.0 + (r_ps - 392.0) / (600.0 - 392.0) * (69.1 - 46.0)
elseif r_ps > 600.0
return 69.1 + 0.111 * (r_ps - 600.0)
else
return T(NaN)
end
end
"""
boore_thompson_2015(m, r_ps::U, src::SourceParameters{S,T}, region::Symbol) where {S<:Float64, T<:Real, U<:Real}
Boore & Thompson (2015) excitation duration model (for ACRs or SCRs).
"""
function boore_thompson_2015(m, r_ps::U, src::SourceParameters{S,T}, region::Symbol) where {S<:Float64,T<:Real,U<:Real}
# source duration
fa, fb, ε = corner_frequency(m, src)
if src.model == :Atkinson_Silva_2000
Ds = 0.5 / fa + 0.5 / fb
else
Ds = 1.0 / fa
end
# path duration
if region == :ACR
Dp = boore_thompson_2015_path_duration_acr(r_ps)
elseif region == :SCR
Dp = boore_thompson_2015_path_duration_scr(r_ps)
else
Dp = NaN
end
# checks on return type for type stability
if isnan(Dp)
if T <: Dual
return T(NaN)
elseif U <: Dual
return U(NaN)
else
return S(NaN)
end
else
return Ds + Dp
end
end
boore_thompson_2015(m, r_ps, fas::FourierParameters, region) = boore_thompson_2015(m, r_ps, fas.source, region)
boore_thompson_2015(m, r_ps::U, src::SourceParameters{S,T}, rvt::RandomVibrationParameters) where {S<:Float64, T<:Real, U<:Real} = boore_thompson_2015(m, r_ps, src, rvt.dur_region)
boore_thompson_2015(m, r_ps::U, fas::FourierParameters, rvt::RandomVibrationParameters) where {U<:Real} = boore_thompson_2015(m, r_ps, fas.source, rvt.dur_region)
"""
edwards_2023_path_duration(r_ps::T) where {T<:Real}
Edwards (2023) path duration model using within South African NPP study.
Note that the model was specified in terms of R_hyp -- so interpret this to be the effective point-source distance.
Further note that this model is apparently based upon work of Afshari & Stewart (2016) who found
a dependence of 5-75% significant duration on distance of 0.07s/km. Edwards then found for the
Groningen project in the Netherlands (for induced seismicity) that the excitation duration was
equivalent to the 5-75% duration divided by 0.55.
However, in Edwards' definition, this 0.55 scale factor is supposed to apply to the 5-75% duration
in its entirety, but he only scales the path duration (not the source duration).
"""
function edwards_2023_path_duration(r_ps::T) where {T<:Real}
# path duration
if r_ps <= 0.0
return zero(T)
else
return 0.13 * r_ps
end
end
"""
edwards_2023(m, r_ps::U, src::SourceParameters{S,T}) where {S<:Float64, T<:Real, U<:Real}
Edwards (2023) excitation duration model proposed for use within South African NPP study.
"""
function edwards_2023(m, r_ps::U, src::SourceParameters{S,T}) where {S<:Float64,T<:Real,U<:Real}
# source duration
fa, fb, ε = corner_frequency(m, src)
# this is not explicitly considered in the Edwards model, but keep the same functionality as other models for consistency
if src.model == :Atkinson_Silva_2000
Ds = 0.5 / fa + 0.5 / fb
else
Ds = 1.0 / fa
end
# path duration
Dp = edwards_2023_path_duration(r_ps)
return Ds + Dp
end
"""
uk_path_duration_free(r_ps::T) where {T<:Real}
Path duration model for the UK allowing the plateau segment to have a free slope
"""
function uk_path_duration_free(r_ps::T) where {T<:Real}
r_ref = [ 0.0, 21.8, 140.4, 254.2 ]
dg_ref = [ 0.667, 0.002, 0.128, 0.192 ]
d_path = zero(T)
if r_ps <= r_ref[1]
return d_path
elseif r_ps <= r_ref[2]
return d_path + dg_ref[1] * r_ps
elseif r_ps <= r_ref[3]
return d_path + dg_ref[1] * r_ref[2] + dg_ref[2] * (r_ps - r_ref[2])
elseif r_ps <= r_ref[4]
return d_path + dg_ref[1] * r_ref[2] + dg_ref[2] * (r_ref[3] - r_ref[2]) + dg_ref[3] * (r_ps - r_ref[3])
else
return d_path + dg_ref[1] * r_ref[2] + dg_ref[2] * (r_ref[3] - r_ref[2]) + dg_ref[3] * (r_ref[4] - r_ref[3]) + dg_ref[4] * (r_ps - r_ref[4])
end
end
"""
uk_path_duration_fixed(r_ps::T) where {T<:Real}
Path duration model for the UK forcing the plateau segment to have a flat slope
"""
function uk_path_duration_fixed(r_ps::T) where {T<:Real}
r_ref = [0.0, 28.3, 140.5, 254.1]
dg_ref = [0.519, 0.0, 0.13, 0.193]
d_path = zero(T)
if r_ps <= r_ref[1]
return d_path
elseif r_ps <= r_ref[2]
return d_path + dg_ref[1] * r_ps
elseif r_ps <= r_ref[3]
return d_path + dg_ref[1] * r_ref[2] + dg_ref[2] * (r_ps - r_ref[2])
elseif r_ps <= r_ref[4]
return d_path + dg_ref[1] * r_ref[2] + dg_ref[2] * (r_ref[3] - r_ref[2]) + dg_ref[3] * (r_ps - r_ref[3])
else
return d_path + dg_ref[1] * r_ref[2] + dg_ref[2] * (r_ref[3] - r_ref[2]) + dg_ref[3] * (r_ref[4] - r_ref[3]) + dg_ref[4] * (r_ps - r_ref[4])
end
end
"""
uk_duration_free(m, r_ps::U, src::SourceParameters{S,T}) where {S<:Float64,T<:Real,U<:Real}
Excitation duration for the UK. Combines standard reciprocal corner frequency source duration with a UK path duration.
"""
function uk_duration_free(m, r_ps::U, src::SourceParameters{S,T}) where {S<:Float64,T<:Real,U<:Real}
# source duration
fa, fb, ε = corner_frequency(m, src)
# this is not explicitly considered in the Edwards model, but keep the same functionality as other models for consistency
if src.model == :Atkinson_Silva_2000
Ds = 0.5 / fa + 0.5 / fb
else
Ds = 1.0 / fa
end
# path duration
Dp = uk_path_duration_free(r_ps)
# combine source and path durations
return Ds + Dp
end
"""
uk_duration_fixed(m, r_ps::U, src::SourceParameters{S,T}) where {S<:Float64,T<:Real,U<:Real}
Excitation duration for the UK. Combines standard reciprocal corner frequency source duration with a UK path duration.
"""
function uk_duration_fixed(m, r_ps::U, src::SourceParameters{S,T}) where {S<:Float64,T<:Real,U<:Real}
# source duration
fa, fb, ε = corner_frequency(m, src)
# this is not explicitly considered in the Edwards model, but keep the same functionality as other models for consistency
if src.model == :Atkinson_Silva_2000
Ds = 0.5 / fa + 0.5 / fb
else
Ds = 1.0 / fa
end
# path duration
Dp = uk_path_duration_fixed(r_ps)
# combine source and path durations
return Ds + Dp
end
"""
excitation_duration(m, r_ps::U, src::SourceParameters{S,T}, rvt::RandomVibrationParameters) where {S<:Float64,T<:Real,U<:Real}
Generic function implementing excitation duration models.
Currently, only the general Boore & Thompson (2014, 2015) models are implemented along with some project-specific models from Edwards (2023) (for South Africa),
and two UK duration models.
The first two are both represented within the Boore & Thompson (2015) paper, so just switch path duration based upon `rvt.dur_region`
To activate the Edwards model, use `rvt.dur_ex == :BE23`
For the UK models use `rvt.dur_ex == :UKfree` or `rvt.dur_ex == :UKfixed`
"""
function excitation_duration(m, r_ps::U, src::SourceParameters{S,T}, rvt::RandomVibrationParameters) where {S<:Float64,T<:Real,U<:Real}
if rvt.dur_ex == :BE23
# use the BT15 saturation model to obtain an r_rup from the specified r_ps
# Edwards actually suggested using R_{EFF}, but this metric is heavily dependent upon a particular source/site geometry
# sat = NearSourceSaturationParameters(:BT15)
# compute r_rup from r_ps
# r_rup = rupture_distance_from_equivalent_point_source_distance(r_ps, m, sat)
return edwards_2023(m, r_ps, src)
elseif rvt.dur_ex == :UKfree
return uk_duration_free(m, r_ps, src)
elseif rvt.dur_ex == :UKfixed
return uk_duration_fixed(m, r_ps, src)
elseif (rvt.dur_ex == :BT14) & (rvt.dur_region == :ACR)
return boore_thompson_2014(m, r_ps, src)
elseif (rvt.dur_ex == :BT15)
return boore_thompson_2015(m, r_ps, src, rvt)
else
if T <: Dual
return T(NaN)
elseif U <: Dual
return U(NaN)
else
return S(NaN)
end
end
end
excitation_duration(m, r_ps, fas::FourierParameters, rvt::RandomVibrationParameters) = excitation_duration(m, r_ps, fas.source, rvt)
# Definition of Boore & Thompson (2012) constant values to be used within subsequent functions
include("coefficients/PJSbooreThompson2012.jl")
"""
boore_thompson_2012_coefs(idx_m::T, idx_r::T; region::Symbol=:ACR) where T<:Int
Base function to extract the coefficients of the Boore & Thompson (2012) rms duration model.
"""
function boore_thompson_2012_coefs(idx_m::T, idx_r::T; region::Symbol=:ACR) where {T<:Int}
idx = (idx_r - 1) * num_m_ii_bt12 + idx_m
if region == :SCR
@inbounds c = coefs_ena_bt12[idx, 3:9]
return c
else
@inbounds c = coefs_wna_bt12[idx, 3:9]
return c
end
end
"""
boore_thompson_2012_base(η::S, c::Vector{T}, ζ::T=0.05) where {S<:Real,T<:Float64}
Base function to compute the Boore & Thompson (2012) rms duration model for known magnitude and distance.
"""
function boore_thompson_2012_base(η::S, c::Vector{T}, ζ::T=0.05) where {S<:Real,T<:Float64}
@inbounds ηc3 = η^c[3]
@inbounds ratio = (c[1] + c[2] * ((1.0 - ηc3) / (1.0 + ηc3))) * (1.0 + c[4] / (2π * ζ) * (η / (1.0 + c[5] * η^c[6]))^c[7])
return ratio
end
"""
boore_thompson_2012(m, r_ps::T, src::SourceParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {T<:Real}
Boore & Thompson (2012) rms duration model. Also outputs the excitation duration (given that its required within the rms duration calculations).
"""
function boore_thompson_2012(m, r_ps::T, src::SourceParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {T<:Real}
# for magnitude and distance that don't match coefficient tables we need to use bilinear interpolation
# get the excitation duration (as recommended by Boore & Thompson, 2012)
Dex = excitation_duration(m, r_ps, src, rvt)
# get the oscillator period
T_n = period(sdof)
ζ = sdof.ζ_n
# define the η parameter as T_n/Dex
η = T_n / Dex
# impose limits on the magnitudes and distances
m = (m < 4.0) ? 4.0 : m
m = (m > 8.0) ? 8.0 : m
r_ps = (r_ps < 2.0) ? 2.0 : r_ps
r_ps = (r_ps > 1262.0) ? 1262.0 : r_ps
# get the bounding indicies
i_lo = findlast(m_ii_bt12 .<= m)
i_hi = findfirst(m_ii_bt12 .>= m)
j_lo = findlast(r_jj_bt12 .<= r_ps)
j_hi = findfirst(r_jj_bt12 .>= r_ps)
# get the region for the rms duration model
region = rvt.dur_region
# check for situations in which the coefficients are known for the given m,r
if i_lo == i_hi # we have coefficients for this magnitude
if j_lo == j_hi # we have coefficients for this distance
c = boore_thompson_2012_coefs(i_lo, j_lo; region=region)
Dratio = boore_thompson_2012_base(η, c, ζ)
else # we need to interpolate the distance values only
r_lo = r_jj_bt12[j_lo]
r_hi = r_jj_bt12[j_hi]
c_lo = boore_thompson_2012_coefs(i_lo, j_lo; region=region)
c_hi = boore_thompson_2012_coefs(i_lo, j_hi; region=region)
D_lo = boore_thompson_2012_base(η, c_lo, ζ)
D_hi = boore_thompson_2012_base(η, c_hi, ζ)
lnDratio = log(D_lo) + (r_ps - r_lo) / (r_hi - r_lo) * log(D_hi / D_lo)
Dratio = exp(lnDratio)
end
else # we need to interpolate the magnitudes
if j_lo == j_hi # we have coefficients for this distance
m_lo = m_ii_bt12[i_lo]
m_hi = m_ii_bt12[i_hi]
c_lo = boore_thompson_2012_coefs(i_lo, j_lo; region=region)
c_hi = boore_thompson_2012_coefs(i_hi, j_lo; region=region)
D_lo = boore_thompson_2012_base(η, c_lo, ζ)
D_hi = boore_thompson_2012_base(η, c_hi, ζ)
lnDratio = log(D_lo) + (m - m_lo) / (m_hi - m_lo) * log(D_hi / D_lo)
Dratio = exp(lnDratio)
else # we need to interpolate for this magnitude and distance
# create the combinations of (m,r) from these indices
m_lo = m_ii_bt12[i_lo]
m_hi = m_ii_bt12[i_hi]
r_lo = r_jj_bt12[j_lo]
r_hi = r_jj_bt12[j_hi]
# get the corresponding coefficients
c_ll = boore_thompson_2012_coefs(i_lo, j_lo; region=region)
c_lh = boore_thompson_2012_coefs(i_lo, j_hi; region=region)
c_hl = boore_thompson_2012_coefs(i_hi, j_lo; region=region)
c_hh = boore_thompson_2012_coefs(i_hi, j_hi; region=region)
# get the corresponding ratios
Dr_ll = boore_thompson_2012_base(η, c_ll, ζ)
Dr_lh = boore_thompson_2012_base(η, c_lh, ζ)
Dr_hl = boore_thompson_2012_base(η, c_hl, ζ)
Dr_hh = boore_thompson_2012_base(η, c_hh, ζ)
# bilinear interpolation
# used repeated linear interpolation as the fastest method
Δm = m_hi - m_lo
Δr = r_hi - r_lo
fac = 1.0 / (Δm * Δr)
lnDr_ll = log(Dr_ll)
lnDr_lh = log(Dr_lh)
lnDr_hl = log(Dr_hl)
lnDr_hh = log(Dr_hh)
lnDratio = fac * ((lnDr_ll * (r_hi - r_ps) + lnDr_lh * (r_ps - r_lo)) * (m_hi - m) + (lnDr_hl * (r_hi - r_ps) + lnDr_hh * (r_ps - r_lo)) * (m - m_lo))
Dratio = exp(lnDratio)
end
end
Drms = Dratio * Dex
return (Drms, Dex, Dratio)
end
boore_thompson_2012(m, r_ps, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters) = boore_thompson_2012(m, r_ps, fas.source, sdof, rvt)
# Definition of Boore & Thompson (2015) constant values to be used within subsequent functions
include("coefficients/PJSbooreThompson2015.jl")
"""
boore_thompson_2015_coefs(idx_m::T, idx_r::T; region::Symbol=:ACR) where T<:Int
Base function to extract the coefficients of the Boore & Thompson (2015) rms duration model.
"""
function boore_thompson_2015_coefs(idx_m::T, idx_r::T; region::Symbol=:ACR) where {T<:Int}
idx = (idx_r - 1) * num_m_ii_bt15 + idx_m
if region == :SCR
@inbounds c = coefs_ena_bt15[idx, 3:9]
return c
else
@inbounds c = coefs_wna_bt15[idx, 3:9]
return c
end
end
"""
boore_thompson_2015_base(η::S, c::Vector{T}, ζ::T=0.05) where {S<:Real,T<:Float64}
Base function to compute the Boore & Thompson (2015) rms duration model for known magnitude and distance.
"""
function boore_thompson_2015_base(η::S, c::Vector{T}, ζ::T=0.05) where {S<:Real,T<:Float64}
@inbounds ηc3 = η^c[3]
@inbounds ratio = (c[1] + c[2] * ((1.0 - ηc3) / (1.0 + ηc3))) * (1.0 + c[4] / (2π * ζ) * (η / (1.0 + c[5] * η^c[6]))^c[7])
return ratio
end
"""
boore_thompson_2015(m, r_ps::T, src::SourceParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {T<:Real}
Boore & Thompson (2015) rms duration model. Also outputs the excitation duration (given that its required within the rms duration calculations).
"""
function boore_thompson_2015(m, r_ps::T, src::SourceParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {T<:Real}
# for magnitude and distance that don't match coefficient tables we need to use bilinear interpolation of the log Drms values
# get the excitation duration (as recommended by Boore & Thompson, 2015)
Dex = excitation_duration(m, r_ps, src, rvt)
# get the oscillator period
T_n = period(sdof)
ζ = sdof.ζ_n
# define the η parameter as T_n/Dex
η = T_n / Dex
# impose limits on the magnitudes and distances
m = (m < 2.0) ? 2.0 : m
m = (m > 8.0) ? 8.0 : m
r_ps = (r_ps < 2.0) ? 2.0 : r_ps
r_ps = (r_ps > 1262.0) ? 1262.0 : r_ps
# get the bounding indicies
i_lo = findlast(m_ii_bt15 .<= m)
i_hi = findfirst(m_ii_bt15 .>= m)
j_lo = findlast(r_jj_bt15 .<= r_ps)
j_hi = findfirst(r_jj_bt15 .>= r_ps)
# get the region for the rms duration model
region = rvt.dur_region
# check for situations in which the coefficients are known for the given m,r
if i_lo == i_hi # we have coefficients for this magnitude
if j_lo == j_hi # we have coefficients for this distance
c = boore_thompson_2015_coefs(i_lo, j_lo; region=region)
Dratio = boore_thompson_2015_base(η, c, ζ)
else # we need to interpolate the distance values only
r_lo = r_jj_bt15[j_lo]
r_hi = r_jj_bt15[j_hi]
c_lo = boore_thompson_2015_coefs(i_lo, j_lo; region=region)
c_hi = boore_thompson_2015_coefs(i_lo, j_hi; region=region)
D_lo = boore_thompson_2015_base(η, c_lo, ζ)
D_hi = boore_thompson_2015_base(η, c_hi, ζ)
lnDratio = log(D_lo) + (r_ps - r_lo) / (r_hi - r_lo) * log(D_hi / D_lo)
Dratio = exp(lnDratio)
end
else # we need to interpolate the magnitudes
if j_lo == j_hi # we have coefficients for this distance
m_lo = m_ii_bt15[i_lo]
m_hi = m_ii_bt15[i_hi]
c_lo = boore_thompson_2015_coefs(i_lo, j_lo; region=region)
c_hi = boore_thompson_2015_coefs(i_hi, j_lo; region=region)
D_lo = boore_thompson_2015_base(η, c_lo, ζ)
D_hi = boore_thompson_2015_base(η, c_hi, ζ)
lnDratio = log(D_lo) + (m - m_lo) / (m_hi - m_lo) * log(D_hi / D_lo)
Dratio = exp(lnDratio)
else # we need to interpolate for this magnitude and distance
# create the combinations of (m,r) from these indices
m_lo = m_ii_bt15[i_lo]
m_hi = m_ii_bt15[i_hi]
r_lo = r_jj_bt15[j_lo]
r_hi = r_jj_bt15[j_hi]
# get the corresponding coefficients
c_ll = boore_thompson_2015_coefs(i_lo, j_lo; region=region)
c_lh = boore_thompson_2015_coefs(i_lo, j_hi; region=region)
c_hl = boore_thompson_2015_coefs(i_hi, j_lo; region=region)
c_hh = boore_thompson_2015_coefs(i_hi, j_hi; region=region)
# get the corresponding ratios
Dr_ll = boore_thompson_2015_base(η, c_ll, ζ)
Dr_lh = boore_thompson_2015_base(η, c_lh, ζ)
Dr_hl = boore_thompson_2015_base(η, c_hl, ζ)
Dr_hh = boore_thompson_2015_base(η, c_hh, ζ)
# bilinear interpolation
# used repeated linear interpolation as the fastest method
Δm = m_hi - m_lo
Δr = r_hi - r_lo
fac = 1.0 / (Δm * Δr)
lnDr_ll = log(Dr_ll)
lnDr_lh = log(Dr_lh)
lnDr_hl = log(Dr_hl)
lnDr_hh = log(Dr_hh)
lnDratio = fac * ((lnDr_ll * (r_hi - r_ps) + lnDr_lh * (r_ps - r_lo)) * (m_hi - m) + (lnDr_hl * (r_hi - r_ps) + lnDr_hh * (r_ps - r_lo)) * (m - m_lo))
Dratio = exp(lnDratio)
end
end
Drms = Dratio * Dex
return (Drms, Dex, Dratio)
end
boore_thompson_2015(m, r_ps, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters) = boore_thompson_2015(m, r_ps, fas.source, sdof, rvt)
"""
liu_pezeshk_1999(m, r_ps::T, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {T<:Real}
Liu & Pezeshk (1999) rms duration model. Also outputs the excitation duration (given that its required within the rms duration calculations).
"""
function liu_pezeshk_1999(m, r_ps::T, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {T<:Real}
# get the excitation duration
Dex = excitation_duration(m, r_ps, fas, rvt)
# oscillator duration
Dosc = 1.0 / ( 2π * sdof.f_n * sdof.ζ_n )
# gamma parameter
γ = Dex / Dosc
# spectral moments, required for use within definition of α parameter
mi = spectral_moments([0,1,2], m, r_ps, fas, sdof)
m0 = mi.m0
m1 = mi.m1
m2 = mi.m2
# define α
α = sqrt( 2π * (1.0 - ( m1^2 )/( m0*m2 )) )
n = 2.0
# RMS duration
Drms = Dex + Dosc * (γ^n / (γ^n + α))
Dratio = Drms / Dex
return (Drms, Dex, Dratio)
end
"""
rms_duration(m::S, r_ps::T, src::SourceParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {T<:Real}
Returns a 3-tuple of (Drms, Dex, Dratio), using a switch on `rvt.dur_rms`.
Default `rvt` makes use of the `:BT14` model for excitation duration, `Dex`.
- `m` is magnitude
- `r_ps` is an equivalent point source distance
"""
function rms_duration(m, r_ps::T, src::SourceParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {T<:Real}
if (rvt.dur_rms == :BT15) && (rvt.pf_method == :DK80)
return boore_thompson_2015(m, r_ps, src, sdof, rvt)
elseif (rvt.dur_rms == :BT12) && (rvt.pf_method == :CL56)
return boore_thompson_2012(m, r_ps, src, sdof, rvt)
elseif (rvt.dur_rms == :LP99) && (rvt.pf_method == :CL56)
return liu_pezeshk_1999(m, r_ps, src, sdof, rvt)
# println("Cannot pass `src::SourceParameters` for `rvt.dur_rms == :LP99`; method requires full `fas::FourierParameters` input")
# return (T(NaN), T(NaN), T(NaN))
else
println("Inconsistent combination of `rvt.dur_rms` and `rvt.pf_method`")
return (T(NaN), T(NaN), T(NaN))
end
end
function rms_duration(m, r_ps, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters)
if (rvt.dur_rms == :LP99) && (rvt.pf_method == :CL56)
return liu_pezeshk_1999(m, r_ps, fas, sdof, rvt)
else
return rms_duration(m, r_ps, fas.source, sdof, rvt)
end
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 34549 |
# Definition of Boore & Thompson (2012) constant values to be used within subsequent functions
const m_ii_bt12 = [ 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0 ]
const r_jj_bt12 = [ 2.00, 3.17, 5.02, 7.96, 12.62, 20.00, 31.70, 50.24, 79.62, 126.19, 200.00, 317.00, 502.40, 796.20, 1262.00 ]
const num_m_ii_bt12 = 9
const num_r_jj_bt12 = 15
const coefs_wna_bt12 = [ 4.0 2.00 8.4312e-01 -2.8671e-02 2.0 1.7316e+00 1.1695e+00 2.1671e+00 9.6224e-01 9.9929e-01 9.4336e-01 4.0 2.00;
4.5 2.00 8.3064e-01 -5.3355e-08 2.0 1.6962e+00 1.3236e+00 2.0308e+00 9.5517e-01 1.0176e+00 9.6580e-01 4.5 2.00;
5.0 2.00 8.9701e-01 -1.0484e-02 2.0 1.7181e+00 1.2797e+00 1.9295e+00 1.0163e+00 1.0290e+00 9.6175e-01 5.0 2.00;
5.5 2.00 8.3574e-01 -1.2031e-06 2.0 1.3859e+00 1.2015e+00 1.9904e+00 8.1829e-01 1.0523e+00 9.8336e-01 5.5 2.00;
6.0 2.00 8.4485e-01 -1.2609e-02 2.0 1.2391e+00 9.9399e-01 2.0532e+00 7.4884e-01 1.0681e+00 9.7567e-01 6.0 2.00;
6.5 2.00 8.4348e-01 -1.4520e-06 2.0 1.1331e+00 9.3441e-01 2.0328e+00 7.1150e-01 1.0680e+00 9.7535e-01 6.5 2.00;
7.0 2.00 8.0078e-01 -1.0231e-03 2.0 9.9676e-01 8.0084e-01 2.1466e+00 5.9286e-01 1.0908e+00 9.7381e-01 7.0 2.00;
7.5 2.00 8.3352e-01 -2.0697e-03 2.0 9.4601e-01 8.2133e-01 2.1052e+00 6.1011e-01 1.0849e+00 9.5386e-01 7.5 2.00;
8.0 2.00 1.1818e+00 -3.7875e-01 2.0 7.6114e-01 2.4868e+00 3.4051e+00 5.1616e-01 1.1002e+00 9.3188e-01 8.0 2.00;
4.0 3.17 8.2110e-01 -4.7357e-03 2.0 1.8627e+00 1.6118e+00 2.0128e+00 9.6557e-01 1.0024e+00 9.6134e-01 4.0 3.17;
4.5 3.17 8.7601e-01 -5.9903e-07 2.0 1.8200e+00 1.4626e+00 1.9542e+00 1.0076e+00 1.0074e+00 9.5429e-01 4.5 3.17;
5.0 3.17 8.3971e-01 -3.0439e-03 2.0 1.5964e+00 1.3635e+00 1.9761e+00 8.9640e-01 1.0425e+00 9.7057e-01 5.0 3.17;
5.5 3.17 8.3455e-01 -2.8341e-06 2.0 1.3116e+00 1.1068e+00 2.0414e+00 7.7989e-01 1.0458e+00 9.8125e-01 5.5 3.17;
6.0 3.17 8.1645e-01 -8.3202e-08 2.0 1.1908e+00 9.8968e-01 2.0549e+00 6.9953e-01 1.0647e+00 9.7531e-01 6.0 3.17;
6.5 3.17 8.2440e-01 -2.2922e-19 2.0 1.1212e+00 9.2690e-01 2.0537e+00 6.7673e-01 1.0722e+00 9.7217e-01 6.5 3.17;
7.0 3.17 8.3242e-01 -4.0859e-03 2.0 1.0919e+00 1.0439e+00 2.0355e+00 6.6335e-01 1.0850e+00 9.6470e-01 7.0 3.17;
7.5 3.17 8.3241e-01 -8.3435e-03 2.0 1.1067e+00 1.1521e+00 1.9907e+00 6.4715e-01 1.0951e+00 9.4210e-01 7.5 3.17;
8.0 3.17 8.3994e-01 -2.6168e-02 2.0 9.6494e-01 9.0967e-01 2.2436e+00 5.8696e-01 1.1028e+00 9.2279e-01 8.0 3.17;
4.0 5.02 8.6329e-01 -4.0771e-02 2.0 1.8792e+00 1.7825e+00 2.0071e+00 9.5979e-01 1.0150e+00 9.6497e-01 4.0 5.02;
4.5 5.02 8.4825e-01 -5.8380e-05 2.0 1.8285e+00 1.6611e+00 1.9249e+00 9.6711e-01 1.0252e+00 9.7713e-01 4.5 5.02;
5.0 5.02 8.4446e-01 -3.4661e-22 2.0 1.5463e+00 1.4665e+00 1.9448e+00 8.6771e-01 1.0329e+00 9.7563e-01 5.0 5.02;
5.5 5.02 8.4978e-01 -6.2734e-09 2.0 1.5126e+00 1.4004e+00 1.9072e+00 8.4997e-01 1.0460e+00 9.7378e-01 5.5 5.02;
6.0 5.02 8.2129e-01 -4.5730e-06 2.0 1.2115e+00 1.0578e+00 2.0028e+00 7.0987e-01 1.0598e+00 9.7654e-01 6.0 5.02;
6.5 5.02 8.1544e-01 -1.9160e-08 2.0 1.0668e+00 8.4143e-01 2.0735e+00 6.5158e-01 1.0751e+00 9.7467e-01 6.5 5.02;
7.0 5.02 8.2414e-01 -4.0369e-03 2.0 1.0467e+00 7.1242e-01 2.1586e+00 6.2836e-01 1.0794e+00 9.5870e-01 7.0 5.02;
7.5 5.02 8.9473e-01 -5.3853e-02 2.0 1.0888e+00 1.4138e+00 2.0212e+00 6.7776e-01 1.0900e+00 9.5025e-01 7.5 5.02;
8.0 5.02 9.2147e-01 -8.9899e-02 2.0 9.5008e-01 1.1607e+00 2.4017e+00 6.2635e-01 1.0980e+00 9.2819e-01 8.0 5.02;
4.0 7.96 8.4779e-01 -2.8493e-02 2.0 2.0858e+00 2.6221e+00 1.8501e+00 9.5690e-01 1.0194e+00 9.7959e-01 4.0 7.96;
4.5 7.96 8.4677e-01 -2.1554e-14 2.0 1.9701e+00 2.2219e+00 1.7755e+00 9.8498e-01 1.0316e+00 9.9715e-01 4.5 7.96;
5.0 7.96 8.8283e-01 -4.1263e-07 2.0 1.9400e+00 1.8389e+00 1.8013e+00 1.0235e+00 1.0334e+00 9.7377e-01 5.0 7.96;
5.5 7.96 8.2785e-01 -8.1587e-17 2.0 1.4890e+00 1.4475e+00 1.9052e+00 8.1571e-01 1.0561e+00 9.8353e-01 5.5 7.96;
6.0 7.96 8.3393e-01 -4.2583e-08 2.0 1.4016e+00 1.4232e+00 1.8975e+00 7.8526e-01 1.0658e+00 9.7835e-01 6.0 7.96;
6.5 7.96 8.1429e-01 -2.8150e-05 2.0 1.0955e+00 9.3363e-01 2.0547e+00 6.6504e-01 1.0786e+00 9.8445e-01 6.5 7.96;
7.0 7.96 8.0350e-01 -3.1805e-06 2.0 1.0903e+00 1.0120e+00 2.0825e+00 6.3175e-01 1.0930e+00 9.6779e-01 7.0 7.96;
7.5 7.96 8.6455e-01 -4.9497e-02 2.0 1.0672e+00 1.3965e+00 2.0600e+00 6.2719e-01 1.0924e+00 9.5518e-01 7.5 7.96;
8.0 7.96 9.3068e-01 -1.0354e-01 2.0 1.0295e+00 1.7393e+00 2.1326e+00 6.3596e-01 1.0994e+00 9.2609e-01 8.0 7.96;
4.0 12.62 8.4343e-01 -9.4015e-03 2.0 1.7138e+00 2.7357e+00 1.8332e+00 8.7570e-01 1.0193e+00 9.9529e-01 4.0 12.62;
4.5 12.62 8.2603e-01 -1.5203e-02 2.0 1.7515e+00 2.3023e+00 1.8093e+00 8.6816e-01 1.0462e+00 9.9553e-01 4.5 12.62;
5.0 12.62 8.5078e-01 -6.8471e-17 2.0 1.6943e+00 1.8025e+00 1.7993e+00 9.1795e-01 1.0461e+00 1.0026e+00 5.0 12.62;
5.5 12.62 8.4406e-01 -4.2873e-07 2.0 1.6936e+00 1.6701e+00 1.7942e+00 8.9001e-01 1.0584e+00 9.8314e-01 5.5 12.62;
6.0 12.62 8.1873e-01 -9.7554e-08 2.0 1.3379e+00 1.3058e+00 1.9370e+00 7.4590e-01 1.0649e+00 9.8476e-01 6.0 12.62;
6.5 12.62 8.2130e-01 -1.1179e-06 2.0 1.0666e+00 9.5527e-01 2.0441e+00 6.5972e-01 1.0706e+00 9.9066e-01 6.5 12.62;
7.0 12.62 8.3901e-01 -3.8867e-03 2.0 1.0721e+00 9.7602e-01 2.0319e+00 6.7214e-01 1.0773e+00 9.7088e-01 7.0 12.62;
7.5 12.62 8.8154e-01 -5.3242e-02 2.0 1.0746e+00 1.4629e+00 2.0001e+00 6.4928e-01 1.0882e+00 9.4526e-01 7.5 12.62;
8.0 12.62 9.6254e-01 -1.5468e-01 2.0 8.4972e-01 1.1369e+00 2.6445e+00 5.5070e-01 1.0967e+00 9.2600e-01 8.0 12.62;
4.0 20.00 8.4020e-01 -4.0622e-03 2.0 1.7122e+00 3.7111e+00 1.7781e+00 8.3369e-01 1.0231e+00 1.0055e+00 4.0 20.00;
4.5 20.00 8.0074e-01 -1.1163e-03 2.0 1.6050e+00 2.5984e+00 1.7981e+00 8.0776e-01 1.0514e+00 1.0107e+00 4.5 20.00;
5.0 20.00 8.1957e-01 -2.6783e-08 2.0 1.5537e+00 1.9525e+00 1.8541e+00 8.1185e-01 1.0503e+00 9.9790e-01 5.0 20.00;
5.5 20.00 8.4597e-01 -2.1761e-28 2.0 1.6384e+00 1.8613e+00 1.7709e+00 8.6430e-01 1.0543e+00 9.8634e-01 5.5 20.00;
6.0 20.00 8.1936e-01 -2.8792e-08 2.0 1.2967e+00 1.3933e+00 1.9226e+00 7.3484e-01 1.0646e+00 9.9737e-01 6.0 20.00;
6.5 20.00 8.2149e-01 -2.1626e-07 2.0 1.2651e+00 1.1833e+00 1.8904e+00 7.2337e-01 1.0798e+00 9.7962e-01 6.5 20.00;
7.0 20.00 8.2885e-01 -1.4510e-02 2.0 1.0514e+00 8.6325e-01 2.0854e+00 6.3459e-01 1.0858e+00 9.7187e-01 7.0 20.00;
7.5 20.00 8.8599e-01 -6.7109e-02 2.0 1.0820e+00 1.4223e+00 2.1483e+00 6.5140e-01 1.0931e+00 9.5410e-01 7.5 20.00;
8.0 20.00 9.6561e-01 -1.5069e-01 2.0 9.2494e-01 1.6108e+00 2.3995e+00 5.7877e-01 1.0942e+00 9.3791e-01 8.0 20.00;
4.0 31.70 8.1172e-01 -4.8496e-04 2.0 1.5154e+00 4.2066e+00 1.7868e+00 7.5495e-01 1.0411e+00 1.0121e+00 4.0 31.70;
4.5 31.70 7.8971e-01 -1.1171e-07 2.0 1.3881e+00 2.8525e+00 1.9129e+00 7.1011e-01 1.0446e+00 1.0101e+00 4.5 31.70;
5.0 31.70 7.8907e-01 -3.0999e-07 2.0 1.3945e+00 1.9681e+00 1.8882e+00 7.2307e-01 1.0590e+00 1.0093e+00 5.0 31.70;
5.5 31.70 8.2863e-01 -4.3712e-29 2.0 1.5918e+00 1.8609e+00 1.7700e+00 8.3632e-01 1.0636e+00 1.0051e+00 5.5 31.70;
6.0 31.70 8.1063e-01 -2.5156e-07 2.0 1.3122e+00 1.4358e+00 1.8632e+00 7.3257e-01 1.0734e+00 1.0013e+00 6.0 31.70;
6.5 31.70 8.1517e-01 -5.7539e-06 2.0 1.1768e+00 1.1135e+00 1.8888e+00 6.9805e-01 1.0796e+00 9.8922e-01 6.5 31.70;
7.0 31.70 8.1577e-01 -1.2460e-04 2.0 1.1862e+00 1.0549e+00 1.9416e+00 6.8195e-01 1.0868e+00 9.6233e-01 7.0 31.70;
7.5 31.70 9.2526e-01 -1.1605e-01 2.0 1.0984e+00 1.6537e+00 2.1768e+00 6.4739e-01 1.0974e+00 9.5360e-01 7.5 31.70;
8.0 31.70 9.0070e-01 -1.0408e-01 2.0 9.3630e-01 1.4596e+00 2.2897e+00 5.6532e-01 1.0993e+00 9.3947e-01 8.0 31.70;
4.0 50.24 7.4376e-01 -9.0204e-03 2.0 1.1760e+00 5.3724e+00 1.9952e+00 5.7376e-01 1.0611e+00 1.0292e+00 4.0 50.24;
4.5 50.24 7.6692e-01 -2.8995e-07 2.0 1.2262e+00 3.1344e+00 1.9104e+00 6.3632e-01 1.0607e+00 1.0303e+00 4.5 50.24;
5.0 50.24 8.0410e-01 -1.7249e-07 2.0 1.2658e+00 2.0493e+00 1.8728e+00 7.1205e-01 1.0610e+00 1.0300e+00 5.0 50.24;
5.5 50.24 8.0289e-01 -7.3756e-10 2.0 1.3033e+00 1.9082e+00 1.8283e+00 7.1257e-01 1.0611e+00 1.0228e+00 5.5 50.24;
6.0 50.24 8.2058e-01 -3.3962e-07 2.0 1.4215e+00 1.7148e+00 1.7918e+00 7.7238e-01 1.0701e+00 9.9697e-01 6.0 50.24;
6.5 50.24 8.1998e-01 -3.7615e-08 2.0 1.3171e+00 1.5287e+00 1.8113e+00 7.3336e-01 1.0743e+00 9.8469e-01 6.5 50.24;
7.0 50.24 8.0401e-01 -1.8401e-03 2.0 1.2092e+00 1.1668e+00 1.9378e+00 6.7879e-01 1.0950e+00 9.7028e-01 7.0 50.24;
7.5 50.24 9.2124e-01 -1.1109e-01 2.0 1.0821e+00 1.7469e+00 2.2082e+00 6.4069e-01 1.0886e+00 9.5945e-01 7.5 50.24;
8.0 50.24 9.1213e-01 -1.0459e-01 2.0 1.0303e+00 1.7188e+00 2.1460e+00 6.1959e-01 1.0951e+00 9.3272e-01 8.0 50.24;
4.0 79.62 7.1877e-01 -8.4424e-07 2.0 9.8189e-01 5.7882e+00 1.9315e+00 4.8869e-01 1.0633e+00 1.0405e+00 4.0 79.62;
4.5 79.62 7.6806e-01 -7.7865e-10 2.0 1.1500e+00 4.2410e+00 1.8852e+00 5.8860e-01 1.0545e+00 1.0258e+00 4.5 79.62;
5.0 79.62 8.1221e-01 -1.9339e-06 2.0 1.3867e+00 3.2310e+00 1.7712e+00 7.2172e-01 1.0557e+00 1.0225e+00 5.0 79.62;
5.5 79.62 8.1179e-01 -3.6814e-15 2.0 1.3673e+00 2.3510e+00 1.7695e+00 7.3065e-01 1.0617e+00 1.0209e+00 5.5 79.62;
6.0 79.62 8.3805e-01 -3.9863e-07 2.0 1.4750e+00 1.7874e+00 1.7191e+00 8.0489e-01 1.0630e+00 1.0006e+00 6.0 79.62;
6.5 79.62 8.3461e-01 -3.2932e-04 2.0 1.5359e+00 1.6907e+00 1.7029e+00 8.1570e-01 1.0730e+00 9.7817e-01 6.5 79.62;
7.0 79.62 8.2516e-01 -1.0574e-03 2.0 1.4617e+00 1.6598e+00 1.7075e+00 7.8372e-01 1.0840e+00 9.7763e-01 7.0 79.62;
7.5 79.62 9.2678e-01 -1.2826e-01 2.0 1.0954e+00 1.8061e+00 2.2617e+00 6.3883e-01 1.0935e+00 9.5951e-01 7.5 79.62;
8.0 79.62 9.4781e-01 -1.3027e-01 2.0 1.1123e+00 1.9835e+00 2.2682e+00 6.5983e-01 1.0897e+00 9.3568e-01 8.0 79.62;
4.0 126.19 7.0065e-01 -3.0866e-03 2.0 7.7514e-01 4.3880e+00 2.1942e+00 3.9751e-01 1.0665e+00 1.0430e+00 4.0 126.19;
4.5 126.19 7.3944e-01 -6.1421e-03 2.0 8.4700e-01 3.1720e+00 2.1861e+00 4.6495e-01 1.0631e+00 1.0421e+00 4.5 126.19;
5.0 126.19 8.0513e-01 -3.1300e-07 2.0 1.4173e+00 3.7696e+00 1.7451e+00 7.2746e-01 1.0661e+00 1.0375e+00 5.0 126.19;
5.5 126.19 8.3644e-01 -1.2787e-02 2.0 1.6253e+00 3.0751e+00 1.6687e+00 8.0811e-01 1.0660e+00 1.0188e+00 5.5 126.19;
6.0 126.19 8.4568e-01 -1.0589e-02 2.0 1.6317e+00 2.5450e+00 1.6207e+00 8.3600e-01 1.0663e+00 1.0196e+00 6.0 126.19;
6.5 126.19 8.4142e-01 -9.2432e-03 2.0 1.6367e+00 2.2281e+00 1.6330e+00 8.4571e-01 1.0759e+00 1.0072e+00 6.5 126.19;
7.0 126.19 8.3694e-01 -1.8592e-12 2.0 1.4260e+00 1.8587e+00 1.6980e+00 7.8752e-01 1.0719e+00 9.9019e-01 7.0 126.19;
7.5 126.19 9.7787e-01 -1.5087e-01 2.0 1.3198e+00 2.7095e+00 2.0948e+00 7.4851e-01 1.0802e+00 9.6889e-01 7.5 126.19;
8.0 126.19 9.5551e-01 -1.3687e-01 2.0 1.0502e+00 1.6420e+00 2.2945e+00 6.6223e-01 1.0834e+00 9.5884e-01 8.0 126.19;
4.0 200.00 7.2408e-01 -3.7872e-06 2.0 7.9315e-01 3.3863e+00 2.1194e+00 4.3168e-01 1.0731e+00 1.0494e+00 4.0 200.00;
4.5 200.00 7.6883e-01 -1.0649e-10 2.0 8.4489e-01 3.0451e+00 2.0022e+00 5.1530e-01 1.0674e+00 1.0491e+00 4.5 200.00;
5.0 200.00 8.0446e-01 -1.1419e-07 2.0 1.2079e+00 3.5405e+00 1.7311e+00 6.7846e-01 1.0708e+00 1.0434e+00 5.0 200.00;
5.5 200.00 8.5125e-01 -2.0805e-02 2.0 1.6828e+00 3.7940e+00 1.5949e+00 8.1298e-01 1.0634e+00 1.0157e+00 5.5 200.00;
6.0 200.00 8.8936e-01 -3.4678e-02 2.0 1.9176e+00 3.6113e+00 1.5457e+00 9.0903e-01 1.0583e+00 1.0253e+00 6.0 200.00;
6.5 200.00 8.8360e-01 -4.3347e-02 2.0 2.1189e+00 3.0810e+00 1.5627e+00 9.3733e-01 1.0723e+00 1.0070e+00 6.5 200.00;
7.0 200.00 8.8401e-01 -4.3273e-02 2.0 2.2411e+00 3.1543e+00 1.5785e+00 9.5961e-01 1.0768e+00 9.8898e-01 7.0 200.00;
7.5 200.00 9.7709e-01 -1.3800e-01 2.0 1.3833e+00 2.6413e+00 2.0144e+00 7.8650e-01 1.0724e+00 9.7395e-01 7.5 200.00;
8.0 200.00 9.4766e-01 -1.2599e-01 2.0 1.0937e+00 1.7927e+00 2.1485e+00 6.8255e-01 1.0817e+00 9.6134e-01 8.0 200.00;
4.0 317.00 7.3621e-01 -2.6124e-07 2.0 6.7866e-01 1.5442e+00 2.3208e+00 4.0993e-01 1.0759e+00 1.0570e+00 4.0 317.00;
4.5 317.00 7.7046e-01 -2.0803e-06 2.0 8.4695e-01 2.4074e+00 1.9286e+00 5.2494e-01 1.0786e+00 1.0462e+00 4.5 317.00;
5.0 317.00 8.3255e-01 -8.9857e-03 2.0 1.2272e+00 3.5393e+00 1.6207e+00 6.9898e-01 1.0666e+00 1.0366e+00 5.0 317.00;
5.5 317.00 9.3328e-01 -9.4425e-02 2.0 1.7388e+00 5.6367e+00 1.5939e+00 8.2772e-01 1.0637e+00 1.0337e+00 5.5 317.00;
6.0 317.00 9.6786e-01 -1.0575e-01 2.0 2.0371e+00 4.4326e+00 1.5835e+00 9.3047e-01 1.0545e+00 1.0163e+00 6.0 317.00;
6.5 317.00 9.9191e-01 -1.2806e-01 2.0 2.2631e+00 4.7905e+00 1.5624e+00 9.7756e-01 1.0573e+00 1.0188e+00 6.5 317.00;
7.0 317.00 9.8463e-01 -1.2911e-01 2.0 2.4172e+00 4.1328e+00 1.5968e+00 1.0248e+00 1.0671e+00 1.0121e+00 7.0 317.00;
7.5 317.00 9.8211e-01 -1.4721e-01 2.0 1.4960e+00 2.3251e+00 2.0687e+00 8.3602e-01 1.0789e+00 9.7502e-01 7.5 317.00;
8.0 317.00 9.8036e-01 -1.3181e-01 2.0 1.4355e+00 2.1624e+00 2.0674e+00 8.5037e-01 1.0726e+00 9.6315e-01 8.0 317.00;
4.0 502.40 7.7145e-01 -2.1903e-08 2.0 7.5501e-01 1.2254e+00 1.9918e+00 4.8005e-01 1.0784e+00 1.0568e+00 4.0 502.40;
4.5 502.40 8.3924e-01 -1.7176e-02 2.0 8.4240e-01 1.7566e+00 1.7682e+00 5.8451e-01 1.0631e+00 1.0452e+00 4.5 502.40;
5.0 502.40 8.6317e-01 -3.0913e-02 2.0 1.2712e+00 3.3879e+00 1.4455e+00 7.1360e-01 1.0659e+00 1.0382e+00 5.0 502.40;
5.5 502.40 9.3729e-01 -1.1001e-01 2.0 1.9503e+00 6.6024e+00 1.4210e+00 8.4644e-01 1.0762e+00 1.0447e+00 5.5 502.40;
6.0 502.40 9.8756e-01 -1.2780e-01 2.0 2.3398e+00 5.8967e+00 1.4040e+00 9.5484e-01 1.0593e+00 1.0275e+00 6.0 502.40;
6.5 502.40 1.0255e+00 -1.6704e-01 2.0 2.7393e+00 5.7808e+00 1.5652e+00 1.0339e+00 1.0626e+00 1.0108e+00 6.5 502.40;
7.0 502.40 1.0233e+00 -1.6031e-01 2.0 2.9463e+00 4.5741e+00 1.5529e+00 1.0997e+00 1.0652e+00 1.0006e+00 7.0 502.40;
7.5 502.40 1.0200e+00 -1.2401e-01 2.0 3.0000e+00 3.9155e+00 1.6445e+00 1.1560e+00 1.0461e+00 9.6435e-01 7.5 502.40;
8.0 502.40 1.0002e+00 -1.1999e-01 2.0 2.5675e+00 3.3955e+00 1.6785e+00 1.1070e+00 1.0599e+00 9.6587e-01 8.0 502.40;
4.0 796.20 8.8270e-01 -8.3018e-02 2.0 1.2361e+00 3.2178e+00 1.2860e+00 6.5438e-01 1.0883e+00 1.0605e+00 4.0 796.20;
4.5 796.20 9.0131e-01 -9.0819e-02 2.0 1.4035e+00 3.7970e+00 1.3032e+00 7.1226e-01 1.0843e+00 1.0593e+00 4.5 796.20;
5.0 796.20 9.3558e-01 -8.3350e-02 2.0 1.5771e+00 4.0563e+00 1.2214e+00 7.8376e-01 1.0603e+00 1.0343e+00 5.0 796.20;
5.5 796.20 9.8071e-01 -1.2639e-01 2.0 2.1823e+00 5.4690e+00 1.2828e+00 8.9979e-01 1.0625e+00 1.0402e+00 5.5 796.20;
6.0 796.20 1.0292e+00 -1.6994e-01 2.0 2.9999e+00 6.5631e+00 1.2973e+00 1.0071e+00 1.0608e+00 1.0173e+00 6.0 796.20;
6.5 796.20 1.0716e+00 -2.0385e-01 2.0 3.0000e+00 6.0142e+00 1.4500e+00 1.0802e+00 1.0575e+00 1.0181e+00 6.5 796.20;
7.0 796.20 1.1170e+00 -2.2503e-01 2.0 3.0000e+00 5.5908e+00 1.6436e+00 1.1310e+00 1.0466e+00 1.0011e+00 7.0 796.20;
7.5 796.20 1.1243e+00 -2.3116e-01 2.0 3.0000e+00 4.7524e+00 1.7099e+00 1.1844e+00 1.0490e+00 9.9987e-01 7.5 796.20;
8.0 796.20 1.0006e+00 -1.1062e-01 2.0 2.8163e+00 3.0643e+00 1.6161e+00 1.2033e+00 1.0543e+00 9.8424e-01 8.0 796.20;
4.0 1262.00 1.1142e+00 -2.9561e-01 2.0 1.6692e+00 6.1510e+00 1.3141e+00 7.6115e-01 1.0829e+00 1.0502e+00 4.0 1262.00;
4.5 1262.00 1.1450e+00 -2.8700e-01 2.0 1.9553e+00 6.0141e+00 1.2838e+00 8.6221e-01 1.0634e+00 1.0392e+00 4.5 1262.00;
5.0 1262.00 1.1431e+00 -3.0083e-01 2.0 2.2941e+00 6.8268e+00 1.2609e+00 8.9057e-01 1.0726e+00 1.0475e+00 5.0 1262.00;
5.5 1262.00 1.1467e+00 -2.7310e-01 2.0 2.5178e+00 6.9746e+00 1.3125e+00 9.6257e-01 1.0554e+00 1.0372e+00 5.5 1262.00;
6.0 1262.00 1.1623e+00 -2.9893e-01 2.0 3.0000e+00 7.2278e+00 1.4351e+00 1.0457e+00 1.0629e+00 1.0252e+00 6.0 1262.00;
6.5 1262.00 1.2000e+00 -3.2059e-01 2.0 3.0000e+00 7.6028e+00 1.5529e+00 1.0983e+00 1.0535e+00 1.0295e+00 6.5 1262.00;
7.0 1262.00 1.2000e+00 -3.0723e-01 2.0 3.0000e+00 6.1282e+00 1.6668e+00 1.1508e+00 1.0466e+00 1.0024e+00 7.0 1262.00;
7.5 1262.00 1.2000e+00 -3.0499e-01 2.0 3.0000e+00 5.0982e+00 1.7273e+00 1.2181e+00 1.0481e+00 1.0067e+00 7.5 1262.00;
8.0 1262.00 1.2000e+00 -3.0348e-01 2.0 3.0000e+00 4.2696e+00 1.8291e+00 1.2610e+00 1.0492e+00 9.8681e-01 8.0 1262.00 ]
const coefs_ena_bt12 = [ 4.0 2.00 7.4499e-01 -3.0772e-02 2.0 1.3928e+00 8.3838e-01 2.4979e+00 6.7955e-01 1.0253e+00 9.6354e-01 4.0 2.00;
4.5 2.00 7.6659e-01 -3.0413e-02 2.0 1.3636e+00 9.7771e-01 2.3632e+00 6.9419e-01 1.0538e+00 9.6656e-01 4.5 2.00;
5.0 2.00 8.5088e-01 -2.7815e-06 2.0 1.2579e+00 9.8032e-01 2.0749e+00 7.8838e-01 1.0598e+00 9.5727e-01 5.0 2.00;
5.5 2.00 7.6469e-01 -1.0292e-07 2.0 1.1153e+00 8.5585e-01 2.1955e+00 6.0514e-01 1.0745e+00 9.7063e-01 5.5 2.00;
6.0 2.00 8.0539e-01 -4.1307e-17 2.0 1.0631e+00 8.3666e-01 2.1792e+00 6.3713e-01 1.0776e+00 9.5917e-01 6.0 2.00;
6.5 2.00 8.2454e-01 -1.1132e-16 2.0 1.0240e+00 7.5717e-01 2.1935e+00 6.4412e-01 1.0957e+00 9.4398e-01 6.5 2.00;
7.0 2.00 8.4196e-01 -8.3632e-03 2.0 9.8648e-01 7.3577e-01 2.2221e+00 6.4268e-01 1.1001e+00 9.1936e-01 7.0 2.00;
7.5 2.00 8.0918e-01 -1.9895e-06 2.0 9.1407e-01 7.9186e-01 2.2626e+00 5.7595e-01 1.1080e+00 9.0618e-01 7.5 2.00;
8.0 2.00 1.1574e+00 -4.1628e-01 2.0 7.1549e-01 3.3332e+00 4.1754e+00 4.0981e-01 1.1114e+00 8.7461e-01 8.0 2.00;
4.0 3.17 7.4249e-01 -3.4061e-02 2.0 1.3792e+00 8.1130e-01 2.5371e+00 6.6759e-01 1.0251e+00 9.6351e-01 4.0 3.17;
4.5 3.17 7.7349e-01 -2.2472e-02 2.0 1.3817e+00 9.9520e-01 2.3073e+00 7.2181e-01 1.0535e+00 9.6624e-01 4.5 3.17;
5.0 3.17 8.5089e-01 -4.4519e-07 2.0 1.2735e+00 9.9594e-01 2.0666e+00 7.9499e-01 1.0601e+00 9.5733e-01 5.0 3.17;
5.5 3.17 7.6277e-01 -3.8418e-08 2.0 1.1145e+00 8.4433e-01 2.2020e+00 6.0264e-01 1.0744e+00 9.7069e-01 5.5 3.17;
6.0 3.17 8.0431e-01 -1.3389e-17 2.0 1.0649e+00 8.3603e-01 2.1806e+00 6.3657e-01 1.0778e+00 9.5924e-01 6.0 3.17;
6.5 3.17 8.2327e-01 -9.8165e-21 2.0 1.0255e+00 7.5555e-01 2.1958e+00 6.4310e-01 1.0954e+00 9.4426e-01 6.5 3.17;
7.0 3.17 8.4445e-01 -1.2431e-02 2.0 9.8210e-01 7.3887e-01 2.2377e+00 6.3896e-01 1.1000e+00 9.1991e-01 7.0 3.17;
7.5 3.17 8.0631e-01 -4.7208e-07 2.0 9.0758e-01 7.6090e-01 2.2867e+00 5.6936e-01 1.1083e+00 9.0648e-01 7.5 3.17;
8.0 3.17 1.1238e+00 -3.3574e-01 2.0 7.3859e-01 2.2882e+00 3.4862e+00 4.8200e-01 1.1122e+00 8.7493e-01 8.0 3.17;
4.0 5.02 7.4005e-01 -3.5818e-02 2.0 1.3817e+00 8.0165e-01 2.5506e+00 6.6482e-01 1.0248e+00 9.6350e-01 4.0 5.02;
4.5 5.02 7.7668e-01 -1.8238e-02 2.0 1.3961e+00 1.0010e+00 2.2827e+00 7.3750e-01 1.0531e+00 9.6663e-01 4.5 5.02;
5.0 5.02 8.5014e-01 -3.3214e-07 2.0 1.2845e+00 1.0033e+00 2.0625e+00 7.9911e-01 1.0594e+00 9.5759e-01 5.0 5.02;
5.5 5.02 7.6180e-01 -2.1336e-17 2.0 1.1175e+00 8.4272e-01 2.2037e+00 6.0313e-01 1.0745e+00 9.7063e-01 5.5 5.02;
6.0 5.02 8.0269e-01 -2.0009e-17 2.0 1.0693e+00 8.3770e-01 2.1815e+00 6.3637e-01 1.0776e+00 9.5939e-01 6.0 5.02;
6.5 5.02 8.2171e-01 -3.0971e-31 2.0 1.0280e+00 7.5486e-01 2.1982e+00 6.4214e-01 1.0955e+00 9.4444e-01 6.5 5.02;
7.0 5.02 8.4613e-01 -1.5745e-02 2.0 9.8072e-01 7.4313e-01 2.2508e+00 6.3615e-01 1.0995e+00 9.1966e-01 7.0 5.02;
7.5 5.02 8.0493e-01 -6.6301e-08 2.0 9.0662e-01 7.5179e-01 2.2949e+00 5.6713e-01 1.1082e+00 9.0712e-01 7.5 5.02;
8.0 5.02 1.1064e+00 -3.1800e-01 2.0 7.4773e-01 2.1428e+00 3.4018e+00 4.8628e-01 1.1116e+00 8.7545e-01 8.0 5.02;
4.0 7.96 7.3601e-01 -3.8687e-02 2.0 1.3940e+00 7.9664e-01 2.5636e+00 6.6310e-01 1.0243e+00 9.6349e-01 4.0 7.96;
4.5 7.96 7.8586e-01 -7.4996e-03 2.0 1.4162e+00 1.0088e+00 2.2240e+00 7.7432e-01 1.0527e+00 9.6619e-01 4.5 7.96;
5.0 7.96 8.4919e-01 -2.4409e-07 2.0 1.2958e+00 1.0061e+00 2.0606e+00 8.0357e-01 1.0588e+00 9.5731e-01 5.0 7.96;
5.5 7.96 7.6152e-01 -1.7248e-17 2.0 1.1247e+00 8.4775e-01 2.2017e+00 6.0650e-01 1.0740e+00 9.7116e-01 5.5 7.96;
6.0 7.96 8.0101e-01 -5.6871e-34 2.0 1.0761e+00 8.4182e-01 2.1812e+00 6.3750e-01 1.0776e+00 9.5969e-01 6.0 7.96;
6.5 7.96 8.1921e-01 -6.4799e-35 2.0 1.0327e+00 7.5446e-01 2.2011e+00 6.4087e-01 1.0955e+00 9.4462e-01 6.5 7.96;
7.0 7.96 8.4706e-01 -2.0159e-02 2.0 9.7927e-01 7.4729e-01 2.2700e+00 6.3117e-01 1.0997e+00 9.1996e-01 7.0 7.96;
7.5 7.96 8.0254e-01 -1.0004e-19 2.0 9.0843e-01 7.4615e-01 2.3023e+00 5.6478e-01 1.1079e+00 9.0698e-01 7.5 7.96;
8.0 7.96 1.0991e+00 -3.1060e-01 2.0 7.5231e-01 2.0950e+00 3.3597e+00 4.8859e-01 1.1116e+00 8.7612e-01 8.0 7.96;
4.0 12.62 7.0000e-01 -2.4374e-01 2.0 1.7607e+00 6.9945e+00 2.9837e+00 4.0530e-01 1.0529e+00 1.0123e+00 4.0 12.62;
4.5 12.62 8.1100e-01 -5.4627e-02 2.0 1.3644e+00 2.1006e+00 1.9852e+00 6.6942e-01 1.0678e+00 1.0024e+00 4.5 12.62;
5.0 12.62 7.9093e-01 -9.1466e-03 2.0 1.4484e+00 1.7639e+00 1.8515e+00 7.2182e-01 1.0770e+00 9.8893e-01 5.0 12.62;
5.5 12.62 7.8662e-01 -6.4267e-07 2.0 1.1562e+00 1.0929e+00 1.9671e+00 6.4646e-01 1.0865e+00 9.8772e-01 5.5 12.62;
6.0 12.62 8.4063e-01 -3.7478e-07 2.0 1.1179e+00 8.6813e-01 1.9900e+00 7.1682e-01 1.0880e+00 9.6728e-01 6.0 12.62;
6.5 12.62 8.2699e-01 -9.6153e-08 2.0 1.0649e+00 9.0260e-01 2.0259e+00 6.5749e-01 1.0958e+00 9.5398e-01 6.5 12.62;
7.0 12.62 8.0730e-01 -1.0776e-06 2.0 9.7457e-01 7.1721e-01 2.2248e+00 5.9962e-01 1.1051e+00 9.3355e-01 7.0 12.62;
7.5 12.62 8.2952e-01 -1.1781e-02 2.0 9.4264e-01 9.2716e-01 2.2199e+00 6.0866e-01 1.1050e+00 9.2204e-01 7.5 12.62;
8.0 12.62 1.1075e+00 -3.2347e-01 2.0 7.9284e-01 2.4170e+00 3.4246e+00 4.9618e-01 1.1125e+00 8.8831e-01 8.0 12.62;
4.0 20.00 7.0972e-01 -1.5611e-01 2.0 1.0568e+00 1.5270e+01 3.4374e+00 3.3059e-01 1.0844e+00 1.0550e+00 4.0 20.00;
4.5 20.00 7.5373e-01 -3.5155e-02 2.0 1.0502e+00 3.2069e+00 2.1437e+00 5.0568e-01 1.0894e+00 1.0373e+00 4.5 20.00;
5.0 20.00 7.4294e-01 -4.4353e-03 2.0 9.7401e-01 1.3124e+00 2.0837e+00 5.1430e-01 1.0829e+00 1.0347e+00 5.0 20.00;
5.5 20.00 7.2999e-01 -2.9787e-07 2.0 1.0646e+00 8.7860e-01 2.0446e+00 5.2091e-01 1.0870e+00 1.0000e+00 5.5 20.00;
6.0 20.00 7.9094e-01 -2.4672e-17 2.0 1.0599e+00 9.0053e-01 1.9662e+00 5.9849e-01 1.0887e+00 9.8811e-01 6.0 20.00;
6.5 20.00 8.0349e-01 -4.4357e-07 2.0 1.1059e+00 1.1712e+00 1.9580e+00 6.2395e-01 1.0934e+00 9.6524e-01 6.5 20.00;
7.0 20.00 8.2080e-01 -6.2367e-05 2.0 1.1345e+00 1.2266e+00 1.9089e+00 6.6433e-01 1.1049e+00 9.4121e-01 7.0 20.00;
7.5 20.00 8.2713e-01 -1.6679e-02 2.0 9.7085e-01 9.6843e-01 2.1135e+00 5.9319e-01 1.1024e+00 9.1320e-01 7.5 20.00;
8.0 20.00 1.1435e+00 -3.3384e-01 2.0 8.6005e-01 2.9950e+00 3.0842e+00 5.6602e-01 1.1145e+00 8.9025e-01 8.0 20.00;
4.0 31.70 7.5523e-01 -6.1519e-02 2.0 7.0295e-01 1.6974e+01 2.7714e+00 3.5788e-01 1.0968e+00 1.0716e+00 4.0 31.70;
4.5 31.70 7.2579e-01 -7.4006e-02 2.0 8.4409e-01 7.7628e+00 2.6833e+00 3.5510e-01 1.0895e+00 1.0478e+00 4.5 31.70;
5.0 31.70 7.3171e-01 -1.8856e-02 2.0 9.7754e-01 2.6668e+00 2.1737e+00 4.6838e-01 1.0968e+00 1.0442e+00 5.0 31.70;
5.5 31.70 7.4865e-01 -4.8344e-07 2.0 9.7714e-01 1.1250e+00 2.1068e+00 5.1255e-01 1.0960e+00 1.0332e+00 5.5 31.70;
6.0 31.70 7.6646e-01 -3.0853e-07 2.0 1.0203e+00 9.3153e-01 2.0629e+00 5.4787e-01 1.0977e+00 1.0095e+00 6.0 31.70;
6.5 31.70 7.7282e-01 -7.6203e-07 2.0 9.9068e-01 9.3050e-01 2.0019e+00 5.4762e-01 1.1004e+00 9.9098e-01 6.5 31.70;
7.0 31.70 8.0833e-01 -2.0127e-03 2.0 9.9126e-01 1.1425e+00 1.9250e+00 6.0071e-01 1.1018e+00 9.7147e-01 7.0 31.70;
7.5 31.70 8.2974e-01 -1.7129e-02 2.0 9.6726e-01 1.0363e+00 2.0572e+00 5.9916e-01 1.1023e+00 9.2972e-01 7.5 31.70;
8.0 31.70 1.1337e+00 -3.4815e-01 2.0 8.2312e-01 2.8601e+00 3.2358e+00 5.1106e-01 1.1149e+00 8.9638e-01 8.0 31.70;
4.0 50.24 7.0000e-01 -3.3844e-03 2.0 6.2430e-01 2.7092e+01 2.1023e+00 3.3039e-01 1.1043e+00 1.0745e+00 4.0 50.24;
4.5 50.24 7.0000e-01 -1.0683e-03 2.0 7.0260e-01 9.4854e+00 2.2301e+00 3.6400e-01 1.0999e+00 1.0722e+00 4.5 50.24;
5.0 50.24 7.0000e-01 -1.8942e-02 2.0 7.8355e-01 4.0256e+00 2.4505e+00 3.7077e-01 1.0970e+00 1.0617e+00 5.0 50.24;
5.5 50.24 7.0000e-01 -1.6300e-02 2.0 8.8500e-01 1.9832e+00 2.3716e+00 4.0325e-01 1.0971e+00 1.0463e+00 5.5 50.24;
6.0 50.24 7.1272e-01 -1.4726e-07 2.0 8.9286e-01 8.1783e-01 2.3500e+00 4.3997e-01 1.0965e+00 1.0360e+00 6.0 50.24;
6.5 50.24 7.6839e-01 -6.4575e-08 2.0 1.0072e+00 9.1313e-01 1.9774e+00 5.3680e-01 1.1030e+00 9.9851e-01 6.5 50.24;
7.0 50.24 7.9821e-01 -2.1127e-05 2.0 9.9853e-01 1.0824e+00 1.8584e+00 5.8686e-01 1.0951e+00 9.8511e-01 7.0 50.24;
7.5 50.24 8.3695e-01 -3.1385e-02 2.0 9.8773e-01 1.0788e+00 2.0739e+00 5.9519e-01 1.0989e+00 9.3891e-01 7.5 50.24;
8.0 50.24 1.2000e+00 -4.0437e-01 2.0 8.5839e-01 4.1919e+00 3.1777e+00 5.4781e-01 1.1109e+00 9.0655e-01 8.0 50.24;
4.0 79.62 7.0000e-01 -8.0890e-18 2.0 5.5429e-01 3.4017e+01 2.0664e+00 3.1187e-01 1.1005e+00 1.0754e+00 4.0 79.62;
4.5 79.62 7.0000e-01 -1.3090e-07 2.0 6.3896e-01 1.3043e+01 2.1523e+00 3.4652e-01 1.1058e+00 1.0788e+00 4.5 79.62;
5.0 79.62 7.0000e-01 -1.2290e-02 2.0 7.3580e-01 6.5228e+00 2.3315e+00 3.6224e-01 1.1035e+00 1.0648e+00 5.0 79.62;
5.5 79.62 7.0000e-01 -5.1176e-03 2.0 8.5381e-01 2.3219e+00 2.3280e+00 4.0281e-01 1.0951e+00 1.0580e+00 5.5 79.62;
6.0 79.62 7.4394e-01 -7.1538e-03 2.0 8.5853e-01 1.0128e+00 2.3976e+00 4.6298e-01 1.0970e+00 1.0547e+00 6.0 79.62;
6.5 79.62 7.3383e-01 -7.5166e-06 2.0 9.1533e-01 7.6082e-01 2.2108e+00 4.7191e-01 1.1022e+00 1.0224e+00 6.5 79.62;
7.0 79.62 7.6594e-01 -1.1135e-05 2.0 1.0242e+00 1.0944e+00 1.8323e+00 5.4115e-01 1.1060e+00 9.8341e-01 7.0 79.62;
7.5 79.62 8.3184e-01 -3.7984e-02 2.0 1.0252e+00 1.1924e+00 1.9481e+00 5.9080e-01 1.1065e+00 9.5858e-01 7.5 79.62;
8.0 79.62 1.2000e+00 -4.2855e-01 2.0 8.2436e-01 4.5732e+00 3.5456e+00 5.0411e-01 1.1105e+00 9.2490e-01 8.0 79.62;
4.0 126.19 7.0000e-01 -9.3134e-03 2.0 6.5770e-01 2.4111e+01 2.0921e+00 3.4515e-01 1.0948e+00 1.0737e+00 4.0 126.19;
4.5 126.19 7.0000e-01 -6.4122e-03 2.0 7.0065e-01 1.1473e+01 2.2173e+00 3.6651e-01 1.0964e+00 1.0705e+00 4.5 126.19;
5.0 126.19 7.0000e-01 -3.8103e-02 2.0 8.1428e-01 5.6824e+00 2.5118e+00 3.6708e-01 1.0982e+00 1.0603e+00 5.0 126.19;
5.5 126.19 7.0000e-01 -2.0781e-02 2.0 8.8580e-01 2.2925e+00 2.3286e+00 4.0074e-01 1.0892e+00 1.0465e+00 5.5 126.19;
6.0 126.19 7.1685e-01 -2.3828e-03 2.0 9.4160e-01 1.1819e+00 2.1530e+00 4.6235e-01 1.0937e+00 1.0376e+00 6.0 126.19;
6.5 126.19 7.5639e-01 -6.9748e-06 2.0 1.0266e+00 1.0918e+00 1.9603e+00 5.4218e-01 1.0949e+00 1.0160e+00 6.5 126.19;
7.0 126.19 7.8490e-01 -1.8834e-05 2.0 1.1253e+00 1.1569e+00 1.8651e+00 6.0514e-01 1.0910e+00 9.7531e-01 7.0 126.19;
7.5 126.19 8.2386e-01 -3.8922e-02 2.0 1.0819e+00 1.3516e+00 1.9944e+00 5.9384e-01 1.0999e+00 9.5643e-01 7.5 126.19;
8.0 126.19 1.2000e+00 -4.3500e-01 2.0 8.3252e-01 3.9690e+00 3.5290e+00 4.9975e-01 1.1068e+00 9.2419e-01 8.0 126.19;
4.0 200.00 7.0000e-01 -9.9722e-09 2.0 5.7369e-01 2.2867e+01 2.0999e+00 3.2613e-01 1.0893e+00 1.0764e+00 4.0 200.00;
4.5 200.00 7.0000e-01 -2.0290e-15 2.0 6.9245e-01 1.1532e+01 2.0741e+00 3.6652e-01 1.0896e+00 1.0693e+00 4.5 200.00;
5.0 200.00 7.0000e-01 -1.7951e-02 2.0 7.5549e-01 5.9753e+00 2.4248e+00 3.6718e-01 1.0879e+00 1.0610e+00 5.0 200.00;
5.5 200.00 7.0000e-01 -1.2546e-02 2.0 8.5451e-01 2.9617e+00 2.2767e+00 4.0641e-01 1.0935e+00 1.0547e+00 5.5 200.00;
6.0 200.00 7.1629e-01 -4.5233e-07 2.0 9.3155e-01 1.7244e+00 2.1745e+00 4.5411e-01 1.0864e+00 1.0374e+00 6.0 200.00;
6.5 200.00 7.4775e-01 -1.1187e-05 2.0 1.0262e+00 1.3210e+00 1.9536e+00 5.2329e-01 1.0925e+00 1.0271e+00 6.5 200.00;
7.0 200.00 7.8534e-01 -5.3183e-05 2.0 1.0803e+00 1.3301e+00 1.8174e+00 6.0116e-01 1.0887e+00 1.0000e+00 7.0 200.00;
7.5 200.00 8.3010e-01 -4.3565e-02 2.0 1.0546e+00 1.3811e+00 1.9608e+00 5.9829e-01 1.1017e+00 9.7409e-01 7.5 200.00;
8.0 200.00 1.2000e+00 -4.2648e-01 2.0 8.5386e-01 4.6946e+00 3.5826e+00 5.2896e-01 1.0980e+00 9.4662e-01 8.0 200.00;
4.0 317.00 7.0000e-01 -3.0941e-07 2.0 5.4038e-01 2.0798e+01 2.1620e+00 3.1839e-01 1.0999e+00 1.0873e+00 4.0 317.00;
4.5 317.00 7.0000e-01 -2.0482e-02 2.0 6.1477e-01 1.5841e+01 2.4554e+00 3.1946e-01 1.0955e+00 1.0786e+00 4.5 317.00;
5.0 317.00 7.0000e-01 -3.9962e-02 2.0 7.0732e-01 8.4084e+00 2.7415e+00 3.3211e-01 1.0985e+00 1.0637e+00 5.0 317.00;
5.5 317.00 7.0390e-01 -7.4679e-03 2.0 7.6534e-01 3.2582e+00 2.3231e+00 3.8841e-01 1.0927e+00 1.0643e+00 5.5 317.00;
6.0 317.00 7.3097e-01 -3.7794e-04 2.0 8.8502e-01 2.1430e+00 2.1211e+00 4.6048e-01 1.0888e+00 1.0423e+00 6.0 317.00;
6.5 317.00 7.7222e-01 -4.3701e-03 2.0 1.0979e+00 2.0230e+00 1.8593e+00 5.6905e-01 1.0903e+00 1.0215e+00 6.5 317.00;
7.0 317.00 7.9944e-01 -2.1160e-03 2.0 1.1200e+00 1.6581e+00 1.8141e+00 6.2103e-01 1.0856e+00 1.0083e+00 7.0 317.00;
7.5 317.00 7.9780e-01 -2.1297e-06 2.0 1.2097e+00 1.5811e+00 1.7106e+00 6.5362e-01 1.0932e+00 9.8560e-01 7.5 317.00;
8.0 317.00 1.2000e+00 -4.1799e-01 2.0 9.6603e-01 5.5529e+00 3.0556e+00 5.6936e-01 1.1012e+00 9.5754e-01 8.0 317.00;
4.0 502.40 7.0000e-01 -1.7111e-02 2.0 4.6999e-01 1.8968e+01 2.8200e+00 2.6648e-01 1.0937e+00 1.0850e+00 4.0 502.40;
4.5 502.40 7.0000e-01 -2.6396e-02 2.0 5.1949e-01 1.6368e+01 2.8759e+00 2.7832e-01 1.0958e+00 1.0749e+00 4.5 502.40;
5.0 502.40 7.0000e-01 -2.1671e-02 2.0 6.1000e-01 8.6654e+00 2.6980e+00 3.1148e-01 1.0901e+00 1.0729e+00 5.0 502.40;
5.5 502.40 7.0002e-01 -7.1630e-03 2.0 6.9537e-01 4.5437e+00 2.4581e+00 3.5831e-01 1.0952e+00 1.0655e+00 5.5 502.40;
6.0 502.40 7.6134e-01 -6.3443e-06 2.0 8.9341e-01 3.7976e+00 1.9228e+00 5.0275e-01 1.0876e+00 1.0463e+00 6.0 502.40;
6.5 502.40 7.9007e-01 -2.5364e-03 2.0 1.0237e+00 2.5624e+00 1.7955e+00 5.8082e-01 1.0837e+00 1.0309e+00 6.5 502.40;
7.0 502.40 7.8695e-01 -2.0933e-03 2.0 1.1867e+00 2.1554e+00 1.6970e+00 6.3350e-01 1.0993e+00 1.0215e+00 7.0 502.40;
7.5 502.40 8.1809e-01 -4.3629e-03 2.0 1.4327e+00 2.5223e+00 1.5747e+00 7.2501e-01 1.0885e+00 9.9483e-01 7.5 502.40;
8.0 502.40 1.2000e+00 -3.9261e-01 2.0 1.1094e+00 5.2480e+00 2.8220e+00 6.5055e-01 1.0920e+00 9.6559e-01 8.0 502.40;
4.0 796.20 7.0000e-01 -2.3099e-02 2.0 4.5581e-01 1.7534e+01 3.1836e+00 2.5169e-01 1.0938e+00 1.0935e+00 4.0 796.20;
4.5 796.20 7.0000e-01 -3.7902e-02 2.0 4.8070e-01 1.8783e+01 3.4708e+00 2.4695e-01 1.0957e+00 1.0901e+00 4.5 796.20;
5.0 796.20 7.0000e-01 -8.6256e-03 2.0 5.4088e-01 8.8700e+00 2.5344e+00 3.0798e-01 1.0999e+00 1.0796e+00 5.0 796.20;
5.5 796.20 7.2574e-01 -6.1859e-07 2.0 6.3759e-01 6.1694e+00 2.2528e+00 3.8172e-01 1.0942e+00 1.0656e+00 5.5 796.20;
6.0 796.20 7.9007e-01 -1.1663e-07 2.0 8.9429e-01 5.2998e+00 1.8310e+00 5.4462e-01 1.0835e+00 1.0541e+00 6.0 796.20;
6.5 796.20 8.0321e-01 -5.4738e-06 2.0 1.0887e+00 4.4263e+00 1.6296e+00 6.2320e-01 1.0833e+00 1.0565e+00 6.5 796.20;
7.0 796.20 8.3257e-01 -1.9010e-02 2.0 1.3544e+00 3.6403e+00 1.5790e+00 7.0373e-01 1.0842e+00 1.0292e+00 7.0 796.20;
7.5 796.20 8.2613e-01 -6.7595e-03 2.0 1.5248e+00 2.8118e+00 1.5264e+00 7.6541e-01 1.0887e+00 1.0129e+00 7.5 796.20;
8.0 796.20 1.1507e+00 -3.2529e-01 2.0 1.4633e+00 5.9123e+00 2.1639e+00 7.6925e-01 1.0861e+00 9.8940e-01 8.0 796.20;
4.0 1262.00 7.0380e-01 -2.3859e-02 2.0 4.6750e-01 1.6009e+01 3.2471e+00 2.5732e-01 1.0983e+00 1.0854e+00 4.0 1262.00;
4.5 1262.00 7.2948e-01 -1.4944e-02 2.0 4.8377e-01 1.2697e+01 2.6412e+00 2.9720e-01 1.0910e+00 1.0799e+00 4.5 1262.00;
5.0 1262.00 7.1686e-01 -8.8205e-09 2.0 5.0825e-01 8.9544e+00 2.5879e+00 3.1741e-01 1.0940e+00 1.0730e+00 5.0 1262.00;
5.5 1262.00 7.5789e-01 -5.9107e-07 2.0 6.3038e-01 8.3660e+00 2.0527e+00 4.2616e-01 1.0955e+00 1.0773e+00 5.5 1262.00;
6.0 1262.00 7.8795e-01 -1.1888e-06 2.0 9.4374e-01 7.9155e+00 1.6171e+00 5.6637e-01 1.0922e+00 1.0692e+00 6.0 1262.00;
6.5 1262.00 8.3205e-01 -7.7356e-04 2.0 1.3982e+00 7.1069e+00 1.4151e+00 7.1961e-01 1.0743e+00 1.0470e+00 6.5 1262.00;
7.0 1262.00 8.2346e-01 -5.7461e-03 2.0 1.6840e+00 5.8126e+00 1.3549e+00 7.5587e-01 1.0847e+00 1.0338e+00 7.0 1262.00;
7.5 1262.00 8.4754e-01 -2.1169e-02 2.0 1.9081e+00 4.5097e+00 1.3691e+00 8.1498e-01 1.0837e+00 1.0215e+00 7.5 1262.00;
8.0 1262.00 8.5187e-01 -1.5704e-02 2.0 2.7561e+00 4.7263e+00 1.2542e+00 9.5985e-01 1.0839e+00 1.0185e+00 8.0 1262.00 ]
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 37054 |
# Definition of Boore & Thompson (2012) constant values to be used within subsequent functions
const m_ii_bt15 = [ 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0 ]
const r_jj_bt15 = [ 2.00, 3.17, 5.02, 7.96, 12.62, 20.00, 31.70, 50.24, 79.62, 126.20, 200.01, 317.00, 502.41, 796.26, 1262.00 ]
const num_m_ii_bt15 = 13
const num_r_jj_bt15 = 15
const coefs_wna_bt15 = [ 2.00 2.00 9.38E-01 -1.09E-02 2.00E+00 1.00E+00 1.86E+00 2.00E+00 1.07E+00 1.03E+00 1.00E+00;
2.50 2.00 9.06E-01 -1.38E-02 2.00E+00 1.00E+00 1.67E+00 2.00E+00 1.07E+00 1.05E+00 1.04E+00;
3.00 2.00 9.55E-01 -1.74E-02 2.00E+00 1.00E+00 1.17E+00 2.00E+00 1.28E+00 1.04E+00 1.03E+00;
3.50 2.00 9.55E-01 -2.27E-02 2.00E+00 1.00E+00 9.35E-01 2.00E+00 1.29E+00 1.04E+00 1.03E+00;
4.00 2.00 9.85E-01 -3.71E-02 2.00E+00 1.00E+00 6.72E-01 2.00E+00 1.37E+00 1.03E+00 1.02E+00;
4.50 2.00 1.01E+00 -7.99E-02 2.00E+00 1.00E+00 5.18E-01 2.00E+00 1.39E+00 1.04E+00 1.02E+00;
5.00 2.00 1.04E+00 -1.10E-01 2.00E+00 1.00E+00 4.31E-01 2.00E+00 1.34E+00 1.03E+00 1.01E+00;
5.50 2.00 1.03E+00 -1.28E-01 2.00E+00 1.00E+00 3.20E-01 2.00E+00 1.34E+00 1.05E+00 1.01E+00;
6.00 2.00 9.54E-01 -7.01E-02 2.00E+00 1.00E+00 2.23E-01 2.00E+00 1.16E+00 1.05E+00 1.00E+00;
6.50 2.00 9.52E-01 -6.39E-02 2.00E+00 1.00E+00 1.86E-01 2.00E+00 1.16E+00 1.05E+00 9.96E-01;
7.00 2.00 8.48E-01 2.92E-02 2.00E+00 1.00E+00 1.15E-01 2.00E+00 1.15E+00 1.07E+00 9.88E-01;
7.50 2.00 8.49E-01 3.80E-02 2.00E+00 1.00E+00 1.02E-01 2.00E+00 1.15E+00 1.07E+00 9.65E-01;
8.00 2.00 8.30E-01 3.78E-02 2.00E+00 1.00E+00 8.68E-02 2.00E+00 1.05E+00 1.08E+00 9.50E-01;
2.00 3.17 9.17E-01 -9.48E-03 2.00E+00 1.00E+00 3.35E+00 2.00E+00 1.01E+00 1.05E+00 1.02E+00;
2.50 3.17 9.17E-01 -2.05E-02 2.00E+00 1.00E+00 3.08E+00 2.00E+00 1.01E+00 1.05E+00 1.04E+00;
3.00 3.17 9.37E-01 -1.12E-02 2.00E+00 1.00E+00 1.89E+00 2.00E+00 1.19E+00 1.04E+00 1.03E+00;
3.50 3.17 9.36E-01 -1.44E-02 2.00E+00 1.00E+00 1.48E+00 2.00E+00 1.19E+00 1.04E+00 1.03E+00;
4.00 3.17 9.62E-01 -3.49E-02 2.00E+00 1.00E+00 9.96E-01 2.00E+00 1.27E+00 1.04E+00 1.02E+00;
4.50 3.17 9.66E-01 -4.16E-02 2.00E+00 1.00E+00 6.78E-01 2.00E+00 1.30E+00 1.04E+00 1.03E+00;
5.00 3.17 1.01E+00 -9.19E-02 2.00E+00 1.00E+00 5.24E-01 2.00E+00 1.34E+00 1.04E+00 1.02E+00;
5.50 3.17 1.02E+00 -1.15E-01 2.00E+00 1.00E+00 3.74E-01 2.00E+00 1.29E+00 1.05E+00 1.01E+00;
6.00 3.17 9.80E-01 -8.70E-02 2.00E+00 1.00E+00 2.67E-01 2.00E+00 1.15E+00 1.05E+00 9.85E-01;
6.50 3.17 9.45E-01 -5.79E-02 2.00E+00 1.00E+00 1.90E-01 2.00E+00 1.17E+00 1.06E+00 9.84E-01;
7.00 3.17 8.36E-01 4.35E-02 2.00E+00 1.00E+00 1.15E-01 2.00E+00 1.16E+00 1.07E+00 9.83E-01;
7.50 3.17 8.45E-01 3.80E-02 2.00E+00 1.00E+00 1.02E-01 2.00E+00 1.13E+00 1.08E+00 9.61E-01;
8.00 3.17 8.28E-01 3.80E-02 2.00E+00 1.00E+00 7.62E-02 2.00E+00 1.06E+00 1.08E+00 9.41E-01;
2.00 5.02 9.13E-01 -4.79E-03 2.00E+00 1.00E+00 5.72E+00 2.00E+00 9.90E-01 1.05E+00 1.04E+00;
2.50 5.02 9.02E-01 -3.31E-03 2.00E+00 1.00E+00 5.19E+00 2.00E+00 1.02E+00 1.05E+00 1.04E+00;
3.00 5.02 9.03E-01 -2.62E-03 2.00E+00 1.00E+00 3.71E+00 2.00E+00 1.04E+00 1.05E+00 1.05E+00;
3.50 5.02 9.09E-01 -2.44E-03 2.00E+00 1.00E+00 2.44E+00 2.00E+00 1.12E+00 1.05E+00 1.05E+00;
4.00 5.02 9.39E-01 -2.64E-02 2.00E+00 1.00E+00 1.49E+00 2.00E+00 1.21E+00 1.05E+00 1.05E+00;
4.50 5.02 9.36E-01 -2.14E-02 2.00E+00 1.00E+00 1.05E+00 2.00E+00 1.19E+00 1.04E+00 1.03E+00;
5.00 5.02 9.76E-01 -6.53E-02 2.00E+00 1.00E+00 6.74E-01 2.00E+00 1.25E+00 1.05E+00 1.03E+00;
5.50 5.02 9.95E-01 -9.77E-02 2.00E+00 1.00E+00 4.58E-01 2.00E+00 1.23E+00 1.06E+00 1.02E+00;
6.00 5.02 9.96E-01 -1.02E-01 2.00E+00 1.00E+00 3.34E-01 2.00E+00 1.21E+00 1.06E+00 1.01E+00;
6.50 5.02 8.88E-01 -1.34E-02 2.00E+00 1.00E+00 1.90E-01 2.00E+00 1.15E+00 1.07E+00 1.00E+00;
7.00 5.02 8.24E-01 5.87E-02 2.00E+00 1.00E+00 1.20E-01 2.00E+00 1.16E+00 1.07E+00 9.91E-01;
7.50 5.02 8.41E-01 3.74E-02 2.00E+00 1.00E+00 9.77E-02 2.00E+00 1.08E+00 1.08E+00 9.59E-01;
8.00 5.02 8.04E-01 6.20E-02 2.00E+00 1.00E+00 7.63E-02 2.00E+00 1.06E+00 1.08E+00 9.48E-01;
2.00 7.96 9.10E-01 -1.24E-02 2.00E+00 1.00E+00 1.07E+01 2.00E+00 9.03E-01 1.05E+00 1.03E+00;
2.50 7.96 9.03E-01 6.10E-04 2.00E+00 1.00E+00 7.60E+00 2.00E+00 1.01E+00 1.05E+00 1.05E+00;
3.00 7.96 8.93E-01 -4.72E-03 2.00E+00 1.00E+00 6.14E+00 2.00E+00 1.00E+00 1.06E+00 1.06E+00;
3.50 7.96 8.93E-01 -4.55E-03 2.00E+00 1.00E+00 3.78E+00 2.00E+00 1.00E+00 1.05E+00 1.05E+00;
4.00 7.96 9.15E-01 -2.36E-02 2.00E+00 1.00E+00 2.52E+00 2.00E+00 1.07E+00 1.06E+00 1.05E+00;
4.50 7.96 9.29E-01 -2.47E-02 2.00E+00 1.00E+00 1.51E+00 2.00E+00 1.16E+00 1.06E+00 1.05E+00;
5.00 7.96 9.71E-01 -6.76E-02 2.00E+00 1.00E+00 9.17E-01 2.00E+00 1.21E+00 1.06E+00 1.04E+00;
5.50 7.96 9.69E-01 -6.62E-02 2.00E+00 1.00E+00 6.06E-01 2.00E+00 1.20E+00 1.06E+00 1.03E+00;
6.00 7.96 9.49E-01 -6.62E-02 2.00E+00 1.00E+00 3.53E-01 2.00E+00 1.15E+00 1.06E+00 1.01E+00;
6.50 7.96 8.31E-01 4.55E-02 2.00E+00 1.00E+00 1.75E-01 2.00E+00 1.15E+00 1.07E+00 1.02E+00;
7.00 7.96 8.31E-01 4.58E-02 2.00E+00 1.00E+00 1.38E-01 2.00E+00 1.13E+00 1.07E+00 9.90E-01;
7.50 7.96 8.31E-01 4.14E-02 2.00E+00 1.00E+00 1.12E-01 2.00E+00 1.12E+00 1.08E+00 9.75E-01;
8.00 7.96 8.04E-01 6.82E-02 2.00E+00 1.00E+00 7.01E-02 2.00E+00 1.05E+00 1.08E+00 9.48E-01;
2.00 12.62 9.01E-01 -2.38E-04 2.00E+00 1.00E+00 1.39E+01 2.00E+00 9.03E-01 1.05E+00 1.05E+00;
2.50 12.62 8.78E-01 -2.16E-03 2.00E+00 1.00E+00 1.20E+01 2.00E+00 8.87E-01 1.06E+00 1.06E+00;
3.00 12.62 8.67E-01 -2.53E-03 2.00E+00 1.00E+00 9.21E+00 2.00E+00 8.98E-01 1.07E+00 1.06E+00;
3.50 12.62 8.88E-01 -4.74E-03 2.00E+00 1.00E+00 4.96E+00 2.00E+00 1.00E+00 1.07E+00 1.06E+00;
4.00 12.62 8.89E-01 -1.24E-02 2.00E+00 1.00E+00 3.28E+00 2.00E+00 1.02E+00 1.06E+00 1.06E+00;
4.50 12.62 8.90E-01 -1.27E-02 2.00E+00 1.00E+00 1.71E+00 2.00E+00 1.02E+00 1.06E+00 1.05E+00;
5.00 12.62 9.15E-01 -2.13E-02 2.00E+00 1.00E+00 9.17E-01 2.00E+00 1.14E+00 1.06E+00 1.05E+00;
5.50 12.62 9.69E-01 -6.63E-02 2.00E+00 1.00E+00 6.29E-01 2.00E+00 1.20E+00 1.06E+00 1.03E+00;
6.00 12.62 9.99E-01 -1.15E-01 2.00E+00 1.00E+00 5.22E-01 2.00E+00 1.16E+00 1.06E+00 1.02E+00;
6.50 12.62 8.21E-01 5.22E-02 2.00E+00 1.00E+00 1.75E-01 2.00E+00 1.08E+00 1.07E+00 1.00E+00;
7.00 12.62 8.42E-01 3.63E-02 2.00E+00 1.00E+00 1.49E-01 2.00E+00 1.10E+00 1.07E+00 9.84E-01;
7.50 12.62 8.18E-01 5.02E-02 2.00E+00 1.00E+00 1.12E-01 2.00E+00 1.09E+00 1.08E+00 9.69E-01;
8.00 12.62 8.02E-01 6.36E-02 2.00E+00 1.00E+00 7.30E-02 2.00E+00 1.07E+00 1.08E+00 9.47E-01;
2.00 20.00 8.67E-01 1.11E-03 2.00E+00 1.00E+00 2.31E+01 2.00E+00 8.44E-01 1.07E+00 1.05E+00;
2.50 20.00 8.79E-01 -2.62E-03 2.00E+00 1.00E+00 1.54E+01 2.00E+00 9.00E-01 1.07E+00 1.06E+00;
3.00 20.00 8.78E-01 -2.33E-03 2.00E+00 1.00E+00 1.24E+01 2.00E+00 9.00E-01 1.06E+00 1.05E+00;
3.50 20.00 8.78E-01 -9.54E-03 2.00E+00 1.00E+00 7.24E+00 2.00E+00 9.47E-01 1.07E+00 1.06E+00;
4.00 20.00 8.75E-01 -8.07E-03 2.00E+00 1.00E+00 4.40E+00 2.00E+00 9.51E-01 1.06E+00 1.06E+00;
4.50 20.00 8.82E-01 -1.08E-02 2.00E+00 1.00E+00 2.28E+00 2.00E+00 1.00E+00 1.07E+00 1.06E+00;
5.00 20.00 8.90E-01 -1.53E-02 2.00E+00 1.00E+00 1.35E+00 2.00E+00 1.01E+00 1.06E+00 1.04E+00;
5.50 20.00 8.86E-01 -1.56E-02 2.00E+00 1.00E+00 7.89E-01 2.00E+00 1.01E+00 1.06E+00 1.03E+00;
6.00 20.00 9.69E-01 -8.21E-02 2.00E+00 1.00E+00 5.22E-01 2.00E+00 1.15E+00 1.07E+00 1.03E+00;
6.50 20.00 9.68E-01 -8.34E-02 2.00E+00 1.00E+00 3.54E-01 2.00E+00 1.17E+00 1.06E+00 1.01E+00;
7.00 20.00 8.30E-01 3.98E-02 2.00E+00 1.00E+00 1.57E-01 2.00E+00 1.11E+00 1.08E+00 1.00E+00;
7.50 20.00 8.36E-01 4.00E-02 2.00E+00 1.00E+00 1.19E-01 2.00E+00 1.10E+00 1.07E+00 9.68E-01;
8.00 20.00 8.01E-01 6.36E-02 2.00E+00 1.00E+00 7.10E-02 2.00E+00 1.05E+00 1.08E+00 9.49E-01;
2.00 31.70 8.77E-01 -2.85E-03 2.00E+00 1.00E+00 2.84E+01 2.00E+00 8.36E-01 1.07E+00 1.06E+00;
2.50 31.70 8.72E-01 -2.76E-03 2.00E+00 1.00E+00 2.74E+01 2.00E+00 8.37E-01 1.07E+00 1.06E+00;
3.00 31.70 8.76E-01 -2.14E-03 2.00E+00 1.00E+00 1.88E+01 2.00E+00 9.14E-01 1.07E+00 1.06E+00;
3.50 31.70 8.55E-01 -9.99E-03 2.00E+00 1.00E+00 1.05E+01 2.00E+00 8.84E-01 1.09E+00 1.07E+00;
4.00 31.70 8.76E-01 -1.01E-02 2.00E+00 1.00E+00 6.42E+00 2.00E+00 9.42E-01 1.07E+00 1.06E+00;
4.50 31.70 8.68E-01 -7.45E-03 2.00E+00 1.00E+00 3.65E+00 2.00E+00 9.52E-01 1.07E+00 1.06E+00;
5.00 31.70 8.84E-01 -2.10E-02 2.00E+00 1.00E+00 1.97E+00 2.00E+00 9.67E-01 1.07E+00 1.05E+00;
5.50 31.70 8.91E-01 -2.11E-02 2.00E+00 1.00E+00 1.06E+00 2.00E+00 9.86E-01 1.06E+00 1.03E+00;
6.00 31.70 9.70E-01 -8.86E-02 2.00E+00 1.00E+00 6.97E-01 2.00E+00 1.13E+00 1.07E+00 1.03E+00;
6.50 31.70 9.66E-01 -8.88E-02 2.00E+00 1.00E+00 4.23E-01 2.00E+00 1.12E+00 1.07E+00 1.00E+00;
7.00 31.70 7.93E-01 7.72E-02 2.00E+00 1.00E+00 1.57E-01 2.00E+00 1.07E+00 1.07E+00 1.00E+00;
7.50 31.70 8.07E-01 6.50E-02 2.00E+00 1.00E+00 1.26E-01 2.00E+00 1.08E+00 1.08E+00 9.72E-01;
8.00 31.70 7.98E-01 6.55E-02 2.00E+00 1.00E+00 8.50E-02 2.00E+00 1.07E+00 1.08E+00 9.51E-01;
2.00 50.24 8.70E-01 -2.75E-03 2.00E+00 1.00E+00 3.34E+01 2.00E+00 8.31E-01 1.08E+00 1.06E+00;
2.50 50.24 8.63E-01 -1.52E-02 2.00E+00 1.00E+00 2.83E+01 2.00E+00 8.21E-01 1.08E+00 1.07E+00;
3.00 50.24 8.76E-01 -1.96E-03 2.00E+00 1.00E+00 1.80E+01 2.00E+00 9.11E-01 1.07E+00 1.07E+00;
3.50 50.24 8.54E-01 2.04E-03 2.00E+00 1.00E+00 1.37E+01 2.00E+00 8.84E-01 1.08E+00 1.07E+00;
4.00 50.24 8.79E-01 -1.08E-02 2.00E+00 1.00E+00 6.94E+00 2.00E+00 9.35E-01 1.07E+00 1.07E+00;
4.50 50.24 8.75E-01 -1.25E-02 2.00E+00 1.00E+00 4.72E+00 2.00E+00 9.33E-01 1.07E+00 1.06E+00;
5.00 50.24 8.79E-01 -1.76E-02 2.00E+00 1.00E+00 2.58E+00 2.00E+00 9.66E-01 1.07E+00 1.06E+00;
5.50 50.24 8.76E-01 -7.74E-03 2.00E+00 1.00E+00 1.30E+00 2.00E+00 9.89E-01 1.07E+00 1.05E+00;
6.00 50.24 8.97E-01 -3.42E-02 2.00E+00 1.00E+00 7.04E-01 2.00E+00 9.98E-01 1.07E+00 1.02E+00;
6.50 50.24 9.07E-01 -4.26E-02 2.00E+00 1.00E+00 4.49E-01 2.00E+00 1.04E+00 1.07E+00 1.01E+00;
7.00 50.24 9.07E-01 -4.26E-02 2.00E+00 1.00E+00 3.05E-01 2.00E+00 1.05E+00 1.07E+00 1.01E+00;
7.50 50.24 8.06E-01 6.49E-02 2.00E+00 1.00E+00 1.32E-01 2.00E+00 1.08E+00 1.07E+00 9.82E-01;
8.00 50.24 8.00E-01 6.46E-02 2.00E+00 1.00E+00 9.83E-02 2.00E+00 1.08E+00 1.08E+00 9.62E-01;
2.00 79.62 8.77E-01 -1.54E-02 2.00E+00 1.00E+00 2.13E+01 2.00E+00 8.24E-01 1.08E+00 1.06E+00;
2.50 79.62 8.74E-01 -1.34E-02 2.00E+00 1.00E+00 1.89E+01 2.00E+00 8.41E-01 1.07E+00 1.07E+00;
3.00 79.62 8.58E-01 -8.54E-03 2.00E+00 1.00E+00 1.51E+01 2.00E+00 8.63E-01 1.08E+00 1.08E+00;
3.50 79.62 8.70E-01 -1.69E-02 2.00E+00 1.00E+00 1.17E+01 2.00E+00 8.59E-01 1.07E+00 1.07E+00;
4.00 79.62 8.69E-01 -1.02E-02 2.00E+00 1.00E+00 6.79E+00 2.00E+00 9.17E-01 1.07E+00 1.06E+00;
4.50 79.62 8.64E-01 -9.08E-03 2.00E+00 1.00E+00 4.01E+00 2.00E+00 9.22E-01 1.08E+00 1.07E+00;
5.00 79.62 8.80E-01 -2.34E-02 2.00E+00 1.00E+00 2.25E+00 2.00E+00 9.66E-01 1.07E+00 1.06E+00;
5.50 79.62 8.77E-01 -1.97E-02 2.00E+00 1.00E+00 1.26E+00 2.00E+00 9.69E-01 1.07E+00 1.05E+00;
6.00 79.62 8.77E-01 -1.15E-02 2.00E+00 1.00E+00 7.06E-01 2.00E+00 1.05E+00 1.07E+00 1.04E+00;
6.50 79.62 8.93E-01 -2.12E-02 2.00E+00 1.00E+00 4.34E-01 2.00E+00 1.08E+00 1.07E+00 1.01E+00;
7.00 79.62 8.91E-01 -2.06E-02 2.00E+00 1.00E+00 3.06E-01 2.00E+00 1.11E+00 1.07E+00 1.00E+00;
7.50 79.62 8.87E-01 -1.92E-02 2.00E+00 1.00E+00 1.99E-01 2.00E+00 1.12E+00 1.07E+00 9.88E-01;
8.00 79.62 7.90E-01 6.96E-02 2.00E+00 1.00E+00 1.06E-01 2.00E+00 1.09E+00 1.08E+00 9.64E-01;
2.00 126.20 8.67E-01 -1.54E-02 2.00E+00 1.00E+00 1.06E+01 2.00E+00 8.24E-01 1.08E+00 1.07E+00;
2.50 126.20 8.70E-01 -1.99E-02 2.00E+00 1.00E+00 1.11E+01 2.00E+00 8.25E-01 1.08E+00 1.07E+00;
3.00 126.20 8.68E-01 -2.25E-02 2.00E+00 1.00E+00 9.66E+00 2.00E+00 8.31E-01 1.08E+00 1.07E+00;
3.50 126.20 8.69E-01 -2.90E-02 2.00E+00 1.00E+00 9.08E+00 2.00E+00 8.38E-01 1.08E+00 1.08E+00;
4.00 126.20 8.66E-01 -1.41E-02 2.00E+00 1.00E+00 5.26E+00 2.00E+00 9.05E-01 1.08E+00 1.08E+00;
4.50 126.20 8.67E-01 -1.24E-02 2.00E+00 1.00E+00 3.47E+00 2.00E+00 9.22E-01 1.07E+00 1.06E+00;
5.00 126.20 8.83E-01 -3.09E-02 2.00E+00 1.00E+00 2.31E+00 2.00E+00 9.33E-01 1.07E+00 1.05E+00;
5.50 126.20 8.87E-01 -3.49E-02 2.00E+00 1.00E+00 1.33E+00 2.00E+00 9.58E-01 1.07E+00 1.04E+00;
6.00 126.20 8.85E-01 -4.67E-03 2.00E+00 1.00E+00 6.42E-01 2.00E+00 1.11E+00 1.06E+00 1.04E+00;
6.50 126.20 8.83E-01 -7.45E-03 2.00E+00 1.00E+00 4.14E-01 2.00E+00 1.11E+00 1.06E+00 1.02E+00;
7.00 126.20 9.14E-01 -3.72E-02 2.00E+00 1.00E+00 3.05E-01 2.00E+00 1.13E+00 1.06E+00 9.97E-01;
7.50 126.20 8.54E-01 1.79E-02 2.00E+00 1.00E+00 1.91E-01 2.00E+00 1.12E+00 1.07E+00 9.80E-01;
8.00 126.20 8.06E-01 6.96E-02 2.00E+00 1.00E+00 1.13E-01 2.00E+00 1.17E+00 1.07E+00 9.62E-01;
2.00 200.01 8.56E-01 -1.56E-02 2.00E+00 1.00E+00 1.03E+01 2.00E+00 8.08E-01 1.09E+00 1.07E+00;
2.50 200.01 8.54E-01 -2.40E-02 2.00E+00 1.00E+00 1.13E+01 2.00E+00 7.70E-01 1.09E+00 1.09E+00;
3.00 200.01 8.57E-01 -2.40E-02 2.00E+00 1.00E+00 1.16E+01 2.00E+00 7.70E-01 1.09E+00 1.07E+00;
3.50 200.01 8.67E-01 -2.90E-02 2.00E+00 1.00E+00 9.08E+00 2.00E+00 8.30E-01 1.09E+00 1.08E+00;
4.00 200.01 8.69E-01 -2.93E-02 2.00E+00 1.00E+00 7.53E+00 2.00E+00 8.32E-01 1.08E+00 1.07E+00;
4.50 200.01 8.73E-01 -3.34E-02 2.00E+00 1.00E+00 5.56E+00 2.00E+00 8.32E-01 1.08E+00 1.07E+00;
5.00 200.01 8.81E-01 -3.48E-02 2.00E+00 1.00E+00 3.46E+00 2.00E+00 8.72E-01 1.08E+00 1.06E+00;
5.50 200.01 9.15E-01 -6.55E-02 2.00E+00 1.00E+00 2.27E+00 2.00E+00 9.25E-01 1.07E+00 1.05E+00;
6.00 200.01 9.16E-01 -5.45E-02 2.00E+00 1.00E+00 1.37E+00 2.00E+00 9.66E-01 1.07E+00 1.05E+00;
6.50 200.01 8.12E-01 6.67E-02 2.00E+00 1.00E+00 5.05E-01 2.00E+00 1.06E+00 1.06E+00 1.03E+00;
7.00 200.01 8.10E-01 7.00E-02 2.00E+00 1.00E+00 3.05E-01 2.00E+00 1.11E+00 1.06E+00 1.02E+00;
7.50 200.01 8.40E-01 3.43E-02 2.00E+00 1.00E+00 2.54E-01 2.00E+00 1.17E+00 1.07E+00 1.01E+00;
8.00 200.01 8.39E-01 3.23E-02 2.00E+00 1.00E+00 1.87E-01 2.00E+00 1.17E+00 1.07E+00 9.74E-01;
2.00 317.00 9.43E-01 -1.02E-01 2.00E+00 1.00E+00 1.21E+01 2.00E+00 7.87E-01 1.08E+00 1.08E+00;
2.50 317.00 8.98E-01 -6.21E-02 2.00E+00 1.00E+00 1.02E+01 2.00E+00 7.73E-01 1.09E+00 1.08E+00;
3.00 317.00 8.87E-01 -5.91E-02 2.00E+00 1.00E+00 1.05E+01 2.00E+00 7.62E-01 1.09E+00 1.09E+00;
3.50 317.00 8.88E-01 -5.91E-02 2.00E+00 1.00E+00 9.81E+00 2.00E+00 7.62E-01 1.09E+00 1.08E+00;
4.00 317.00 8.79E-01 -2.97E-02 2.00E+00 1.00E+00 7.52E+00 2.00E+00 8.23E-01 1.08E+00 1.08E+00;
4.50 317.00 8.67E-01 -3.08E-02 2.00E+00 1.00E+00 5.96E+00 2.00E+00 8.07E-01 1.08E+00 1.07E+00;
5.00 317.00 8.69E-01 -3.36E-02 2.00E+00 1.00E+00 5.00E+00 2.00E+00 8.24E-01 1.08E+00 1.08E+00;
5.50 317.00 9.22E-01 -6.81E-02 2.00E+00 1.00E+00 3.09E+00 2.00E+00 9.07E-01 1.08E+00 1.07E+00;
6.00 317.00 9.16E-01 -5.09E-02 2.00E+00 1.00E+00 2.01E+00 2.00E+00 9.57E-01 1.07E+00 1.05E+00;
6.50 317.00 9.05E-01 -5.09E-02 2.00E+00 1.00E+00 1.30E+00 2.00E+00 9.57E-01 1.07E+00 1.05E+00;
7.00 317.00 7.84E-01 9.62E-02 2.00E+00 1.00E+00 4.18E-01 2.00E+00 1.10E+00 1.06E+00 1.04E+00;
7.50 317.00 8.33E-01 3.42E-02 2.00E+00 1.00E+00 2.99E-01 2.00E+00 1.12E+00 1.07E+00 1.02E+00;
8.00 317.00 8.48E-01 3.23E-02 2.00E+00 1.00E+00 1.87E-01 2.00E+00 1.17E+00 1.07E+00 9.92E-01;
2.00 502.41 9.28E-01 -9.26E-02 2.00E+00 1.00E+00 6.71E+00 2.00E+00 7.45E-01 1.08E+00 1.08E+00;
2.50 502.41 9.23E-01 -9.30E-02 2.00E+00 1.00E+00 6.52E+00 2.00E+00 7.44E-01 1.09E+00 1.08E+00;
3.00 502.41 9.27E-01 -9.51E-02 2.00E+00 1.00E+00 6.52E+00 2.00E+00 7.57E-01 1.09E+00 1.07E+00;
3.50 502.41 9.27E-01 -9.25E-02 2.00E+00 1.00E+00 6.01E+00 2.00E+00 7.57E-01 1.09E+00 1.08E+00;
4.00 502.41 9.18E-01 -9.25E-02 2.00E+00 1.00E+00 6.01E+00 2.00E+00 7.57E-01 1.09E+00 1.08E+00;
4.50 502.41 8.63E-01 -1.46E-02 2.00E+00 1.00E+00 4.55E+00 2.00E+00 8.12E-01 1.07E+00 1.07E+00;
5.00 502.41 8.64E-01 -3.31E-02 2.00E+00 1.00E+00 3.53E+00 2.00E+00 8.25E-01 1.09E+00 1.08E+00;
5.50 502.41 9.22E-01 -6.59E-02 2.00E+00 1.00E+00 3.32E+00 2.00E+00 9.05E-01 1.07E+00 1.07E+00;
6.00 502.41 9.16E-01 -5.09E-02 2.00E+00 1.00E+00 2.01E+00 2.00E+00 9.57E-01 1.07E+00 1.06E+00;
6.50 502.41 8.75E-01 9.81E-03 2.00E+00 1.00E+00 1.25E+00 2.00E+00 9.97E-01 1.06E+00 1.05E+00;
7.00 502.41 7.79E-01 9.10E-02 2.00E+00 1.00E+00 5.57E-01 2.00E+00 1.07E+00 1.07E+00 1.05E+00;
7.50 502.41 7.96E-01 9.16E-02 2.00E+00 1.00E+00 2.64E-01 2.00E+00 1.16E+00 1.06E+00 1.04E+00;
8.00 502.41 8.53E-01 3.23E-02 2.00E+00 1.00E+00 1.92E-01 2.00E+00 1.17E+00 1.06E+00 1.00E+00;
2.00 796.26 9.17E-01 -8.91E-02 2.00E+00 1.00E+00 3.60E+00 2.00E+00 7.48E-01 1.09E+00 1.07E+00;
2.50 796.26 9.17E-01 -7.64E-02 2.00E+00 1.00E+00 3.60E+00 2.00E+00 7.79E-01 1.08E+00 1.08E+00;
3.00 796.26 9.14E-01 -7.40E-02 2.00E+00 1.00E+00 3.33E+00 2.00E+00 7.79E-01 1.08E+00 1.08E+00;
3.50 796.26 9.16E-01 -7.70E-02 2.00E+00 1.00E+00 3.36E+00 2.00E+00 7.86E-01 1.08E+00 1.08E+00;
4.00 796.26 9.18E-01 -7.88E-02 2.00E+00 1.00E+00 3.51E+00 2.00E+00 7.89E-01 1.08E+00 1.08E+00;
4.50 796.26 8.72E-01 -3.31E-02 2.00E+00 1.00E+00 2.60E+00 2.00E+00 8.12E-01 1.08E+00 1.08E+00;
5.00 796.26 8.72E-01 -3.09E-02 2.00E+00 1.00E+00 2.55E+00 2.00E+00 8.06E-01 1.08E+00 1.08E+00;
5.50 796.26 9.24E-01 -8.56E-02 2.00E+00 1.00E+00 2.12E+00 2.00E+00 8.66E-01 1.09E+00 1.08E+00;
6.00 796.26 9.02E-01 -5.29E-02 2.00E+00 1.00E+00 1.89E+00 2.00E+00 8.98E-01 1.08E+00 1.07E+00;
6.50 796.26 8.50E-01 9.81E-03 2.00E+00 1.00E+00 1.17E+00 2.00E+00 9.79E-01 1.07E+00 1.06E+00;
7.00 796.26 8.49E-01 8.98E-03 2.00E+00 1.00E+00 6.98E-01 2.00E+00 9.83E-01 1.07E+00 1.05E+00;
7.50 796.26 8.61E-01 2.80E-02 2.00E+00 1.00E+00 3.00E-01 2.00E+00 1.14E+00 1.06E+00 1.04E+00;
8.00 796.26 8.65E-01 2.74E-02 2.00E+00 1.00E+00 8.62E-02 2.00E+00 1.23E+00 1.06E+00 1.02E+00;
2.00 1262.00 7.65E-01 8.02E-02 2.00E+00 1.00E+00 8.90E-01 2.00E+00 8.18E-01 1.08E+00 1.07E+00;
2.50 1262.00 7.63E-01 8.02E-02 2.00E+00 1.00E+00 7.95E-01 2.00E+00 8.14E-01 1.08E+00 1.07E+00;
3.00 1262.00 7.64E-01 8.05E-02 2.00E+00 1.00E+00 7.48E-01 2.00E+00 8.18E-01 1.08E+00 1.07E+00;
3.50 1262.00 7.50E-01 8.04E-02 2.00E+00 1.00E+00 7.40E-01 2.00E+00 8.03E-01 1.09E+00 1.08E+00;
4.00 1262.00 9.87E-01 -1.40E-01 2.00E+00 1.00E+00 1.68E+00 2.00E+00 8.39E-01 1.08E+00 1.07E+00;
4.50 1262.00 9.82E-01 -1.45E-01 2.00E+00 1.00E+00 1.35E+00 2.00E+00 8.20E-01 1.09E+00 1.07E+00;
5.00 1262.00 9.93E-01 -1.40E-01 2.00E+00 1.00E+00 1.68E+00 2.00E+00 8.50E-01 1.07E+00 1.08E+00;
5.50 1262.00 9.72E-01 -1.21E-01 2.00E+00 1.00E+00 1.20E+00 2.00E+00 8.71E-01 1.08E+00 1.07E+00;
6.00 1262.00 9.00E-01 -5.20E-02 2.00E+00 1.00E+00 1.10E+00 2.00E+00 9.00E-01 1.08E+00 1.07E+00;
6.50 1262.00 8.51E-01 -8.69E-03 2.00E+00 1.00E+00 2.15E-01 2.00E+00 9.31E-01 1.08E+00 1.07E+00;
7.00 1262.00 8.74E-01 -4.90E-03 2.00E+00 1.00E+00 2.06E-03 2.00E+00 1.03E+00 1.07E+00 1.06E+00;
7.50 1262.00 9.11E-01 -2.45E-02 2.00E+00 1.00E+00 5.54E-06 2.00E+00 1.17E+00 1.06E+00 1.05E+00;
8.00 1262.00 9.16E-01 -2.36E-02 2.00E+00 1.00E+00 1.51E-09 2.00E+00 1.21E+00 1.05E+00 1.04E+00 ]
const coefs_ena_bt15 = [ 2.00 2.00 9.29E-01 -1.27E-02 2.00E+00 1.00E+00 1.41E+00 1.90E+00 1.15E+00 1.05E+00 1.05E+00;
2.50 2.00 9.20E-01 -2.34E-02 2.00E+00 1.00E+00 1.19E+00 1.89E+00 1.11E+00 1.05E+00 1.05E+00;
3.00 2.00 9.38E-01 -2.74E-02 2.00E+00 1.00E+00 8.36E-01 1.91E+00 1.19E+00 1.05E+00 1.05E+00;
3.50 2.00 9.80E-01 -5.66E-02 2.00E+00 1.00E+00 5.75E-01 1.89E+00 1.35E+00 1.05E+00 1.03E+00;
4.00 2.00 1.03E+00 -1.01E-01 2.00E+00 1.00E+00 5.04E-01 1.85E+00 1.34E+00 1.06E+00 1.02E+00;
4.50 2.00 1.04E+00 -1.14E-01 2.00E+00 1.00E+00 4.30E-01 1.79E+00 1.37E+00 1.05E+00 1.01E+00;
5.00 2.00 1.06E+00 -1.41E-01 2.00E+00 1.00E+00 3.77E-01 1.76E+00 1.43E+00 1.05E+00 9.81E-01;
5.50 2.00 1.06E+00 -1.41E-01 2.00E+00 1.00E+00 3.48E-01 1.72E+00 1.43E+00 1.06E+00 9.55E-01;
6.00 2.00 9.48E-01 -5.23E-02 2.00E+00 1.00E+00 2.23E-01 1.77E+00 1.29E+00 1.07E+00 9.54E-01;
6.50 2.00 9.48E-01 -5.22E-02 2.00E+00 1.00E+00 2.06E-01 1.77E+00 1.28E+00 1.07E+00 9.36E-01;
7.00 2.00 8.56E-01 2.30E-02 2.00E+00 1.00E+00 1.34E-01 1.88E+00 1.22E+00 1.08E+00 9.23E-01;
7.50 2.00 8.52E-01 2.46E-02 2.00E+00 1.00E+00 1.24E-01 1.88E+00 1.22E+00 1.08E+00 9.08E-01;
8.00 2.00 8.45E-01 2.16E-02 2.00E+00 1.00E+00 1.13E-01 1.82E+00 1.13E+00 1.08E+00 9.05E-01;
2.00 3.17 9.11E-01 -3.46E-02 2.00E+00 1.00E+00 2.70E+00 2.06E+00 9.58E-01 1.05E+00 1.06E+00;
2.50 3.17 9.10E-01 -3.94E-02 2.00E+00 1.00E+00 1.92E+00 2.03E+00 9.58E-01 1.07E+00 1.06E+00;
3.00 3.17 9.50E-01 -6.92E-02 2.00E+00 1.00E+00 1.21E+00 2.10E+00 1.07E+00 1.05E+00 1.06E+00;
3.50 3.17 9.73E-01 -4.57E-02 2.00E+00 1.00E+00 7.38E-01 2.05E+00 1.28E+00 1.06E+00 1.04E+00;
4.00 3.17 9.96E-01 -1.01E-01 2.00E+00 1.00E+00 5.96E-01 1.99E+00 1.19E+00 1.06E+00 1.03E+00;
4.50 3.17 9.99E-01 -9.17E-02 2.00E+00 1.00E+00 4.77E-01 1.90E+00 1.28E+00 1.05E+00 1.02E+00;
5.00 3.17 1.05E+00 -1.29E-01 2.00E+00 1.00E+00 4.23E-01 1.84E+00 1.41E+00 1.06E+00 9.81E-01;
5.50 3.17 9.97E-01 -8.61E-02 2.00E+00 1.00E+00 3.50E-01 1.73E+00 1.35E+00 1.07E+00 9.76E-01;
6.00 3.17 9.51E-01 -6.70E-02 2.00E+00 1.00E+00 2.86E-01 1.76E+00 1.30E+00 1.06E+00 9.45E-01;
6.50 3.17 9.04E-01 -1.56E-02 2.00E+00 1.00E+00 2.05E-01 1.78E+00 1.27E+00 1.07E+00 9.32E-01;
7.00 3.17 8.44E-01 3.24E-02 2.00E+00 1.00E+00 1.34E-01 1.88E+00 1.22E+00 1.08E+00 9.28E-01;
7.50 3.17 8.44E-01 3.26E-02 2.00E+00 1.00E+00 1.16E-01 1.89E+00 1.22E+00 1.07E+00 8.98E-01;
8.00 3.17 8.28E-01 3.91E-02 2.00E+00 1.00E+00 9.04E-02 1.87E+00 1.12E+00 1.09E+00 8.98E-01;
2.00 5.02 9.03E-01 -2.31E-02 2.00E+00 1.00E+00 4.70E+00 2.03E+00 9.16E-01 1.06E+00 1.06E+00;
2.50 5.02 9.09E-01 -1.77E-02 2.00E+00 1.00E+00 2.89E+00 2.06E+00 1.01E+00 1.07E+00 1.06E+00;
3.00 5.02 9.08E-01 -3.10E-02 2.00E+00 1.00E+00 2.07E+00 2.04E+00 1.00E+00 1.06E+00 1.05E+00;
3.50 5.02 9.40E-01 -4.10E-02 2.00E+00 1.00E+00 1.21E+00 2.08E+00 1.11E+00 1.07E+00 1.06E+00;
4.00 5.02 9.56E-01 -6.43E-02 2.00E+00 1.00E+00 7.86E-01 2.04E+00 1.15E+00 1.06E+00 1.04E+00;
4.50 5.02 9.53E-01 -6.41E-02 2.00E+00 1.00E+00 6.75E-01 1.92E+00 1.15E+00 1.07E+00 1.04E+00;
5.00 5.02 9.77E-01 -7.32E-02 2.00E+00 1.00E+00 5.21E-01 1.81E+00 1.28E+00 1.06E+00 1.01E+00;
5.50 5.02 1.02E+00 -1.24E-01 2.00E+00 1.00E+00 4.02E-01 1.81E+00 1.31E+00 1.06E+00 9.69E-01;
6.00 5.02 9.36E-01 -4.62E-02 2.00E+00 1.00E+00 2.86E-01 1.78E+00 1.28E+00 1.07E+00 9.61E-01;
6.50 5.02 8.92E-01 -1.15E-02 2.00E+00 1.00E+00 2.10E-01 1.80E+00 1.18E+00 1.07E+00 9.36E-01;
7.00 5.02 8.21E-01 5.64E-02 2.00E+00 1.00E+00 1.34E-01 1.89E+00 1.19E+00 1.07E+00 9.40E-01;
7.50 5.02 8.21E-01 4.97E-02 2.00E+00 1.00E+00 1.11E-01 1.92E+00 1.17E+00 1.08E+00 9.23E-01;
8.00 5.02 8.09E-01 5.00E-02 2.00E+00 1.00E+00 9.04E-02 1.90E+00 1.11E+00 1.08E+00 8.94E-01;
2.00 7.96 8.92E-01 -7.58E-03 2.00E+00 1.00E+00 8.62E+00 2.04E+00 9.17E-01 1.07E+00 1.07E+00;
2.50 7.96 8.96E-01 -1.84E-02 2.00E+00 1.00E+00 5.22E+00 2.06E+00 9.44E-01 1.07E+00 1.05E+00;
3.00 7.96 8.97E-01 -3.22E-02 2.00E+00 1.00E+00 3.75E+00 2.07E+00 9.16E-01 1.08E+00 1.06E+00;
3.50 7.96 8.92E-01 -3.79E-02 2.00E+00 1.00E+00 2.45E+00 2.05E+00 9.15E-01 1.08E+00 1.06E+00;
4.00 7.96 9.00E-01 -2.92E-02 2.00E+00 1.00E+00 1.44E+00 1.95E+00 9.95E-01 1.06E+00 1.04E+00;
4.50 7.96 9.52E-01 -6.98E-02 2.00E+00 1.00E+00 7.96E-01 2.06E+00 1.11E+00 1.06E+00 1.04E+00;
5.00 7.96 9.51E-01 -7.59E-02 2.00E+00 1.00E+00 5.52E-01 1.97E+00 1.11E+00 1.07E+00 1.02E+00;
5.50 7.96 9.58E-01 -7.26E-02 2.00E+00 1.00E+00 4.54E-01 1.88E+00 1.20E+00 1.07E+00 9.80E-01;
6.00 7.96 9.61E-01 -6.65E-02 2.00E+00 1.00E+00 3.30E-01 1.84E+00 1.18E+00 1.07E+00 9.59E-01;
6.50 7.96 8.89E-01 -1.09E-02 2.00E+00 1.00E+00 2.11E-01 1.85E+00 1.17E+00 1.07E+00 9.38E-01;
7.00 7.96 8.21E-01 5.64E-02 2.00E+00 1.00E+00 1.34E-01 1.89E+00 1.13E+00 1.08E+00 9.44E-01;
7.50 7.96 8.21E-01 5.26E-02 2.00E+00 1.00E+00 1.10E-01 1.95E+00 1.16E+00 1.07E+00 9.13E-01;
8.00 7.96 8.09E-01 5.02E-02 2.00E+00 1.00E+00 9.48E-02 1.89E+00 1.06E+00 1.08E+00 9.04E-01;
2.00 12.62 8.80E-01 -1.09E-02 2.00E+00 1.00E+00 1.44E+01 1.97E+00 8.61E-01 1.08E+00 1.07E+00;
2.50 12.62 8.77E-01 -1.29E-02 2.00E+00 1.00E+00 1.09E+01 1.98E+00 8.50E-01 1.08E+00 1.07E+00;
3.00 12.62 8.94E-01 -2.13E-02 2.00E+00 1.00E+00 6.61E+00 2.11E+00 9.07E-01 1.07E+00 1.07E+00;
3.50 12.62 8.92E-01 -3.71E-02 2.00E+00 1.00E+00 4.01E+00 2.16E+00 9.08E-01 1.08E+00 1.07E+00;
4.00 12.62 9.01E-01 -3.09E-02 2.00E+00 1.00E+00 2.09E+00 2.06E+00 9.64E-01 1.08E+00 1.06E+00;
4.50 12.62 9.45E-01 -7.00E-02 2.00E+00 1.00E+00 1.35E+00 2.15E+00 1.03E+00 1.07E+00 1.04E+00;
5.00 12.62 9.77E-01 -1.02E-01 2.00E+00 1.00E+00 9.01E-01 2.07E+00 1.06E+00 1.07E+00 1.01E+00;
5.50 12.62 1.01E+00 -1.29E-01 2.00E+00 1.00E+00 5.91E-01 2.00E+00 1.11E+00 1.07E+00 9.96E-01;
6.00 12.62 9.42E-01 -6.54E-02 2.00E+00 1.00E+00 3.90E-01 1.88E+00 1.14E+00 1.07E+00 9.74E-01;
6.50 12.62 9.40E-01 -7.12E-02 2.00E+00 1.00E+00 3.00E-01 1.87E+00 1.12E+00 1.07E+00 9.46E-01;
7.00 12.62 7.88E-01 8.40E-02 2.00E+00 1.00E+00 1.30E-01 1.94E+00 1.13E+00 1.08E+00 9.46E-01;
7.50 12.62 7.88E-01 8.09E-02 2.00E+00 1.00E+00 8.08E-02 2.11E+00 1.15E+00 1.07E+00 9.23E-01;
8.00 12.62 7.92E-01 7.05E-02 2.00E+00 1.00E+00 4.83E-02 2.28E+00 1.07E+00 1.08E+00 9.09E-01;
2.00 20.00 8.54E-01 -3.91E-03 2.00E+00 1.00E+00 6.77E+01 1.83E+00 7.47E-01 1.09E+00 1.08E+00;
2.50 20.00 8.48E-01 -3.92E-03 2.00E+00 1.00E+00 4.46E+01 1.85E+00 7.70E-01 1.09E+00 1.08E+00;
3.00 20.00 8.43E-01 -1.93E-03 2.00E+00 1.00E+00 2.99E+01 1.88E+00 7.54E-01 1.09E+00 1.07E+00;
3.50 20.00 8.38E-01 -5.17E-03 2.00E+00 1.00E+00 1.71E+01 1.87E+00 7.58E-01 1.08E+00 1.08E+00;
4.00 20.00 8.28E-01 2.97E-03 2.00E+00 1.00E+00 8.98E+00 1.85E+00 7.70E-01 1.08E+00 1.06E+00;
4.50 20.00 9.01E-01 -6.28E-02 2.00E+00 1.00E+00 5.92E+00 2.30E+00 8.47E-01 1.08E+00 1.06E+00;
5.00 20.00 8.99E-01 -5.38E-02 2.00E+00 1.00E+00 2.99E+00 2.14E+00 8.59E-01 1.08E+00 1.04E+00;
5.50 20.00 8.99E-01 -4.81E-02 2.00E+00 1.00E+00 1.45E+00 2.03E+00 9.10E-01 1.08E+00 1.02E+00;
6.00 20.00 8.89E-01 -4.06E-02 2.00E+00 1.00E+00 7.91E-01 1.94E+00 9.21E-01 1.07E+00 1.01E+00;
6.50 20.00 8.99E-01 -3.99E-02 2.00E+00 1.00E+00 5.11E-01 1.92E+00 1.02E+00 1.08E+00 9.93E-01;
7.00 20.00 9.00E-01 -4.37E-02 2.00E+00 1.00E+00 3.20E-01 1.92E+00 1.05E+00 1.07E+00 9.73E-01;
7.50 20.00 9.00E-01 -4.30E-02 2.00E+00 1.00E+00 2.34E-01 1.91E+00 1.08E+00 1.08E+00 9.42E-01;
8.00 20.00 7.78E-01 7.59E-02 2.00E+00 1.00E+00 4.83E-02 2.56E+00 1.06E+00 1.08E+00 9.28E-01;
2.00 31.70 8.45E-01 2.02E-03 2.00E+00 1.00E+00 2.00E+02 1.76E+00 7.32E-01 1.09E+00 1.09E+00;
2.50 31.70 8.45E-01 -5.58E-03 2.00E+00 1.00E+00 1.08E+02 1.70E+00 7.30E-01 1.10E+00 1.09E+00;
3.00 31.70 8.41E-01 -1.08E-02 2.00E+00 1.00E+00 8.64E+01 1.77E+00 6.97E-01 1.09E+00 1.09E+00;
3.50 31.70 8.33E-01 -5.48E-03 2.00E+00 1.00E+00 4.94E+01 1.81E+00 7.33E-01 1.09E+00 1.08E+00;
4.00 31.70 8.34E-01 -5.48E-03 2.00E+00 1.00E+00 2.98E+01 1.80E+00 7.21E-01 1.09E+00 1.08E+00;
4.50 31.70 8.34E-01 -5.48E-03 2.00E+00 1.00E+00 1.37E+01 1.86E+00 7.39E-01 1.09E+00 1.07E+00;
5.00 31.70 9.04E-01 -6.29E-02 2.00E+00 1.00E+00 8.88E+00 2.32E+00 8.18E-01 1.08E+00 1.06E+00;
5.50 31.70 8.92E-01 -5.15E-02 2.00E+00 1.00E+00 3.99E+00 2.16E+00 8.12E-01 1.08E+00 1.05E+00;
6.00 31.70 8.92E-01 -4.99E-02 2.00E+00 1.00E+00 2.05E+00 2.11E+00 8.49E-01 1.08E+00 1.02E+00;
6.50 31.70 8.97E-01 -5.50E-02 2.00E+00 1.00E+00 1.02E+00 2.04E+00 8.86E-01 1.07E+00 1.00E+00;
7.00 31.70 9.12E-01 -5.74E-02 2.00E+00 1.00E+00 5.88E-01 2.00E+00 9.85E-01 1.08E+00 9.96E-01;
7.50 31.70 8.98E-01 -4.83E-02 2.00E+00 1.00E+00 4.22E-01 1.88E+00 9.88E-01 1.08E+00 9.61E-01;
8.00 31.70 7.14E-01 1.34E-01 2.00E+00 1.00E+00 4.68E-02 2.85E+00 9.96E-01 1.08E+00 9.41E-01;
2.00 50.24 8.23E-01 9.71E-03 2.00E+00 1.00E+00 1.99E+02 1.45E+00 6.53E-01 1.10E+00 1.09E+00;
2.50 50.24 8.17E-01 4.57E-03 2.00E+00 1.00E+00 1.92E+02 1.52E+00 6.37E-01 1.10E+00 1.09E+00;
3.00 50.24 8.16E-01 4.75E-03 2.00E+00 1.00E+00 1.21E+02 1.53E+00 6.53E-01 1.09E+00 1.09E+00;
3.50 50.24 8.31E-01 -1.80E-03 2.00E+00 1.00E+00 6.94E+01 1.64E+00 7.11E-01 1.09E+00 1.08E+00;
4.00 50.24 8.28E-01 -1.80E-03 2.00E+00 1.00E+00 4.47E+01 1.70E+00 7.11E-01 1.09E+00 1.08E+00;
4.50 50.24 8.40E-01 -8.55E-03 2.00E+00 1.00E+00 2.47E+01 1.86E+00 7.43E-01 1.08E+00 1.08E+00;
5.00 50.24 8.41E-01 -1.05E-02 2.00E+00 1.00E+00 1.42E+01 1.87E+00 7.48E-01 1.09E+00 1.07E+00;
5.50 50.24 8.81E-01 -4.36E-02 2.00E+00 1.00E+00 7.52E+00 2.11E+00 8.01E-01 1.09E+00 1.06E+00;
6.00 50.24 9.08E-01 -6.64E-02 2.00E+00 1.00E+00 3.80E+00 2.20E+00 8.44E-01 1.08E+00 1.06E+00;
6.50 50.24 9.03E-01 -6.34E-02 2.00E+00 1.00E+00 1.81E+00 2.17E+00 8.72E-01 1.09E+00 1.04E+00;
7.00 50.24 8.99E-01 -6.06E-02 2.00E+00 1.00E+00 9.85E-01 2.07E+00 9.32E-01 1.08E+00 1.01E+00;
7.50 50.24 9.06E-01 -5.68E-02 2.00E+00 1.00E+00 5.25E-01 2.06E+00 9.78E-01 1.09E+00 9.83E-01;
8.00 50.24 9.02E-01 -5.65E-02 2.00E+00 1.00E+00 4.38E-01 1.85E+00 9.78E-01 1.09E+00 9.61E-01;
2.00 79.62 8.13E-01 9.64E-03 2.00E+00 1.00E+00 1.62E+02 1.47E+00 6.28E-01 1.10E+00 1.09E+00;
2.50 79.62 8.15E-01 4.60E-03 2.00E+00 1.00E+00 1.40E+02 1.52E+00 6.36E-01 1.10E+00 1.09E+00;
3.00 79.62 8.15E-01 3.78E-03 2.00E+00 1.00E+00 9.38E+01 1.57E+00 6.57E-01 1.09E+00 1.09E+00;
3.50 79.62 8.31E-01 -1.75E-03 2.00E+00 1.00E+00 5.71E+01 1.64E+00 7.08E-01 1.09E+00 1.08E+00;
4.00 79.62 8.31E-01 -1.58E-03 2.00E+00 1.00E+00 3.60E+01 1.73E+00 7.29E-01 1.09E+00 1.08E+00;
4.50 79.62 8.47E-01 -1.34E-02 2.00E+00 1.00E+00 2.20E+01 1.91E+00 7.56E-01 1.08E+00 1.08E+00;
5.00 79.62 8.40E-01 -1.03E-02 2.00E+00 1.00E+00 1.29E+01 1.85E+00 7.45E-01 1.08E+00 1.07E+00;
5.50 79.62 8.80E-01 -4.34E-02 2.00E+00 1.00E+00 6.95E+00 2.11E+00 8.01E-01 1.09E+00 1.06E+00;
6.00 79.62 9.08E-01 -6.79E-02 2.00E+00 1.00E+00 3.68E+00 2.18E+00 8.43E-01 1.08E+00 1.06E+00;
6.50 79.62 9.02E-01 -6.39E-02 2.00E+00 1.00E+00 1.76E+00 2.15E+00 8.73E-01 1.09E+00 1.04E+00;
7.00 79.62 8.99E-01 -6.06E-02 2.00E+00 1.00E+00 9.65E-01 2.07E+00 9.32E-01 1.08E+00 1.02E+00;
7.50 79.62 9.06E-01 -5.68E-02 2.00E+00 1.00E+00 5.25E-01 2.05E+00 9.78E-01 1.08E+00 9.87E-01;
8.00 79.62 9.06E-01 -6.15E-02 2.00E+00 1.00E+00 4.35E-01 1.87E+00 9.92E-01 1.09E+00 9.67E-01;
2.00 126.20 8.07E-01 1.13E-02 2.00E+00 1.00E+00 9.27E+01 1.48E+00 6.28E-01 1.10E+00 1.10E+00;
2.50 126.20 7.99E-01 1.14E-02 2.00E+00 1.00E+00 7.95E+01 1.51E+00 6.28E-01 1.10E+00 1.10E+00;
3.00 126.20 8.15E-01 1.60E-03 2.00E+00 1.00E+00 6.07E+01 1.56E+00 6.60E-01 1.10E+00 1.09E+00;
3.50 126.20 8.21E-01 4.21E-03 2.00E+00 1.00E+00 4.81E+01 1.68E+00 6.96E-01 1.09E+00 1.09E+00;
4.00 126.20 8.21E-01 4.21E-03 2.00E+00 1.00E+00 2.97E+01 1.68E+00 7.06E-01 1.09E+00 1.08E+00;
4.50 126.20 8.39E-01 -8.12E-03 2.00E+00 1.00E+00 1.85E+01 1.84E+00 7.39E-01 1.09E+00 1.08E+00;
5.00 126.20 8.36E-01 -9.62E-03 2.00E+00 1.00E+00 1.02E+01 1.85E+00 7.46E-01 1.08E+00 1.07E+00;
5.50 126.20 8.37E-01 2.48E-03 2.00E+00 1.00E+00 4.92E+00 1.91E+00 8.11E-01 1.08E+00 1.06E+00;
6.00 126.20 9.19E-01 -7.39E-02 2.00E+00 1.00E+00 3.31E+00 2.14E+00 8.67E-01 1.08E+00 1.05E+00;
6.50 126.20 9.04E-01 -6.36E-02 2.00E+00 1.00E+00 1.55E+00 2.12E+00 8.89E-01 1.08E+00 1.04E+00;
7.00 126.20 9.10E-01 -6.30E-02 2.00E+00 1.00E+00 9.99E-01 2.01E+00 9.37E-01 1.08E+00 1.01E+00;
7.50 126.20 9.10E-01 -5.98E-02 2.00E+00 1.00E+00 4.80E-01 2.11E+00 9.96E-01 1.09E+00 9.99E-01;
8.00 126.20 9.11E-01 -6.10E-02 2.00E+00 1.00E+00 3.88E-01 1.98E+00 1.03E+00 1.08E+00 9.65E-01;
2.00 200.01 8.03E-01 1.14E-02 2.00E+00 1.00E+00 5.52E+01 1.54E+00 6.35E-01 1.10E+00 1.10E+00;
2.50 200.01 8.05E-01 1.04E-02 2.00E+00 1.00E+00 5.48E+01 1.56E+00 6.42E-01 1.10E+00 1.10E+00;
3.00 200.01 7.96E-01 9.85E-03 2.00E+00 1.00E+00 4.57E+01 1.61E+00 6.42E-01 1.10E+00 1.09E+00;
3.50 200.01 8.17E-01 4.13E-03 2.00E+00 1.00E+00 3.42E+01 1.67E+00 6.94E-01 1.09E+00 1.09E+00;
4.00 200.01 8.21E-01 3.96E-03 2.00E+00 1.00E+00 2.26E+01 1.69E+00 7.14E-01 1.09E+00 1.09E+00;
4.50 200.01 8.36E-01 -5.16E-03 2.00E+00 1.00E+00 1.55E+01 1.81E+00 7.40E-01 1.08E+00 1.09E+00;
5.00 200.01 8.58E-01 -1.69E-02 2.00E+00 1.00E+00 8.78E+00 1.94E+00 7.98E-01 1.08E+00 1.08E+00;
5.50 200.01 8.57E-01 -2.11E-02 2.00E+00 1.00E+00 5.28E+00 1.92E+00 8.12E-01 1.08E+00 1.08E+00;
6.00 200.01 9.16E-01 -7.26E-02 2.00E+00 1.00E+00 3.31E+00 2.12E+00 8.67E-01 1.07E+00 1.05E+00;
6.50 200.01 9.12E-01 -6.39E-02 2.00E+00 1.00E+00 1.72E+00 2.09E+00 9.05E-01 1.07E+00 1.04E+00;
7.00 200.01 9.13E-01 -5.82E-02 2.00E+00 1.00E+00 9.01E-01 2.07E+00 9.64E-01 1.07E+00 1.01E+00;
7.50 200.01 9.09E-01 -4.69E-02 2.00E+00 1.00E+00 5.33E-01 2.03E+00 1.01E+00 1.07E+00 1.01E+00;
8.00 200.01 9.11E-01 -6.10E-02 2.00E+00 1.00E+00 3.73E-01 1.98E+00 1.06E+00 1.08E+00 9.65E-01;
2.00 317.00 7.96E-01 1.29E-02 2.00E+00 1.00E+00 3.56E+01 1.54E+00 6.16E-01 1.10E+00 1.10E+00;
2.50 317.00 8.04E-01 1.04E-02 2.00E+00 1.00E+00 3.17E+01 1.56E+00 6.42E-01 1.10E+00 1.09E+00;
3.00 317.00 7.98E-01 9.68E-03 2.00E+00 1.00E+00 2.78E+01 1.60E+00 6.45E-01 1.10E+00 1.09E+00;
3.50 317.00 8.17E-01 6.15E-03 2.00E+00 1.00E+00 2.27E+01 1.66E+00 6.91E-01 1.09E+00 1.08E+00;
4.00 317.00 8.07E-01 1.58E-02 2.00E+00 1.00E+00 1.68E+01 1.60E+00 7.06E-01 1.09E+00 1.09E+00;
4.50 317.00 8.36E-01 -2.58E-03 2.00E+00 1.00E+00 1.51E+01 1.77E+00 7.40E-01 1.08E+00 1.08E+00;
5.00 317.00 8.62E-01 -1.75E-02 2.00E+00 1.00E+00 9.30E+00 1.84E+00 7.97E-01 1.08E+00 1.08E+00;
5.50 317.00 8.50E-01 -1.08E-02 2.00E+00 1.00E+00 5.28E+00 1.90E+00 8.12E-01 1.08E+00 1.07E+00;
6.00 317.00 9.11E-01 -6.30E-02 2.00E+00 1.00E+00 3.75E+00 2.16E+00 8.89E-01 1.07E+00 1.06E+00;
6.50 317.00 9.01E-01 -4.47E-02 2.00E+00 1.00E+00 1.85E+00 2.09E+00 9.26E-01 1.07E+00 1.05E+00;
7.00 317.00 8.90E-01 -4.04E-02 2.00E+00 1.00E+00 1.17E+00 2.12E+00 9.31E-01 1.07E+00 1.03E+00;
7.50 317.00 9.09E-01 -4.71E-02 2.00E+00 1.00E+00 6.17E-01 2.27E+00 1.04E+00 1.08E+00 1.02E+00;
8.00 317.00 9.47E-01 -8.14E-02 2.00E+00 1.00E+00 5.15E-01 2.08E+00 1.13E+00 1.08E+00 9.94E-01;
2.00 502.41 7.98E-01 1.55E-02 2.00E+00 1.00E+00 1.93E+01 1.55E+00 6.24E-01 1.10E+00 1.09E+00;
2.50 502.41 8.09E-01 7.96E-03 2.00E+00 1.00E+00 1.93E+01 1.64E+00 6.51E-01 1.09E+00 1.09E+00;
3.00 502.41 7.97E-01 1.72E-02 2.00E+00 1.00E+00 1.70E+01 1.59E+00 6.58E-01 1.10E+00 1.09E+00;
3.50 502.41 7.99E-01 2.10E-02 2.00E+00 1.00E+00 1.63E+01 1.56E+00 6.81E-01 1.09E+00 1.09E+00;
4.00 502.41 7.99E-01 2.48E-02 2.00E+00 1.00E+00 1.17E+01 1.60E+00 7.12E-01 1.09E+00 1.09E+00;
4.50 502.41 8.36E-01 -3.24E-03 2.00E+00 1.00E+00 1.12E+01 1.77E+00 7.52E-01 1.09E+00 1.09E+00;
5.00 502.41 8.35E-01 -4.26E-03 2.00E+00 1.00E+00 8.83E+00 1.78E+00 7.54E-01 1.09E+00 1.09E+00;
5.50 502.41 8.53E-01 -1.36E-02 2.00E+00 1.00E+00 5.88E+00 1.89E+00 8.12E-01 1.08E+00 1.07E+00;
6.00 502.41 9.13E-01 -6.23E-02 2.00E+00 1.00E+00 4.09E+00 2.11E+00 8.79E-01 1.08E+00 1.07E+00;
6.50 502.41 9.03E-01 -4.36E-02 2.00E+00 1.00E+00 2.47E+00 2.11E+00 9.26E-01 1.08E+00 1.06E+00;
7.00 502.41 9.03E-01 -4.38E-02 2.00E+00 1.00E+00 1.52E+00 2.16E+00 9.33E-01 1.07E+00 1.05E+00;
7.50 502.41 1.14E+00 -2.86E-01 2.00E+00 1.00E+00 1.83E+00 2.33E+00 1.02E+00 1.08E+00 1.03E+00;
8.00 502.41 1.16E+00 -2.90E-01 2.00E+00 1.00E+00 1.29E+00 2.17E+00 1.10E+00 1.07E+00 1.02E+00;
2.00 796.26 9.55E-01 -1.31E-01 2.00E+00 1.00E+00 1.76E+01 2.00E+00 6.96E-01 1.10E+00 1.10E+00;
2.50 796.26 7.94E-01 2.00E-02 2.00E+00 1.00E+00 9.44E+00 1.60E+00 6.70E-01 1.10E+00 1.10E+00;
3.00 796.26 8.02E-01 1.36E-02 2.00E+00 1.00E+00 9.54E+00 1.62E+00 6.63E-01 1.10E+00 1.09E+00;
3.50 796.26 8.02E-01 1.34E-02 2.00E+00 1.00E+00 9.54E+00 1.54E+00 6.63E-01 1.10E+00 1.09E+00;
4.00 796.26 7.68E-01 5.02E-02 2.00E+00 1.00E+00 7.31E+00 1.51E+00 6.90E-01 1.10E+00 1.09E+00;
4.50 796.26 8.23E-01 6.32E-03 2.00E+00 1.00E+00 8.01E+00 1.74E+00 7.33E-01 1.10E+00 1.09E+00;
5.00 796.26 8.28E-01 1.78E-04 2.00E+00 1.00E+00 6.91E+00 1.75E+00 7.51E-01 1.09E+00 1.08E+00;
5.50 796.26 8.55E-01 -1.67E-02 2.00E+00 1.00E+00 5.63E+00 1.85E+00 7.99E-01 1.08E+00 1.07E+00;
6.00 796.26 8.52E-01 -1.20E-02 2.00E+00 1.00E+00 4.44E+00 2.00E+00 8.20E-01 1.08E+00 1.08E+00;
6.50 796.26 9.03E-01 -4.83E-02 2.00E+00 1.00E+00 3.06E+00 2.26E+00 9.14E-01 1.08E+00 1.07E+00;
7.00 796.26 9.35E-01 -7.41E-02 2.00E+00 1.00E+00 2.38E+00 2.05E+00 9.55E-01 1.08E+00 1.06E+00;
7.50 796.26 1.15E+00 -2.85E-01 2.00E+00 1.00E+00 2.49E+00 2.45E+00 1.03E+00 1.08E+00 1.05E+00;
8.00 796.26 1.18E+00 -3.10E-01 2.00E+00 1.00E+00 1.39E+00 2.42E+00 1.15E+00 1.07E+00 1.04E+00;
2.00 1262.00 1.06E+00 -2.31E-01 2.00E+00 1.00E+00 1.08E+01 1.97E+00 7.07E-01 1.10E+00 1.09E+00;
2.50 1262.00 1.06E+00 -2.32E-01 2.00E+00 1.00E+00 1.04E+01 1.94E+00 7.08E-01 1.10E+00 1.09E+00;
3.00 1262.00 1.06E+00 -2.32E-01 2.00E+00 1.00E+00 1.02E+01 1.94E+00 7.08E-01 1.09E+00 1.09E+00;
3.50 1262.00 1.06E+00 -2.36E-01 2.00E+00 1.00E+00 9.57E+00 1.96E+00 7.05E-01 1.10E+00 1.09E+00;
4.00 1262.00 1.05E+00 -2.36E-01 2.00E+00 1.00E+00 1.03E+01 1.96E+00 7.01E-01 1.10E+00 1.09E+00;
4.50 1262.00 1.07E+00 -2.37E-01 2.00E+00 1.00E+00 1.12E+01 2.07E+00 7.37E-01 1.10E+00 1.09E+00;
5.00 1262.00 8.30E-01 4.11E-03 2.00E+00 1.00E+00 4.26E+00 1.62E+00 7.53E-01 1.10E+00 1.08E+00;
5.50 1262.00 8.48E-01 -2.00E-02 2.00E+00 1.00E+00 4.02E+00 1.83E+00 7.85E-01 1.08E+00 1.08E+00;
6.00 1262.00 8.53E-01 -1.28E-02 2.00E+00 1.00E+00 3.56E+00 1.94E+00 8.23E-01 1.09E+00 1.09E+00;
6.50 1262.00 9.03E-01 -4.83E-02 2.00E+00 1.00E+00 3.17E+00 2.25E+00 9.14E-01 1.08E+00 1.07E+00;
7.00 1262.00 9.52E-01 -8.82E-02 2.00E+00 1.00E+00 3.14E+00 2.59E+00 9.79E-01 1.07E+00 1.06E+00;
7.50 1262.00 1.16E+00 -2.85E-01 2.00E+00 1.00E+00 2.56E+00 2.52E+00 1.04E+00 1.08E+00 1.06E+00;
8.00 1262.00 1.18E+00 -3.07E-01 2.00E+00 1.00E+00 3.10E+00 3.15E+00 1.15E+00 1.07E+00 1.05E+00 ]
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 20808 |
"""
SourceParameters
Custom type defining the source parameters of a Fourier spectrum.
Constructed with signature `SourceParameters{S<:Float64, T<:Real}` with fields:
- `Δσ::T` is the stress parameter in bars
- `RΘϕ::S` is the radiation pattern
- `V::S` is the partition factor (for splitting to horizontal components)
- `F::S` is the free surface factor
- `β::S` is the source velocity in units of km/s
- `ρ::S` is the source density in units of t/m³ or g/cm³
- `model::Symbol` identifies the type of source spectrum (`:Brune`, `:Atkinson_Silva_2000`)
"""
struct SourceParameters{S<:Float64,T<:Real,U<:Real}
# source parameters
Δσ::T# stressParameter
RΘϕ::S # radiationPattern
V::S # partitionFactor
F::S # freeSurfaceFactor
β::S # sourceVelocity
ρ::S # sourceDensity
n::U # high-frequency fall-off rate for Beresnev (2019)
model::Symbol # source spectrum model
end
SourceParameters(Δσ::T) where {T<:Float64} = SourceParameters(Δσ, 0.55, 1.0 / sqrt(2.0), 2.0, 3.5, 2.75, 1.0, :Brune)
SourceParameters(Δσ::T) where {T<:Real} = SourceParameters(Δσ, 0.55, 1.0 / sqrt(2.0), 2.0, 3.5, 2.75, 1.0, :Brune)
SourceParameters(Δσ::T, model::Symbol) where {T<:Real} = SourceParameters(Δσ, 0.55, 1.0 / sqrt(2.0), 2.0, 3.5, 2.75, 1.0, model)
SourceParameters(Δσ::T, βs::S, ρs::S) where {S<:Float64,T<:Real} = SourceParameters(Δσ, 0.55, 1.0 / sqrt(2.0), 2.0, βs, ρs, 1.0, :Brune)
SourceParameters(Δσ::T, βs::T, ρs::T) where {T<:Float64} = SourceParameters(Δσ, 0.55, 1.0 / sqrt(2.0), 2.0, βs, ρs, 1.0, :Brune)
SourceParameters(Δσ::T, n::T) where {T<:Real} = SourceParameters(Δσ, 0.55, 1.0 / sqrt(2.0), 2.0, 3.5, 2.75, n, :Beresnev_2019)
SourceParameters(Δσ::T, n::U) where {T<:Real,U<:Real} = SourceParameters(Δσ, 0.55, 1.0 / sqrt(2.0), 2.0, 3.5, 2.75, n, :Beresnev_2019)
"""
get_parametric_type(src::SourceParameters{S,T}) where {S,T} = T
Extract type of `T` from parametric `SourceParameters` struct
"""
get_parametric_type(src::SourceParameters{S,T}) where {S,T} = T
"""
GeometricSpreadingParameters
Struct for geometric spreading parameters.
Holds fields:
- `Rrefi` are reference distances, these are `<:Real` but will generally be `Float64` values
- `γconi` are constant spreading rates, meaning that they will not be free for AD purposes
- `γvari` are variable spreading rates, meaning that they can be represented as `Dual` numbers for AD
- `γfree` is a vector of `Bool` instances, or a `BitVector` that indicates which segments are constant or variable. Variable spreading rates are given `1` or `true`
- `model` is a symbol defining the type of spreading model `:Piecewise`, `:CY14`, `:CY14mod`
"""
struct GeometricSpreadingParameters{S<:Real,T<:Real,U<:Real,V<:AbstractVector{Bool}}
Rrefi::Vector{S}
γconi::Vector{T}
γvari::Vector{U}
γfree::V
model::Symbol
end
GeometricSpreadingParameters(Rrefi::Vector{S}, γconi::Vector{T}) where {S<:Real,T<:Real} = GeometricSpreadingParameters{S,T,Float64,BitVector}(Rrefi, γconi, Vector{Float64}(), BitVector(zeros(length(γconi))), :Piecewise)
GeometricSpreadingParameters(Rrefi::Vector{S}, γconi::Vector{T}, model::Symbol) where {S<:Real,T<:Real} = GeometricSpreadingParameters{S,T,Float64,BitVector}(Rrefi, γconi, Vector{Float64}(), BitVector(zeros(length(γconi))), model)
GeometricSpreadingParameters(Rrefi::Vector{S}, γvari::Vector{U}) where {S<:Real,U<:Dual} = GeometricSpreadingParameters{S,Float64,U,BitVector}(Rrefi, Vector{Float64}(), γvari, BitVector(ones(length(γvari))), :Piecewise)
GeometricSpreadingParameters(Rrefi::Vector{S}, γvari::Vector{U}, model::Symbol) where {S<:Real,U<:Dual} = GeometricSpreadingParameters{S,Float64,U,BitVector}(Rrefi, Vector{Float64}(), γvari, BitVector(ones(length(γvari))), model)
"""
get_parametric_type(geo::GeometricSpreadingParameters{S,T,U}) where {S,T,U} = T
Extract type of `T` from parametric `GeometricSpreadingParameters` struct
"""
get_parametric_type(geo::GeometricSpreadingParameters{S,T,U,V}) where {S,T,U,V} = (S <: Dual) ? S : ((T <: Dual) ? T : U)
"""
NearSourceSaturationParameters
Struct for near-source saturation parameters. Mimic structure of the `GeometricSpreadingParameters` struct.
Holds fields:
- `mRefi` reference magnitudes
- `hconi` constrained coefficients, not free for AD purposes
- `hvari` variable coefficients, free for AD purposes
- `hfree` is a vector of `Bool` instances, or a `BitVector` indicating which parameters are constant or variable
- `exponent` is the exponent used within equivalent point-source distance calculations: ``r_{ps} = \\left[r_{rup}^n + h(m)^n\\right]^{1/n}``
- `model` is a symbol defining the type of saturation model:
- `:BT15` is Boore & Thompson (2015)
- `:YA15` is Yenier & Atkinson (2015)
- `:CY14` is average Chiou & Youngs (2014)
- `:None` returns zero saturation length
- `:ConstantConstrained` is a fixed saturation length not subject to AD operations
- `:ConstantVariable` is a fixed saturation length that is subject to AD operations (i.e., is a `<:Dual`)
"""
struct NearSourceSaturationParameters{S<:Real,T<:Real,U<:AbstractVector{Bool}}
mRefi::Vector{S}
hconi::Vector{S}
hvari::Vector{T}
hfree::U
exponent::Int
model::Symbol
end
NearSourceSaturationParameters(model::Symbol) = NearSourceSaturationParameters(Vector{Float64}(), Vector{Float64}(), Vector{Float64}(), BitVector(), 2, model)
NearSourceSaturationParameters(exponent::Int, model::Symbol) = NearSourceSaturationParameters(Vector{Float64}(), Vector{Float64}(), Vector{Float64}(), BitVector(), exponent, model)
NearSourceSaturationParameters(mRefi::Vector{T}, hconi::Vector{T}, model::Symbol) where {T} = NearSourceSaturationParameters(mRefi, hconi, Vector{T}(), BitVector(undef, length(hconi)), 2, model)
NearSourceSaturationParameters(mRefi::Vector{S}, hvari::Vector{T}, model::Symbol) where {S,T} = NearSourceSaturationParameters(mRefi, Vector{S}(), hvari, BitVector(ones(length(hvari))), 2, model)
NearSourceSaturationParameters(mRefi::Vector{T}, hconi::Vector{T}) where {T} = NearSourceSaturationParameters(mRefi, hconi, Vector{T}(), BitVector(undef, length(hconi)), 2, :FullyConstrained)
NearSourceSaturationParameters(mRefi::Vector{S}, hvari::Vector{T}) where {S,T} = NearSourceSaturationParameters(mRefi, Vector{S}(), hvari, BitVector(ones(length(hvari))), 2, :FullyVariable)
# specialisation for a constant saturation term
NearSourceSaturationParameters(hcon::Float64) = NearSourceSaturationParameters(Vector{Float64}(), [hcon], Vector{Float64}(), BitVector(undef, 1), 2, :ConstantConstrained)
NearSourceSaturationParameters(hvar::T) where {T<:Dual} = NearSourceSaturationParameters(Vector{Float64}(), Vector{Float64}(), Vector{T}([hvar]), BitVector([1]), 2, :ConstantVariable)
# with exponents
NearSourceSaturationParameters(hcon::Float64, exponent::Int) = NearSourceSaturationParameters(Vector{Float64}(), [hcon], Vector{Float64}(), BitVector(undef, 1), exponent, :ConstantConstrained)
NearSourceSaturationParameters(hvar::T, exponent::Int) where {T<:Dual} = NearSourceSaturationParameters(Vector{Float64}(), Vector{Float64}(), Vector{T}([hvar]), BitVector([1]), exponent, :ConstantVariable)
"""
get_parametric_type(sat::NearSourceSaturationParameters{S,T,U}) where {S,T,U} = T
Extract type of `T` from parametric `NearSourceSaturationParameters` struct
"""
get_parametric_type(sat::NearSourceSaturationParameters{S,T,U}) where {S,T,U} = T
"""
AnelasticAttenuationParameters
Struct for anelastic attenuation parameters.
Holds fields:
- `Q0` quality factor at 1 Hz
- `η` quality exponent ∈ [0,1)
- `cQ` velocity (km/s) along propagation path used to determine `Q(f)`
- `rmetric` is a symbol `:Rrup` or `:Rps` to define which distance metric is used for anelastic attenuation
"""
struct AnelasticAttenuationParameters{S<:Real,T<:Real,U<:AbstractVector{Bool}}
Rrefi::Vector{S}
Q0coni::Vector{S}
Q0vari::Vector{T}
ηconi::Vector{S}
ηvari::Vector{T}
cQ::Vector{Float64}
Qfree::U
ηfree::U
rmetric::Symbol
end
AnelasticAttenuationParameters(Q0::T) where {T<:Float64} = AnelasticAttenuationParameters([0.0, Inf], [Q0], Vector{Float64}(), [0.0], Vector{Float64}(), [3.5], BitVector(zeros(1)), BitVector(zeros(1)), :Rps)
AnelasticAttenuationParameters(Q0::T) where {T<:Real} = AnelasticAttenuationParameters([0.0, Inf], Vector{Float64}(), [Q0], [0.0], Vector{T}(), [3.5], BitVector(ones(1)), BitVector(zeros(1)), :Rps)
AnelasticAttenuationParameters(Q0::T, η::T) where {T<:Float64} = AnelasticAttenuationParameters([0.0, Inf], [Q0], Vector{T}(), [η], Vector{T}(), [3.5], BitVector(zeros(1)), BitVector(zeros(1)), :Rps)
AnelasticAttenuationParameters(Q0::T, η::T, rmetric::Symbol) where {T<:Float64} = AnelasticAttenuationParameters([0.0, Inf], [Q0], Vector{T}(), [η], Vector{T}(), [3.5], BitVector(zeros(1)), BitVector(zeros(1)), rmetric)
AnelasticAttenuationParameters(Q0::T, η::T) where {T<:Real} = AnelasticAttenuationParameters([0.0, Inf], Vector{Float64}(), [Q0], Vector{Float64}(), [η], [3.5], BitVector(ones(1)), BitVector(ones(1)), :Rps)
AnelasticAttenuationParameters(Q0::T, η::T, rmetric::Symbol) where {T<:Real} = AnelasticAttenuationParameters([0.0, Inf], Vector{Float64}(), [Q0], Vector{Float64}(), [η], [3.5], BitVector(ones(1)), BitVector(ones(1)), rmetric)
AnelasticAttenuationParameters(Q0::S, η::T) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters([0.0, Inf], [Q0], Vector{T}(), Vector{S}(), [η], [3.5], BitVector(zeros(1)), BitVector(ones(1)), :Rps)
AnelasticAttenuationParameters(Q0::S, η::T, rmetric::Symbol) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters([0.0, Inf], [Q0], Vector{T}(), Vector{S}(), [η], [3.5], BitVector(zeros(1)), BitVector(ones(1)), rmetric)
AnelasticAttenuationParameters(Q0::S, η::T) where {S<:Real,T<:Float64} = AnelasticAttenuationParameters([0.0, Inf], Vector{T}(), [Q0], [η], Vector{S}(), [3.5], BitVector(ones(1)), BitVector(zeros(1)), :Rps)
AnelasticAttenuationParameters(Q0::S, η::T, rmetric::Symbol) where {S<:Real,T<:Float64} = AnelasticAttenuationParameters([0.0, Inf], Vector{T}(), [Q0], [η], Vector{S}(), [3.5], BitVector(ones(1)), BitVector(zeros(1)), rmetric)
AnelasticAttenuationParameters(Q0, η, cQ::Float64) = AnelasticAttenuationParameters([0.0, Inf], [Q0], Vector{Float64}(), [η], Vector{Float64}(), [cQ], BitVector(zeros(1)), BitVector(zeros(1)), :Rps)
AnelasticAttenuationParameters(Q0, η, cQ::Float64, rmetric::Symbol) = AnelasticAttenuationParameters([0.0, Inf], [Q0], Vector{Float64}(), [η], Vector{Float64}(), [cQ], BitVector(zeros(1)), BitVector(zeros(1)), rmetric)
AnelasticAttenuationParameters(Rrefi::Vector{T}, Q0coni::Vector{T}) where {T<:Float64} = AnelasticAttenuationParameters{T,T,BitVector}(Rrefi, Q0coni, Vector{T}(), zeros(T, length(Q0coni)), Vector{T}(), 3.5 * ones(T, length(Q0coni)), BitVector(zeros(length(Q0coni))), BitVector(zeros(length(Q0coni))), :Rps)
AnelasticAttenuationParameters(Rrefi::Vector{T}, Q0coni::Vector{T}, rmetric::Symbol) where {T<:Float64} = AnelasticAttenuationParameters{T,T,BitVector}(Rrefi, Q0coni, Vector{T}(), zeros(T, length(Q0coni)), Vector{T}(), 3.5 * ones(T, length(Q0coni)), BitVector(zeros(length(Q0coni))), BitVector(zeros(length(Q0coni))), rmetric)
AnelasticAttenuationParameters(Rrefi::Vector{S}, Q0vari::Vector{T}) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters{S,T,BitVector}(Rrefi, Vector{S}(), Q0vari, zeros(S, length(Q0vari)), Vector{S}(), 3.5 * ones(S, length(Q0vari)), BitVector(ones(length(Q0vari))), BitVector(zeros(length(Q0vari))), :Rps)
AnelasticAttenuationParameters(Rrefi::Vector{S}, Q0vari::Vector{T}, rmetric::Symbol) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters{S,T,BitVector}(Rrefi, Vector{S}(), Q0vari, zeros(S, length(Q0vari)), Vector{S}(), 3.5 * ones(S, length(Q0vari)), BitVector(ones(length(Q0vari))), BitVector(zeros(length(Q0vari))), rmetric)
AnelasticAttenuationParameters(Rrefi::Vector{T}, Q0coni::Vector{T}, ηconi::Vector{T}) where {T<:Float64} = AnelasticAttenuationParameters{T,T,BitVector}(Rrefi, Q0coni, Vector{T}(), ηconi, Vector{T}(), 3.5 * ones(T, length(Q0coni)), BitVector(zeros(length(Q0coni))), BitVector(zeros(length(ηconi))), :Rps)
AnelasticAttenuationParameters(Rrefi::Vector{T}, Q0coni::Vector{T}, ηconi::Vector{T}, rmetric::Symbol) where {T<:Float64} = AnelasticAttenuationParameters{T,T,BitVector}(Rrefi, Q0coni, Vector{T}(), ηconi, Vector{T}(), 3.5 * ones(T, length(Q0coni)), BitVector(zeros(length(Q0coni))), BitVector(zeros(length(ηconi))), rmetric)
AnelasticAttenuationParameters(Rrefi::Vector{S}, Q0vari::Vector{T}, ηvari::Vector{T}) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters{S,T,BitVector}(Rrefi, Vector{S}(), Q0vari, zeros(S, length(Q0vari)), ηvari, 3.5 * ones(S, length(Q0vari)), BitVector(ones(length(Q0vari))), BitVector(ones(length(ηvari))), :Rps)
AnelasticAttenuationParameters(Rrefi::Vector{S}, Q0vari::Vector{T}, ηvari::Vector{T}, rmetric::Symbol) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters{S,T,BitVector}(Rrefi, Vector{S}(), Q0vari, zeros(S, length(Q0vari)), ηvari, 3.5 * ones(S, length(Q0vari)), BitVector(ones(length(Q0vari))), BitVector(ones(length(Q0vari))), rmetric)
AnelasticAttenuationParameters(Rrefi::Vector{S}, Q0coni::Vector{S}, ηvari::Vector{T}) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters{S,T,BitVector}(Rrefi, Q0coni, Vector{T}(), Vector{S}(), ηvari, 3.5 * ones(S, length(Q0coni)), BitVector(zeros(length(Q0coni))), BitVector(ones(length(ηvari))), :Rps)
AnelasticAttenuationParameters(Rrefi::Vector{S}, Q0coni::Vector{S}, ηvari::Vector{T}, rmetric::Symbol) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters{S,T,BitVector}(Rrefi, Q0coni, Vector{T}(), Vector{S}(), ηvari, 3.5 * ones(S, length(Q0coni)), BitVector(zeros(length(Q0coni))), BitVector(ones(length(ηvari))), rmetric)
AnelasticAttenuationParameters(Rrefi::Vector{S}, Q0vari::Vector{T}, ηconi::Vector{S}) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters{S,T,BitVector}(Rrefi, Vector{S}(), Q0vari, ηconi, Vector{T}(), 3.5 * ones(S, length(Q0vari)), BitVector(ones(length(Q0vari))), BitVector(zeros(length(ηconi))), :Rps)
AnelasticAttenuationParameters(Rrefi::Vector{S}, Q0vari::Vector{T}, ηconi::Vector{S}, rmetric::Symbol) where {S<:Float64,T<:Real} = AnelasticAttenuationParameters{S,T,BitVector}(Rrefi, Vector{S}(), Q0vari, ηconi, Vector{T}(), 3.5 * ones(S, length(Q0vari)), BitVector(ones(length(Q0vari))), BitVector(zeros(length(ηconi))), rmetric)
"""
get_parametric_type(anelastic::AnelasticAttenuationParameters{S,T,U}) where {S,T,U}
Extract type most elaborate type `S` or `T` from parametric `AnelasticAttenuationParameters` struct
"""
function get_parametric_type(anelastic::AnelasticAttenuationParameters{S,T,U}) where {S,T,U}
if S <: Float64
if T <: Float64
return S
else
return T
end
else
return S
end
end
"""
PathParameters
Custom type defining the path parameters of a Fourier spectrum.
Consists of three other custom structs
- `geometric` is a `GeometricSpreadingParameters` type
- `saturation` is a `NearSourceSaturationParameters` type
- `anelastic` is an `AnelasticAttenuationParameters` type
The base constructor is: `PathParameters(geo::G, sat::S, ane::A) where {G<:GeometricSpreadingParameters, S<:NearSourceSaturationParameters, A<:AnelasticAttenuationParameters}`
See also: [`FourierParameters`](@ref)
"""
struct PathParameters{G<:GeometricSpreadingParameters,S<:NearSourceSaturationParameters,A<:AnelasticAttenuationParameters}
geometric::G
saturation::S
anelastic::A
end
PathParameters(geometric::GeometricSpreadingParameters, anelastic::AnelasticAttenuationParameters) = PathParameters(geometric, NearSourceSaturationParameters(:None), anelastic)
"""
get_parametric_type(path::PathParameters)
Extract type most elaborate type from parametric `PathParameters` struct.
This requires dropping down to lower level structs within `path`.
"""
function get_parametric_type(path::PathParameters)
T = get_parametric_type(path.geometric)
U = get_parametric_type(path.saturation)
V = get_parametric_type(path.anelastic)
if T <: Float64
if U <: Float64
return V
else
return U
end
else
return T
end
end
@doc raw"""
SiteParameters
Custom type defining the site parameters of a Fourier spectrum
- `κ0::T where T<:Real` is the site kappa in units of s
- `ζ0::U where U<:Real` is the Haendel et al. (2020) ζ parameter (for a reference frequency of ``f_0=1`` Hz)
- `η::V where V<:Real` is the Haendel et al. (2020) η parameter
- `model::W where W<:SiteAmplification` is a site amplification model defining the impedance function
The argument `model` is currently one of:
- `SiteAmpUnit` for a generic unit amplification
- `SiteAmpBoore2016` for the Boore (2016) amplification for ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_ask14_620` for the Al Atik & Abrahamson (2021) inversion of ASK14 for ``V_{S,30}=620`` m/s
- `SiteAmpAlAtikAbrahamson2021_ask14_760` for the Al Atik & Abrahamson (2021) inversion of ASK14 for ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_ask14_1100` for the Al Atik & Abrahamson (2021) inversion of ASK14 for ``V_{S,30}=1100`` m/s
- `SiteAmpAlAtikAbrahamson2021_bssa14_620` for the Al Atik & Abrahamson (2021) inversion of BSSA14 for ``V_{S,30}=620`` m/s
- `SiteAmpAlAtikAbrahamson2021_bssa14_760` for the Al Atik & Abrahamson (2021) inversion of BSSA14 for ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_bssa14_1100` for the Al Atik & Abrahamson (2021) inversion of BSSA14 for ``V_{S,30}=1100`` m/s
- `SiteAmpAlAtikAbrahamson2021_cb14_620` for the Al Atik & Abrahamson (2021) inversion of CB14 for ``V_{S,30}=620`` m/s
- `SiteAmpAlAtikAbrahamson2021_cb14_760` for the Al Atik & Abrahamson (2021) inversion of CB14 for ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_cb14_1100` for the Al Atik & Abrahamson (2021) inversion of CB14 for ``V_{S,30}=1100`` m/s
- `SiteAmpAlAtikAbrahamson2021_cy14_620` for the Al Atik & Abrahamson (2021) inversion of CY14 for ``V_{S,30}=620`` m/s
- `SiteAmpAlAtikAbrahamson2021_cy14_760` for the Al Atik & Abrahamson (2021) inversion of CY14 for ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_cy14_1100` for the Al Atik & Abrahamson (2021) inversion of CY14 for ``V_{S,30}=1100`` m/s
See also: [`FourierParameters`](@ref), [`site_amplification`](@ref)
"""
struct SiteParameters{T<:Real,U<:Real,V<:Real,W<:SiteAmplification}
# site parameters
κ0::T # site kappa
ζ0::U # zeta parameter for f0=1 Hz
η::V # eta parameter
model::W # site amplification model
end
SiteParameters(κ0::T) where {T<:Real} = SiteParameters(κ0, NaN, NaN, SiteAmpAlAtikAbrahamson2021_cy14_760())
SiteParameters(κ0::T, model::S) where {T<:Real,S<:SiteAmplification} = SiteParameters(κ0, NaN, NaN, model)
SiteParameters(ζ0::T, η::U) where {T<:Real,U<:Real} = SiteParameters(NaN, ζ0, η, SiteAmpAlAtikAbrahamson2021_cy14_760())
SiteParameters(ζ0::T, η::U, model::V) where {T<:Real,U<:Real,V<:SiteAmplification} = SiteParameters(NaN, ζ0, η, model)
"""
get_parametric_type(site::SiteParameters{T}) where {T} = T
Extract type of `T` from parametric `SiteParameters` struct
"""
get_parametric_type(site::SiteParameters{T}) where {T} = T
"""
FourierParameters
Custom type for the parameters the Fourier amplitude spectrum.
This type is comprised of source, path and site types, and so has a base constructor of: `FourierParameters(src::S, path::T, site::U) where {S<:SourceParameters, T<:PathParameters, U<:SiteParameters}`
See also: [`SourceParameters`](@ref), [`PathParameters`](@ref), [`SiteParameters`](@ref)
"""
struct FourierParameters{S<:SourceParameters,T<:PathParameters,U<:SiteParameters}
source::S # source parameters
path::T # path parameters
site::U # site parameters
end
# initialiser focussing upon source and path response only. Uses zero kappa and unit amplification
FourierParameters(src::S, path::T) where {S<:SourceParameters,T<:PathParameters} = FourierParameters(src, path, SiteParameters(0.0, SiteAmpUnit()))
"""
get_parametric_type(fas::FourierParameters)
Extract type most elaborate type from parametric `FourierParameters` struct.
This requires dropping down to lower level structs within `fas`.
"""
function get_parametric_type(fas::FourierParameters)
T = get_parametric_type(fas.source)
U = get_parametric_type(fas.path)
V = get_parametric_type(fas.site)
if T <: Float64
if U <: Float64
return V
else
return U
end
else
return T
end
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 26420 |
"""
fourier_constant(src::SourceParameters)
Define the constant source term for the Fourier Amplitude Spectrum.
The value provided corresponds to Fourier displacement units of cm-s.
Constant set to permit distances to be passed in km, densities in t/m^3, and velocities in km/s.
The reference distance is set to 1.0 km (and interpreted to be a rupture distance).
"""
function fourier_constant(src::SourceParameters)
# note that the 1e-20 factor allows one to pass in distances in km, density in t/m^3, velocity in km/s
Rref0 = 1.0
return src.RΘϕ * src.V * src.F * 1e-20 / (4π * src.ρ * src.β^3 * Rref0)
end
fourier_constant(fas::FourierParameters) = fourier_constant(fas.source)
"""
fourier_source_shape(f::Float64, fa::T, fb::T, ε::T, src::SourceParameters) where T<:Real
Fourier amplitude spectral shape for _displacement_ defined by corner frequencies.
See also: [`fourier_source_shape`](@ref)
"""
function fourier_source_shape(f::Float64, fa::T, fb::T, ε::T, src::SourceParameters) where {T<:Real}
if src.model == :Brune
# use single corner, with fa=fc
return 1.0 / (1.0 + (f / fa)^2)
elseif src.model == :Atkinson_Silva_2000
# use double corner model
return (1.0 - ε) / (1.0 + (f / fa)^2) + ε / (1.0 + (f / fb)^2)
elseif src.model == :Beresnev_2019
# include a high-frequency roll-off parameter n
rolloff = (src.n + 1.0) / 2.0
return 1.0 / ((1.0 + (f / fa)^2)^rolloff)
else
# use single corner, with fa=fc
return 1.0 / (1.0 + (f / fa)^2)
end
end
"""
fourier_source_shape(f::Float64, fa::T, fb::T, ε::T, fas::FourierParameters) where T<:Real
Fourier amplitude spectral shape for _displacement_ defined by corner frequencies.
See also: [`fourier_source_shape`](@ref)
"""
fourier_source_shape(f, fa, fb, ε, fas::FourierParameters) = fourier_source_shape(f, fa, fb, ε, fas.source)
"""
fourier_source_shape(f::T, m::S, src::SourceParameters) where {S<:Real,T<:Float64}
Source shape of the Fourier Amplitude Spectrum of _displacement_, without the constant term or seismic moment.
This simply includes the source spectral shape.
The nature of the source spectral shape depends upon `src.model`:
- `:Brune` gives the single corner omega-squared spectrum (this is the default)
- `:Atkinson_Silva_2000` gives the double corner spectrum of Atkinson & Silva (2000)
- `:Beresnev_2019` gives a single-corner spectrum with arbitrary fall off rate related to `src.n` from Beresnev (2019)
"""
function fourier_source_shape(f::T, m::S, src::SourceParameters) where {S<:Real,T<:Float64}
fa, fb, ε = corner_frequency(m, src)
return fourier_source_shape(f, fa, fb, ε, src)
end
"""
fourier_source_shape(f, m, fas::FourierParameters)
Source shape of the Fourier amplitude spectrum of _displacement_, without the constant term or seismic moment.
Defined using a `FourierParameters` instance for the source model.
See also: [`fourier_source_shape`](@ref)
"""
fourier_source_shape(f, m, fas::FourierParameters) = fourier_source_shape(f, m, fas.source)
"""
fourier_source_shape(f::Vector{S}, fa::T, fb::T, ε::T, src::SourceParameters) where {S<:Real,T<:Real}
Fourier amplitude spectral shape for _displacement_ defined by corner frequencies.
See also: [`fourier_source_shape`](@ref)
"""
function fourier_source_shape(f::Vector{S}, fa::T, fb::T, ε::T, src::SourceParameters) where {S<:Real,T<:Real}
if src.model == :Brune
# use single corner, with fa=fc
return @. 1.0 / (1.0 + (f / fa)^2)
elseif src.model == :Atkinson_Silva_2000
# use double corner model
return @. (1.0 - ε) / (1.0 + (f / fa)^2) + ε / (1.0 + (f / fb)^2)
elseif src.model == :Beresnev_2019
# include a high-frequency roll-off parameter n
rolloff = (src.n + 1.0) / 2.0
return @. 1.0 / ((1.0 + (f / fa)^2)^rolloff)
else
# use single corner, with fa=fc
return @. 1.0 / (1.0 + (f / fa)^2)
end
end
"""
fourier_source_shape(f::Vector{T}, m::S, src::SourceParameters) where {S<:Real,T<:Float64}
Source shape of the Fourier Amplitude Spectrum of _displacement_, without the constant term or seismic moment.
This simply includes the source spectral shape.
The nature of the source spectral shape depends upon `src.model`:
- `:Brune` gives the single corner omega-squared spectrum (this is the default)
- `:Atkinson_Silva_2000` gives the double corner spectrum of Atkinson & Silva (2000)
- `:Beresnev_2019` gives a single-corner spectrum with arbitrary fall off rate related to `src.n` from Beresnev (2019)
"""
function fourier_source_shape(f::Vector{S}, m::T, src::SourceParameters) where {S<:Real,T<:Real}
fa, fb, ε = corner_frequency(m, src)
return fourier_source_shape(f, fa, fb, ε, src)
end
"""
fourier_source(f::T, m::S, src::SourceParameters) where {S<:Real,T<:Float64}
Source Fourier Amplitude Spectrum of displacement, without the constant term.
This simply includes the seismic moment and the source spectral shape.
See also: [`fourier_source_shape`](@ref)
"""
function fourier_source(f::T, m::S, src::SourceParameters) where {S<:Real,T<:Float64}
Mo = magnitude_to_moment(m)
return Mo * fourier_source_shape(f, m, src)
end
"""
fourier_source(f, m, fas::FourierParameters)
Source Fourier Amplitude Spectrum of displacement, without the constant term.
This simply includes the seismic moment and the source spectral shape.
Defined using a `FourierParameters` instance for the source model.
See also: [`fourier_source_shape`](@ref)
"""
fourier_source(f, m, fas::FourierParameters) = fourier_source(f, m, fas.source)
"""
fourier_path(f::U, r_ps::T, m::S, geo::GeometricSpreadingParameters, sat::NearSourceSaturationParameters, ane::AnelasticAttenuationParameters) where {S<:Real,T<:Real,U<:Float64}
Path scaling of Fourier spectral model -- combination of geometric spreading and anelastic attenuation.
See also: [`geometric_spreading`](@ref), [`anelastic_attenuation`](@ref)
"""
function fourier_path(f::U, r_ps::T, m::S, geo::GeometricSpreadingParameters, sat::NearSourceSaturationParameters, ane::AnelasticAttenuationParameters) where {S<:Real,T<:Real,U<:Float64}
Zr = geometric_spreading(r_ps, m, geo, sat)
if ane.rmetric == :Rrup
r_rup = rupture_distance_from_equivalent_point_source_distance(r_ps, m, sat)
Qr = anelastic_attenuation(f, r_rup, ane)
else
Qr = anelastic_attenuation(f, r_ps, ane)
end
return Zr * Qr
end
fourier_path(f, r_ps, m, path::PathParameters) = fourier_path(f, r_ps, m, path.geometric, path.saturation, path.anelastic)
fourier_path(f, r_ps, m, fas::FourierParameters) = fourier_path(f, r_ps, m, fas.path)
# simplified cases where m is not required
fourier_path(f, r_ps, path::PathParameters) = fourier_path(f, r_ps, NaN, path.geometric, path.saturation, path.anelastic)
fourier_path(f, r_ps, fas::FourierParameters) = fourier_path(f, r_ps, fas.path)
"""
fourier_attenuation(f::S, r::T, ane::AnelasticAttenuationParameters{U,V}, site::SiteParameters{W}) where {S<:Float64,T<:Real,U<:Real,V<:Real,W<:Real}
Combined full-path attenuation, including `Q(f)` effects and `κ0` filter for frequency `f`
Distance defined in terms of an equivalent point source distance `r_ps` or rupture distance `r_rup` depending upon what metric is defined in `ane.rmetric`
"""
function fourier_attenuation(f::S, r::T, ane::AnelasticAttenuationParameters{U,V}, site::SiteParameters{W}) where {S<:Float64,T<:Real,U<:Real,V<:Real,W<:Real}
if f < eps()
return oneunit(promote_type(T, U, V, W))
else
Qr = anelastic_attenuation(f, r, ane)
Kf = kappa_filter(f, site)
return Qr * Kf
end
end
fourier_attenuation(f::S, r::T, path::PathParameters, site::SiteParameters) where {S<:Float64,T<:Real} = fourier_attenuation(f, r, path.anelastic, site)
fourier_attenuation(f::S, r::T, fas::FourierParameters) where {S<:Float64,T<:Real} = fourier_attenuation(f, r, fas.path, fas.site)
"""
fourier_attenuation(f::Vector{S}, r::T, ane::AnelasticAttenuationParameters{U,V}, site::SiteParameters{W}) where {S<:Float64,T<:Real,U<:Real,V<:Real,W<:Real}
Combined full-path attenuation, including `Q(f)` effects and `κ0` filter for frequency `f`
Distance defined in terms of an equivalent point source distance `r_ps` or rupture distance `r_rup` depending upon what metric is defined in `ane.rmetric`
"""
function fourier_attenuation(f::Vector{S}, r::T, ane::AnelasticAttenuationParameters{U,V}, site::SiteParameters{W}) where {S<:Float64,T<:Real,U<:Real,V<:Real,W<:Real}
f = clamp!(f, eps(), Inf)
Qr = anelastic_attenuation(f, r, ane)
Kf = kappa_filter(f, site)
return Qr .* Kf
end
fourier_attenuation(f::Vector{S}, r::T, path::PathParameters, site::SiteParameters) where {S<:Float64,T<:Real} = fourier_attenuation(f, r, path.anelastic, site)
fourier_attenuation(f::Vector{S}, r::T, fas::FourierParameters) where {S<:Float64,T<:Real} = fourier_attenuation(f, r, fas.path, fas.site)
"""
apply_fourier_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, ane::AnelasticAttenuationParameters, site::SiteParameters) where {T<:Real,U<:Real,V<:Real}
Apply the fourier attenuation (`Q(f)` and `κ₀`) filters to an existing FAS `Af`.
Combined full-path attenuation, including `Q(f)` effects and `κ₀` filter for frequency `f`
Distance defined in terms of an equivalent point source distance `r_ps` or rupture distance `r_rup` depending upon what metric is defined in `ane.rmetric`
"""
function apply_fourier_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, ane::AnelasticAttenuationParameters, site::SiteParameters) where {T<:Real,U<:Real,V<:Real}
f = clamp!(f, eps(), Inf)
apply_anelastic_attenuation!(Af, f, r, ane)
apply_kappa_filter!(Af, f, site)
end
apply_fourier_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, path::PathParameters, site::SiteParameters) where {T<:Real,U<:Real,V<:Real} = apply_fourier_attenuation!(Af, f, r, path.anelastic, site)
apply_fourier_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, fas::FourierParameters) where {T<:Real,U<:Real,V<:Real} = apply_fourier_attenuation!(Af, f, r, fas.path, fas.site)
"""
apply_fourier_path_and_site_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, anelastic::AnelasticAttenuationParameters, site::SiteParameters) where {T<:Real,U<:Real,V<:Real}
Apply both the anelastic and site kappa attenuation effects to an existing FAS `Af`
"""
function apply_fourier_path_and_site_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, anelastic::AnelasticAttenuationParameters, site::SiteParameters) where {T<:Real,U<:Real,V<:Real}
numAf = length(Af)
numf = length(f)
numAf == numf || error("length of vector `f` must match the length of vector `Af`")
f = clamp!(f, eps(), Inf)
jq = jη = 1
kq = kη = 1
nsegs = length(anelastic.Qfree)
exp_arg = zeros(T, numf)
for i = 1:nsegs
@inbounds Rr0 = anelastic.Rrefi[i]
@inbounds Rr1 = anelastic.Rrefi[i+1]
@inbounds cQ_r = anelastic.cQ[i]
# get the relevant constrained or free quality factor for this path segment
@inbounds if anelastic.Qfree[i] == 0
@inbounds Q0_r = anelastic.Q0coni[jq]
jq += 1
else
@inbounds Q0_r = anelastic.Q0vari[kq]
kq += 1
end
# get the relevant constrained of free quality exponent for this path segment
@inbounds if anelastic.ηfree[i] == 0
@inbounds η_r = anelastic.ηconi[jη]
jη += 1
else
@inbounds η_r = anelastic.ηvari[kη]
kη += 1
end
if η_r ≈ 0.0
fpow = f
else
if nsegs == 1
fpow = @. f^(1.0 - η_r)
else
# this avoids f^(1-η)
fpow = @. exp((1.0 - η_r) * log(f))
end
end
if r < Rr1
rlim = r
else
rlim = Rr1
end
for (j, fp) in pairs(fpow)
@inbounds exp_arg[j] += -π * fp * (rlim - Rr0) / (Q0_r * cQ_r)
end
end
if isnan(site.κ0)
# Eq. 20 of Haendel et al. (2020) (frequency dependent kappa)
# specified for a reference frequency of f0=1 Hz
for (i, ea) in pairs(exp_arg)
@inbounds Af[i] *= exp(ea -π * site.ζ0 * (1.0 - site.η) * exp((1.0 - site.η) * log(f[i])))
end
else
for (i, ea) in pairs(exp_arg)
@inbounds Af[i] *= exp(ea - π * site.κ0 * f[i])
end
end
return nothing
end
apply_fourier_path_and_site_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, path::PathParameters, site::SiteParameters) where {T<:Real,U<:Real,V<:Real} = apply_fourier_path_and_site_attenuation!(Af, f, r, path.anelastic, site)
apply_fourier_path_and_site_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, fas::FourierParameters) where {T<:Real,U<:Real,V<:Real} = apply_fourier_path_and_site_attenuation!(Af, f, r, fas.path, fas.site)
"""
fourier_site(f::Float64, site::SiteParameters)
Combined site amplification and kappa filter for frequency `f`
"""
function fourier_site(f::Float64, site::SiteParameters)
# kappa filter
Kf = kappa_filter(f, site)
# site impedance function
Sf = site_amplification(f, site)
return Sf * Kf
end
fourier_site(f::Float64, fas::FourierParameters) = fourier_site(f, fas.site)
"""
fourier_spectral_ordinate(f::S, m::S, r_ps::T, src::SourceParameters, geo::GeometricSpreadingParameters, ane::AnelasticAttenuationParameters, site::SiteParameters) where {S<:Float64,T<:Real}
Fourier acceleration spectral ordinate (m/s) based upon an equivalent point source distance `r_ps`
- `f` is frequency (Hz)
- `m` is magnitude
- `r_ps` is the equivalent point source distance including saturation effects (km)
- `src` are the source parameters `SourceParameters`
- `geo` are the geometric spreading parameters `GeometricSpreadingParameters`
- `sat` are the near source saturation parameters `NearSourceSaturationParameters`
- `ane` are the anelastic attenuation parameters `AnelasticAttenuationParameters`
- `site` are the site parameters `SiteParameters`
See also: [`fourier_spectrum`](@ref), [`fourier_spectrum!`](@ref)
"""
function fourier_spectral_ordinate(f::U, m::S, r_ps::T, src::SourceParameters, geo::GeometricSpreadingParameters, sat::NearSourceSaturationParameters, ane::AnelasticAttenuationParameters, site::SiteParameters) where {S<:Real,T<:Real,U<:Float64}
# define all constant terms here
C = fourier_constant(src)
# source term
Ef = fourier_source(f, m, src)
# geometric spreading
Gr = geometric_spreading(r_ps, m, geo, sat)
# combined attenuation of both path (κr) and site (κ0)
if ane.rmetric == :Rrup
r_rup = rupture_distance_from_equivalent_point_source_distance(r_ps, m, sat)
Kf = fourier_attenuation(f, r_rup, ane, site)
else
Kf = fourier_attenuation(f, r_ps, ane, site)
end
# site impedance
Sf = site_amplification(f, site)
# overall displacement spectrum (in cms) is Ef*Pf*Sf
# the division by 10^2 below is to convert from units of cm/s to m/s
return (2π * f)^2 * C * Ef * Gr * Kf * Sf / 100.0
end
"""
fourier_spectral_ordinate(f::U, m::S, r_ps::T, src::SourceParameters, path::PathParameters, site::SiteParameters) where {S<:Real,T<:Real,U<:Float64}
Fourier acceleration spectral ordinate (m/s) based upon an equivalent point source distance `r_ps`
- `f` is frequency (Hz)
- `m` is magnitude
- `r_ps` is the equivalent point source distance including saturation effects (km)
- `src` are the source parameters `SourceParameters`
- `path` are the path parameters `PathParameters`
- `site` are the site parameters `SiteParameters`
"""
fourier_spectral_ordinate(f::U, m::S, r_ps::T, src::SourceParameters, path::PathParameters, site::SiteParameters) where {S<:Real,T<:Real,U<:Float64} = fourier_spectral_ordinate(f, m, r_ps, src, path.geometric, path.saturation, path.anelastic, site)
"""
fourier_spectral_ordinate(f::U, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Float64}
Fourier acceleration spectral ordinate (m/s) based upon an equivalent point source distance `r_ps`
- `f` is frequency (Hz)
- `m` is magnitude
- `r_ps` is the equivalent point source distance including saturation effects (km)
- `fas` are the Fourier spectral parameters `FourierParameters`
"""
fourier_spectral_ordinate(f::U, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Float64} = fourier_spectral_ordinate(f, m, r_ps, fas.source, fas.path, fas.site)
"""
squared_fourier_spectral_ordinate(f::U, m::S, r_ps::T, src::SourceParameters, geo::GeometricSpreadingParameters, ane::AnelasticAttenuationParameters, site::SiteParameters) where {S<:Real,T<:Real}
Squared Fourier acceleration spectral ordinate (m^2/s^2) based upon an equivalent point source distance `r_ps`
- `f` is frequency (Hz)
- `m` is magnitude
- `r_ps` is the equivalent point source distance including saturation effects (km)
- `src` are the source parameters `SourceParameters`
- `geo` are the geometric spreading parameters `GeometricSpreadingParameters`
- `sat` are the near source saturation parameters `NearSourceSaturationParameters`
- `ane` are the anelastic attenuation parameters `AnelasticAttenuationParameters`
- `site` are the site parameters `SiteParameters`
See also: [`fourier_spectral_ordinate`](@ref), [`squared_fourier_spectrum`](@ref)
"""
function squared_fourier_spectral_ordinate(f::S, m::S, r_ps::T, src::SourceParameters, geo::GeometricSpreadingParameters, sat::NearSourceSaturationParameters, ane::AnelasticAttenuationParameters, site::SiteParameters) where {S<:Real,T<:Real}
return fourier_spectral_ordinate(f, m, r_ps, src, geo, sat, ane, site)^2
end
squared_fourier_spectral_ordinate(f::U, m::S, r_ps::T, src::SourceParameters, path::PathParameters, site::SiteParameters) where {S<:Real,T<:Real,U<:Float64} = squared_fourier_spectral_ordinate(f, m, r_ps, src, path.geometric, path.saturation, path.anelastic, site)
squared_fourier_spectral_ordinate(f::U, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Float64} = squared_fourier_spectral_ordinate(f, m, r_ps, fas.source, fas.path, fas.site)
"""
fourier_spectrum(f::Vector{U}, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Float64}
Fourier acceleration spectrum (m/s) based upon an equivalent point source distance `r_ps`
- `f` is `Vector` of frequencies (Hz)
- `m` is magnitude
- `r_ps` is the equivalent point source distance including saturation effects (km)
- `fas` are the Fourier spectral parameters `FourierParameters`
See also: [`fourier_spectral_ordinate`](@ref)
"""
function fourier_spectrum(f::Vector{U}, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Float64}
numf = length(f)
V = get_parametric_type(fas)
W = promote_type(S, T, U, V)
# if V <: Dual
# W = V
# elseif S <: Dual
# W = S
# else
# W = U
# end
if numf == 0
return Vector{W}()
else
# define all frequency independent terms here
C = fourier_constant(fas)
# source amplitude and corner frequencies
Mo = magnitude_to_moment(m)
fa, fb, ε = corner_frequency(m, fas)
# geometric spreading
Gr = geometric_spreading(r_ps, m, fas)
# site impedance
Sfi = site_amplification(f, fas)
factor = 4π^2 * C * Mo * Gr / 100.0
if fas.path.anelastic.rmetric == :Rrup
r_rup = rupture_distance_from_equivalent_point_source_distance(r_ps, m, fas)
end
Af = Vector{W}(undef, numf)
for i in 1:numf
fi = f[i]
# source term
Ef = fourier_source_shape(fi, fa, fb, ε, fas)
# combined attenuation
if fas.path.anelastic.rmetric == :Rrup
Kf = fourier_attenuation(fi, r_rup, fas)
else
Kf = fourier_attenuation(fi, r_ps, fas)
end
# site impedance
# Sf = site_amplification(fi, fas)
# apply factor and convert to acceleration in appropriate units (m/s)
Af[i] = Ef * Kf * Sfi[i] * factor * fi^2
end
return Af
end
end
"""
squared_fourier_spectrum(f::Vector{U}, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Float64}
Squared Fourier amplitude spectrum. Useful within spectral moment calculations.
See also: [`fourier_spectrum`](@ref), [`squared_fourier_spectral_ordinate`](@ref)
"""
function squared_fourier_spectrum(f::Vector{U}, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Float64}
Af = fourier_spectrum(f, m, r_ps, fas)
return Af .^ 2
end
"""
fourier_spectrum!(Af::Vector{U}, f::Vector{V}, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Real,V<:Float64}
Fourier acceleration spectrum (m/s) based upon an equivalent point source distance `r_ps`
- `Af` is the vector of fas amplitudes to be filled (m/s)
- `f` is `Vector` of frequencies (Hz)
- `m` is magnitude
- `r_ps` is the equivalent point source distance including saturation effects (km)
- `fas` are the Fourier spectral parameters `FourierParameters`
See also: [`fourier_spectrum`](@ref)
"""
function fourier_spectrum!(Af::Vector{U}, f::Vector{V}, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Real,V<:Float64}
numf = length(f)
numAf = length(Af)
numf == numAf || error("length of `f` and `Af` must be equal")
if numf == 0
Af = Vector{U}()
else
# define all frequency independent terms here
C = fourier_constant(fas)
# source amplitude and corner frequencies
Mo = magnitude_to_moment(m)
fa, fb, ε = corner_frequency(m, fas)
# geometric spreading
Gr = geometric_spreading(r_ps, m, fas)
# site impedance
Sfi = site_amplification(f, fas)
factor = 4π^2 * C * Mo * Gr / 100.0
if fas.path.anelastic.rmetric == :Rrup
r_rup = rupture_distance_from_equivalent_point_source_distance(r_ps, m, fas)
end
for i in 1:numf
fi = f[i]
# source term
Ef = fourier_source_shape(fi, fa, fb, ε, fas)
# combined attenuation
if fas.path.anelastic.rmetric == :Rrup
Kf = fourier_attenuation(fi, r_rup, fas)
else
Kf = fourier_attenuation(fi, r_ps, fas)
end
# site impedance
# Sf = site_amplification(fi, fas)
# apply factor and convert to acceleration in appropriate units (m/s)
Af[i] = Ef * Kf * Sfi[i] * factor * fi^2
end
end
return nothing
end
"""
squared_fourier_spectrum!(Afsq::Vector{U}, f::Vector{V}, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Real,V<:Float64}
Fourier acceleration spectrum (m/s) based upon an equivalent point source distance `r_ps`
- `Afsq` is the vector of squared fas amplitudes to be filled (m^2/s^2)
- `f` is `Vector` of frequencies (Hz)
- `m` is magnitude
- `r_ps` is the equivalent point source distance including saturation effects (km)
- `fas` are the Fourier spectral parameters `FourierParameters`
See also: [`squared_fourier_spectrum`](@ref), ['squared_fourier_spectral_ordinate'](@ref)
"""
function squared_fourier_spectrum!(Afsq::Vector{U}, f::Vector{V}, m::S, r_ps::T, fas::FourierParameters) where {S<:Real,T<:Real,U<:Real,V<:Float64}
numf = length(f)
numAfsq = length(Afsq)
numf == numAfsq || error("length of `f` and `Afsq` must be equal")
if numf == 0
Afsq = Vector{U}()
else
# define all frequency independent terms here
C = fourier_constant(fas)
# source amplitude and corner frequencies
Mo = magnitude_to_moment(m)
fa, fb, ε = corner_frequency(m, fas)
# geometric spreading
Gr = geometric_spreading(r_ps, m, fas)
# scale factor
factor = 4 * π * π * C * Mo * Gr / 100.0
# frequency dependent terms
# initialise the return vector with ones
for (i, fi) in pairs(f)
Afsq[i] = oneunit(U) * factor * fi * fi
end
# source term
Afsq .*= fourier_source_shape(f, fa, fb, ε, fas)
# combined attenuation
if fas.path.anelastic.rmetric == :Rrup
r_rup = rupture_distance_from_equivalent_point_source_distance(r_ps, m, fas)
# apply_fourier_attenuation!(Afsq, f, r_rup, fas)
apply_fourier_path_and_site_attenuation!(Afsq, f, r_rup, fas)
else
# apply_fourier_attenuation!(Afsq, f, r_ps, fas)
apply_fourier_path_and_site_attenuation!(Afsq, f, r_ps, fas)
end
# site impedance
apply_site_amplification!(Afsq, f, fas)
# square the computed FAS
Afsq .*= Afsq
end
return nothing
end
"""
combined_kappa_frequency(r::T, Af2target::Float64, ane::AnelasticAttenuationParameters, site::SiteParameters) where T<:Real
Frequency at which the combined κ_r and κ_0 filters (squared versions) give a value of `Af2target`.
`r` can be either `r_ps` or `r_rup` depending upon what matches `ane.rmetric`
"""
function combined_kappa_frequency(r::T, Af2target::Float64, ane::AnelasticAttenuationParameters, site::SiteParameters) where {T<:Real}
Q0_eff, η_eff, cQ_eff = effective_quality_parameters(r, ane)
if η_eff < 0.1
# a closed form solution exists (for effectively η=0)
return log(1.0 / Af2target) / (2π * (r / (Q0_eff * cQ_eff) + site.κ0))
else
g(f) = Af2target - (fourier_attenuation(f, r, ane, site)^2)
f_0 = find_zero(g, (0.01, 100.0), Bisection(); xatol=1e-2)
# fk = min(max(f_0, 0.2), 1.0)
fk = max(f_0, 0.1)
U = get_parametric_type(ane)
V = get_parametric_type(site)
if T <: Float64
if U <: Float64
unit = oneunit(V)
else
unit = oneunit(U)
end
else
unit = oneunit(T)
end
return fk * unit
end
end
combined_kappa_frequency(r::T, Af2target::Float64, path::PathParameters, site::SiteParameters) where {T<:Real} = combined_kappa_frequency(r, Af2target, path.anelastic, site)
combined_kappa_frequency(r::T, Af2target::Float64, fas::FourierParameters) where {T<:Real} = combined_kappa_frequency(r, Af2target, fas.path, fas.site)
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 20902 |
"""
geometric_spreading(r_ps::T, m::S, geo::GeometricSpreadingParameters, sat::NearSourceSaturationParameters) where {S<:Real, T<:Real}
Geometric spreading function, switches between different approaches on `path.geo_model`.
"""
function geometric_spreading(r_ps::T, m::S, geo::GeometricSpreadingParameters, sat::NearSourceSaturationParameters) where {S<:Real,T<:Real}
if geo.model == :Piecewise
return geometric_spreading_piecewise(r_ps, geo)
elseif geo.model == :CY14
return geometric_spreading_cy14(r_ps, geo)
elseif geo.model == :CY14mod
return geometric_spreading_cy14mod(r_ps, m, geo, sat)
else
return NaN * oneunit(get_parametric_type(geo))
end
end
geometric_spreading(r_ps::T, m::S, path::PathParameters) where {S<:Real,T<:Real} = geometric_spreading(r_ps, m, path.geometric, path.saturation)
geometric_spreading(r_ps::T, m::S, fas::FourierParameters) where {S<:Real,T<:Real} = geometric_spreading(r_ps, m, fas.path)
# special variants that don't require a magnitude input
geometric_spreading(r_ps::T, path::PathParameters) where {T<:Real} = geometric_spreading(r_ps, NaN, path.geometric, path.saturation)
geometric_spreading(r_ps::T, fas::FourierParameters) where {T<:Real} = geometric_spreading(r_ps, fas.path)
"""
geometric_spreading_piecewise(r_ps::W, geo::GeometricSpreadingParameters{S,T,U,V}) where {S<:Real, T<:Real, U<:Real, V<:AbstractVector{Bool}, W<:Real}
Piecewise linear (in log-log space) geometric spreading function.
Makes use of the reference distances `Rrefi` and spreading rates `γi` in `path`.
"""
function geometric_spreading_piecewise(r_ps::W, geo::GeometricSpreadingParameters{S,T,U,V}) where {S<:Real,T<:Real,U<:Real,V<:AbstractVector{Bool},W<:Real}
z_r = oneunit(get_parametric_type(geo))
j = 1
k = 1
for i = 1:length(geo.γfree)
@inbounds Rr0 = geo.Rrefi[i]
@inbounds Rr1 = geo.Rrefi[i+1]
γ_r = oneunit(get_parametric_type(geo))
if geo.γfree[i] == 0
@inbounds γ_r *= geo.γconi[j]
j += 1
else
@inbounds γ_r *= geo.γvari[k]
k += 1
end
if r_ps < Rr1
z_r *= (Rr0 / r_ps)^γ_r
return z_r
else
z_r *= (Rr0 / Rr1)^γ_r
end
end
return z_r
end
geometric_spreading_piecewise(r_ps, path::PathParameters) = geometric_spreading_piecewise(r_ps, path.geometric)
geometric_spreading_piecewise(r_ps, fas::FourierParameters) = geometric_spreading_piecewise(r_ps, fas.path)
"""
geometric_spreading_cy14(r_ps::W, geo::GeometricSpreadingParameters{S,T,U,V}) where {S<:Real, T<:Real, U<:Real, V<:AbstractVector{Bool}, W<:Real}
Geometric spreading function from Chiou & Youngs (2014).
Defines a smooth transition from one rate `γi[1]` to another `γi[2]`, with a spreading bandwidth of `Rrefi[2]` km.
"""
function geometric_spreading_cy14(r_ps::W, geo::GeometricSpreadingParameters{S,T,U,V}) where {S<:Real,T<:Real,U<:Real,V<:AbstractVector{Bool},W<:Real}
unit = oneunit(get_parametric_type(geo))
j = 1
k = 1
if geo.γfree[1] == 0
γ1 = geo.γconi[j] * unit
j += 1
else
γ1 = geo.γvari[k]
k += 1
end
if geo.γfree[2] == 0
γ2 = geo.γconi[j] * unit
else
γ2 = geo.γvari[k]
end
R0sq = (geo.Rrefi[1])^2
Rrsq = (geo.Rrefi[2])^2
ln_z_r = -γ1 * log(r_ps) + (-γ2 + γ1) / 2 * log((r_ps^2 + Rrsq) / (R0sq + Rrsq))
z_r = exp(ln_z_r)
return z_r
end
geometric_spreading_cy14(r_ps, path::PathParameters) = geometric_spreading_cy14(r_ps, path.geometric)
geometric_spreading_cy14(r_ps, fas::FourierParameters) = geometric_spreading_cy14(r_ps, fas.path)
"""
geometric_spreading_cy14mod(r_ps::W, m::X, geo::GeometricSpreadingParameters{S,T,U,V}, sat::NearSourceSaturationParameters) where {S<:Real, T<:Real, U<:Real, V<:AbstractVector{Bool}, W<:Real, X<:Real}
Geometric spreading function from Chiou & Youngs (2014).
Modified to make use of both `r_ps` and `r_rup` so that only the first saturation term contaminates the source amplitudes.
Defines a smooth transition from one rate `γi[1]` to another `γi[2]`, with a spreading bandwidth of `Rrefi[2]` km.
"""
function geometric_spreading_cy14mod(r_ps::W, m::X, geo::GeometricSpreadingParameters{S,T,U,V}, sat::NearSourceSaturationParameters) where {S<:Real,T<:Real,U<:Real,V<:AbstractVector{Bool},W<:Real,X<:Real}
unit = oneunit(get_parametric_type(geo))
j = 1
k = 1
if geo.γfree[1] == 0
γ1 = geo.γconi[j] * unit
j += 1
else
γ1 = geo.γvari[k]
k += 1
end
if geo.γfree[2] == 0
γ2 = geo.γconi[j] * unit
else
γ2 = geo.γvari[k]
end
R0sq = (geo.Rrefi[1])^2
Rrsq = (geo.Rrefi[2])^2
r_rup = rupture_distance_from_equivalent_point_source_distance(r_ps, m, sat)
ln_z_r = -γ1 * log(r_ps) + (-γ2 + γ1) / 2 * log((r_rup^2 + Rrsq) / (R0sq + Rrsq))
z_r = exp(ln_z_r)
return z_r
end
geometric_spreading_cy14mod(r_ps, m, path::PathParameters) = geometric_spreading_cy14mod(r_ps, m, path.geometric, path.saturation)
geometric_spreading_cy14mod(r_ps, m, fas::FourierParameters) = geometric_spreading_cy14mod(r_ps, m, fas.path)
"""
near_source_saturation(m, sat::NearSourceSaturationParameters)
Near-source saturation term. Used to create equivalent point-source distance.
Switches methods based upon `sat.model`.
# Arguments
Options for `sat.model` are:
- `:BT15` for Boore & Thompson (2015) finite fault factor
- `:YA15` for Yenier & Atkinson (2014) finite fault factor
- `:CY14` for a model fitted to the Chiou & Youngs (2014) saturation lengths (over all periods)
- `:SEA21` for the Stafford et al. (2021) saturation model obtained from inversion of Chiou & Youngs (2014)
- `:None` for zero saturation length
- `:ConstantConstrained` for a constant value, `sat.hconi[1]`, not subject to AD operations
- `:ConstantVariable` for a constant value, `sat.hvari[1]`, that is subject to AD operations
Any other symbol passed will return `NaN`.
See also: [`near_source_saturation`](@ref)
"""
function near_source_saturation(m, sat::NearSourceSaturationParameters)
unit = oneunit(get_parametric_type(sat))
if sat.model == :BT15
# use the Boore & Thompson (2015) finite fault factor
return finite_fault_factor_bt15(m) * unit
elseif sat.model == :YA15
# use the Yenier & Atkinson (2015) finite fault factor
return finite_fault_factor_ya15(m) * unit
elseif sat.model == :CY14
# use the fitted model averaging over Chiou & Youngs (2014)
return finite_fault_factor_cy14(m) * unit
elseif sat.model == :SEA21
# use the near-source saturation model of Stafford et al. (2021)'s inversion of CY14
return finite_fault_factor_sea21(m) * unit
elseif sat.model == :None
return zero(get_parametric_type(sat))
elseif sat.model == :ConstantConstrained
return sat.hconi[1] * unit
elseif sat.model == :ConstantVariable
return sat.hvari[1] * unit
else
return NaN * unit
end
end
"""
near_source_saturation(m, path::PathParameters)
Near-source saturation term taking a `PathParameters` struct.
See also: [`near_source_saturation`](@ref)
"""
near_source_saturation(m, path::PathParameters) = near_source_saturation(m, path.saturation)
"""
near_source_saturation(m, fas::FourierParameters)
Near-source saturation term taking a `FourierParameters` struct.
See also: [`near_source_saturation`](@ref)
"""
near_source_saturation(m, fas::FourierParameters) = near_source_saturation(m, fas.path)
"""
finite_fault_factor_bt15(m::T) where T<:Real
Finite fault factor from Boore & Thompson (2015) used to create equivalent point-source distance.
See also: [`near_source_saturation`](@ref), [`finite_fault_factor_ya15`](@ref), [`finite_fault_factor_cy14`](@ref), [`finite_fault_factor_sea21`](@ref)
"""
function finite_fault_factor_bt15(m::T) where {T<:Real}
Mt1 = 5.744
Mt2 = 7.744
if m <= Mt1
a1 = 0.7497
b1 = 0.4300
h = a1 + b1 * (m - Mt1)
elseif m >= Mt2
a2 = 1.4147
b2 = 0.2350
h = a2 + b2 * (m - Mt2)
else
c0 = 0.7497
c1 = 0.4300
c2 = -0.04875
c3 = 0.0
h = c0 + c1 * (m - Mt1) + c2 * (m - Mt1)^2 + c3 * (m - Mt1)^3
end
return 10.0^h
end
"""
finite_fault_factor_ya15(m::T) where T<:Real
Finite fault factor from Yenier & Atkinson (2015) used to create equivalent point-source distance.
See also: [`near_source_saturation`](@ref), [`finite_fault_factor_bt15`](@ref), [`finite_fault_factor_cy14`](@ref), [`finite_fault_factor_sea21`](@ref)
"""
function finite_fault_factor_ya15(m::T) where {T<:Real}
return 10.0^(-0.405 + 0.235 * m)
end
"""
finite_fault_factor_cy14(m::T) where T<:Real
Finite fault factor for Chiou & Youngs (2014) used to create equivalent point-source distance.
This is a model developed to match the average saturation length over the full period range.
See also: [`near_source_saturation`](@ref), [`finite_fault_factor_bt15`](@ref), [`finite_fault_factor_ya15`](@ref), [`finite_fault_factor_sea21`](@ref)
"""
function finite_fault_factor_cy14(m::T) where {T<:Real}
hα = 7.308
hβ = 0.4792
hγ = 3.556
return hα * cosh(hβ * max(m - hγ, 0.0))
end
"""
finite_fault_factor_sea21(m::T) where T<:Real
Finite fault factor for Stafford et al. (2021) used to create equivalent point-source distance.
See also: [`near_source_saturation`](@ref), [`finite_fault_factor_bt15`](@ref), [`finite_fault_factor_ya15`](@ref), [`finite_fault_factor_cy14`](@ref)
"""
function finite_fault_factor_sea21(m::T) where {T<:Real}
hα = -0.8712
hβ = 0.4451
hγ = 1.1513
hδ = 5.0948
hε = 7.2725
lnh = hα + hβ * m + ((hβ - hγ)/hδ) * log( 1.0 + exp(-hδ * (m - hε)) )
return exp(lnh)
end
"""
equivalent_point_source_distance(r, m, sat::NearSourceSaturationParameters)
Compute equivalent point source distance
- `r` is ``r_{hyp}`` or ``r_{rup}`` (depending upon the size of the event -- but is nominally ``r_{rup}``)
- `m` is magnitude
- `sat` contains the `NearSourceSaturationParameters`
See also: [`near_source_saturation`](@ref)
"""
function equivalent_point_source_distance(r, m, sat::NearSourceSaturationParameters)
h = near_source_saturation(m, sat)
n = sat.exponent
return (r^n + h^n)^(1 / n)
end
equivalent_point_source_distance(r, m, path::PathParameters) = equivalent_point_source_distance(r, m, path.saturation)
equivalent_point_source_distance(r, m, fas::FourierParameters) = equivalent_point_source_distance(r, m, fas.path)
"""
rupture_distance_from_equivalent_point_source_distance(r_ps, m, sat::NearSourceSaturationParameters)
Compute rupture distance from equivalent point source distance
- `r_ps` is the equivalent point source distance
- `m` is magnitude
- `sat` contains the `NearSourceSaturationParameters`
"""
function rupture_distance_from_equivalent_point_source_distance(r_ps, m, sat::NearSourceSaturationParameters)
h = near_source_saturation(m, sat)
n = sat.exponent
return (r_ps^n - h^n)^(1 / n)
end
rupture_distance_from_equivalent_point_source_distance(r_ps, m, path::PathParameters) = rupture_distance_from_equivalent_point_source_distance(r_ps, m, path.saturation)
rupture_distance_from_equivalent_point_source_distance(r_ps, m, fas::FourierParameters) = rupture_distance_from_equivalent_point_source_distance(r_ps, m, fas.path)
"""
anelastic_attenuation(f::S, r::T, anelastic::AnelasticAttenuationParameters) where {S<:Float64,T<:Real}
Anelastic attenuation filter, computed using equivalent point source distance metric or a standard rupture distance.
"""
function anelastic_attenuation(f::S, r::T, anelastic::AnelasticAttenuationParameters) where {S<:Float64,T<:Real}
PT = get_parametric_type(anelastic)
Qfilt = oneunit(PT)
jq = jη = 1
kq = kη = 1
nsegs = length(anelastic.Qfree)
@inbounds for i = 1:nsegs
Rr0 = anelastic.Rrefi[i]
Rr1 = anelastic.Rrefi[i+1]
cQ_r = anelastic.cQ[i]
# get the relevant constrained or free quality factor for this path segment
if anelastic.Qfree[i] == 0
Q0_r = anelastic.Q0coni[jq]
jq += 1
else
Q0_r = anelastic.Q0vari[kq]
kq += 1
end
# get the relevant constrained of free quality exponent for this path segment
if anelastic.ηfree[i] == 0
η_r = anelastic.ηconi[jη]
jη += 1
else
η_r = anelastic.ηvari[kη]
kη += 1
end
if nsegs == 1
fpow = f^(1.0 - η_r)
else
# this avoids f^(1-η)
fpow = exp((1.0 - η_r) * log(f))
end
if r < Rr1
Qfilt *= exp(-π * fpow * (r - Rr0) / (Q0_r * cQ_r))
return Qfilt
else
Qfilt *= exp(-π * fpow * (Rr1 - Rr0) / (Q0_r * cQ_r))
end
end
end
anelastic_attenuation(f, r, path::PathParameters) = anelastic_attenuation(f, r, path.anelastic)
anelastic_attenuation(f, r, fas::FourierParameters) = anelastic_attenuation(f, r, fas.path)
"""
anelastic_attenuation(f::Vector{S}, r::T, anelastic::AnelasticAttenuationParameters) where {S<:Float64,T<:Real}
Anelastic attenuation filter, computed using equivalent point source distance metric or a standard rupture distance.
"""
function anelastic_attenuation(f::Vector{S}, r::T, anelastic::AnelasticAttenuationParameters) where {S<:Float64,T<:Real}
PT = promote_type(get_parametric_type(anelastic), T)
nf = length(f)
Qfilt = ones(PT, nf)
jq = jη = 1
kq = kη = 1
nsegs = length(anelastic.Qfree)
@inbounds for i = 1:nsegs
Rr0 = anelastic.Rrefi[i]
Rr1 = anelastic.Rrefi[i+1]
cQ_r = anelastic.cQ[i]
# get the relevant constrained or free quality factor for this path segment
if anelastic.Qfree[i] == 0
Q0_r = anelastic.Q0coni[jq]
jq += 1
else
Q0_r = anelastic.Q0vari[kq]
kq += 1
end
# get the relevant constrained of free quality exponent for this path segment
if anelastic.ηfree[i] == 0
η_r = anelastic.ηconi[jη]
jη += 1
else
η_r = anelastic.ηvari[kη]
kη += 1
end
if nsegs == 1
fpow = f .^ (1.0 - η_r)
else
# this avoids f^(1-η)
fpow = @. exp((1.0 - η_r) * log(f))
end
if r < Rr1
for i in 1:nf
Qfilt[i] *= exp(-π * fpow[i] * (r - Rr0) / (Q0_r * cQ_r))
end
return Qfilt
else
for i in 1:nf
Qfilt[i] *= exp(-π * fpow[i] * (Rr1 - Rr0) / (Q0_r * cQ_r))
end
end
end
end
"""
anelastic_attenuation!(Qfilt::Vector{U}, f::Vector{S}, r::T, anelastic::AnelasticAttenuationParameters) where {S<:Float64,T<:Real,U<:Real}
Anelastic attenuation filter, computed using equivalent point source distance metric or a standard rupture distance.
"""
function anelastic_attenuation!(Qfilt::Vector{U}, f::Vector{S}, r::T, anelastic::AnelasticAttenuationParameters) where {S<:Float64,T<:Real,U<:Real}
length(Qfilt) == length(f) || error("length of frequency vector must match the filter vector length")
jq = jη = 1
kq = kη = 1
nsegs = length(anelastic.Qfree)
for i = 1:nsegs
@inbounds Rr0 = anelastic.Rrefi[i]
@inbounds Rr1 = anelastic.Rrefi[i+1]
@inbounds cQ_r = anelastic.cQ[i]
# get the relevant constrained or free quality factor for this path segment
if anelastic.Qfree[i] == 0
@inbounds Q0_r = anelastic.Q0coni[jq]
jq += 1
else
@inbounds Q0_r = anelastic.Q0vari[kq]
kq += 1
end
# get the relevant constrained of free quality exponent for this path segment
if anelastic.ηfree[i] == 0
@inbounds η_r = anelastic.ηconi[jη]
jη += 1
else
@inbounds η_r = anelastic.ηvari[kη]
kη += 1
end
if nsegs == 1
fpow = @. f^(1.0 - η_r)
else
# this avoids f^(1-η)
fpow = @. exp((1.0 - η_r) * log(f))
end
if r < Rr1
if i == 1
Qfilt .= @. exp(-π * fpow * (r - Rr0) / (Q0_r * cQ_r))
else
Qfilt .*= @. exp(-π * fpow * (r - Rr0) / (Q0_r * cQ_r))
end
return Qfilt
else
if i == 1
Qfilt .= @. exp(-π * fpow * (Rr1 - Rr0) / (Q0_r * cQ_r))
else
Qfilt .*= @. exp(-π * fpow * (Rr1 - Rr0) / (Q0_r * cQ_r))
end
end
end
end
"""
apply_anelastic_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, anelastic::AnelasticAttenuationParameters) where {T<:Real,U<:Real,V<:Real}
Apply an anelastic attenuation filter to a FAS, computed using equivalent point source distance metric or a standard rupture distance.
"""
function apply_anelastic_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, anelastic::AnelasticAttenuationParameters) where {T<:Real,U<:Real,V<:Real}
numAf = length(Af)
numf = length(f)
numAf == numf || error("length of vector `f` must match the length of vector `Af`")
jq = jη = 1
kq = kη = 1
nsegs = length(anelastic.Qfree)
exp_arg = zeros(T, numf)
for i = 1:nsegs
@inbounds Rr0 = anelastic.Rrefi[i]
@inbounds Rr1 = anelastic.Rrefi[i+1]
@inbounds cQ_r = anelastic.cQ[i]
# get the relevant constrained or free quality factor for this path segment
@inbounds if anelastic.Qfree[i] == 0
@inbounds Q0_r = anelastic.Q0coni[jq]
jq += 1
else
@inbounds Q0_r = anelastic.Q0vari[kq]
kq += 1
end
# get the relevant constrained of free quality exponent for this path segment
@inbounds if anelastic.ηfree[i] == 0
@inbounds η_r = anelastic.ηconi[jη]
jη += 1
else
@inbounds η_r = anelastic.ηvari[kη]
kη += 1
end
if η_r ≈ 0.0
fpow = f
else
if nsegs == 1
fpow = @. f^(1.0 - η_r)
else
# this avoids f^(1-η)
fpow = @. exp((1.0 - η_r) * log(f))
end
end
if r < Rr1
rlim = r
else
rlim = Rr1
end
for (j, fp) in pairs(fpow)
@inbounds exp_arg[j] += -π * fp * (rlim - Rr0) / (Q0_r * cQ_r)
end
# for (j, fp) in pairs(fpow)
# @inbounds Af[j] *= exp(-π * fp * (rlim - Rr0) / (Q0_r * cQ_r))
# end
end
for (i, ea) in pairs(exp_arg)
@inbounds Af[i] *= exp(ea)
end
return nothing
end
apply_anelastic_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, path::PathParameters) where {T<:Real,U<:Real,V<:Real} = apply_anelastic_attenuation!(Af, f, r, path.anelastic)
apply_anelastic_attenuation!(Af::Vector{T}, f::Vector{U}, r::V, fas::FourierParameters) where {T<:Real,U<:Real,V<:Real} = apply_anelastic_attenuation!(Af, f, r, fas.path)
"""
effective_quality_parameters(r::T, anelastic::AnelasticAttenuationParameters) where {T<:Real}
Distance weighted quality parameters for segmented model.
Returns a tuple of effective Q0, η & cQ values from a weighted sum, weighted by relative distance in each path segment.
"""
function effective_quality_parameters(r::T, anelastic::AnelasticAttenuationParameters) where {T<:Real}
PT = get_parametric_type(anelastic)
Q_eff = zero(PT)
η_eff = zero(PT)
cQ_eff = zero(PT)
jq = jη = 1
kq = kη = 1
for i = 1:length(anelastic.Qfree)
@inbounds Rr0 = anelastic.Rrefi[i]
@inbounds Rr1 = anelastic.Rrefi[i+1]
Q0_r = oneunit(PT)
η_r = oneunit(PT)
cQ_r = anelastic.cQ[i]
# get the relevant constrained or free quality factor for this path segment
if anelastic.Qfree[i] == 0
@inbounds Q0_r *= anelastic.Q0coni[jq]
jq += 1
else
@inbounds Q0_r *= anelastic.Q0vari[kq]
kq += 1
end
# get the relevant constrained of free quality exponent for this path segment
if anelastic.ηfree[i] == 0
@inbounds η_r *= anelastic.ηconi[jη]
jη += 1
else
@inbounds η_r *= anelastic.ηvari[kη]
kη += 1
end
if r < Rr1
rfrac = (r - Rr0) / r
Q_eff += rfrac * Q0_r
η_eff += rfrac * η_r
cQ_eff += rfrac * cQ_r
return (Q_eff, η_eff, cQ_eff)
else
rfrac = (Rr1 - Rr0) / r
Q_eff += rfrac * Q0_r
η_eff += rfrac * η_r
cQ_eff += rfrac * cQ_r
end
end
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 4753 |
"""
site_amplification(f::T, amp_model::S; fmin=1e-3, fmax=999.99) where {T<:Real,S<:SiteAmplification}
Computes the site amplification (impedance) for a given frequency `f`. The argument `amp_model` is a subtype of the abstract type `SiteAmplification`.
# Examples
```julia-repl
f = 5.0
# returns the amplification from AlAtik (2021) in both cases
Af = site_amplification(f)
Af = site_amplification(f, SiteAmpAlAtikAbrahamson2021_cy14_760())
# returns the Boore (2016) amplification
Af = site_amplification(f, SiteAmpBoore2016_760())
# returns 1.0
Af = site_amplification(f, SiteAmpUnit())
```
"""
function site_amplification(f::T, amp_model::S; fmin=1e-3, fmax=999.99) where {T<:Real,S<:SiteAmplification}
if f < fmin
f = fmin
elseif f > fmax
f = fmax
end
return amp_model.amplification(f)::T
end
"""
site_amplification(f::Vector{T}, amp_model::S; fmin=1e-3, fmax=999.99) where {T<:Real,S<:SiteAmplification}
Computes the site amplification (impedance) for a given frequency `f`. The argument `amp_model` is a subtype of the abstract type `SiteAmplification`.
# Examples
```julia-repl
f = 5.0
# returns the amplification from AlAtik (2021) in both cases
Af = site_amplification(f)
Af = site_amplification(f, SiteAmpAlAtikAbrahamson2021_cy14_760())
# returns the Boore (2016) amplification
Af = site_amplification(f, SiteAmpBoore2016_760())
# returns 1.0
Af = site_amplification(f, SiteAmpUnit())
```
"""
function site_amplification(f::Vector{T}, amp_model::S; fmin=1e-3, fmax=999.99) where {T<:Real,S<:SiteAmplification}
clamp!(f, fmin, fmax)
return amp_model.amplification.(f)::Vector{T}
end
"""
apply_site_amplification!(Af::Vector{T}, f::Vector{U}, amp_model::S; fmin=1e-3, fmax=999.99) where {T<:Real,U<:Real,S<:SiteAmplification}
Apply site impedance effects to an existing FAS `Af` for a vector of frequencies `f`.
"""
function apply_site_amplification!(Af::Vector{T}, f::Vector{U}, amp_model::S; fmin=1e-3, fmax=999.99) where {T<:Real,U<:Real,S<:SiteAmplification}
numAf = length(Af)
numf = length(f)
numAf == numf || error("length of `f` must match length of `Af`")
clamp!(f, fmin, fmax)
Af .*= amp_model.amplification.(f)
return nothing
end
apply_site_amplification!(Af::Vector{T}, f::Vector{U}, site::SiteParameters; fmin=1e-3, fmax=999.99) where {T<:Real,U<:Real} = apply_site_amplification!(Af, f, site.model, fmin=fmin, fmax=fmax)
apply_site_amplification!(Af::Vector{T}, f::Vector{U}, fas::FourierParameters; fmin=1e-3, fmax=999.99) where {T<:Real,U<:Real} = apply_site_amplification!(Af, f, fas.site, fmin=fmin, fmax=fmax)
"""
site_amplification(f, site::SiteParameters)
Computes the site amplification (impedance) for a given frequency `f`.
"""
site_amplification(f, site::SiteParameters) = site_amplification(f, site.model)
"""
site_amplification(f, fas::FourierParameters)
Computes the site amplification (impedance) for a given frequency `f`.
"""
site_amplification(f, fas::FourierParameters) = site_amplification(f, fas.site)
"""
kappa_filter(f, site::SiteParameters)
Kappa filter for a given frequency `f`
"""
function kappa_filter(f, site::SiteParameters)
if isnan(site.κ0)
# Eq. 20 of Haendel et al. (2020) (frequency dependent kappa)
# specified for a reference frequency of f0=1 Hz
return exp(-π * site.ζ0 * (1.0 - site.η) * f^(1.0 - site.η))
else
return exp(-π * f * site.κ0)
end
end
"""
kappa_filter(f::Vector{T}, site::SiteParameters) where {T<:Real}
Kappa filter for a given frequency vector `f`
"""
function kappa_filter(f::Vector{T}, site::SiteParameters) where {T<:Real}
if isnan(site.κ0)
# Eq. 20 of Haendel et al. (2020) (frequency dependent kappa)
# specified for a reference frequency of f0=1 Hz
return @. exp(-π * site.ζ0 * (1.0 - site.η) * exp((1.0 - site.η) * log(f)))
else
return @. exp(-π * f * site.κ0)
end
end
"""
apply_kappa_filter!(Af::Vector{T}, f::Vector{U}, site::SiteParameters) where {T<:Real,U<:Real}
Apply a kappa filter to a FAS `Af` for a given frequency vector `f`
"""
function apply_kappa_filter!(Af::Vector{T}, f::Vector{U}, site::SiteParameters) where {T<:Real,U<:Real}
numAf = length(Af)
numf = length(f)
numAf == numf || error("length of `f` must match `Af`")
if isnan(site.κ0)
# Eq. 20 of Haendel et al. (2020) (frequency dependent kappa)
# specified for a reference frequency of f0=1 Hz
for i in 1:numf
Af[i] *= exp(-π * site.ζ0 * (1.0 - site.η) * exp((1.0 - site.η) * log(f[i])))
end
else
for i in 1:numf
Af[i] *= exp(-π * f[i] * site.κ0)
end
end
return nothing
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 139455 |
"""
abstract type SiteAmplification
Abstract type to allow dispatch for the `amplification` functions for different site profiles
"""
abstract type SiteAmplification end
"""
construct_interpolant(fi::T, Ai::T) where {T<:SVector}
Construct a fast interpolant from `StaticArrays` defining the frequencies and amplifications with arbitrary spacing.
Returns a function that takes a frequency input and returns the amplification.
Interpolant is defined to work over the frequency range [0.001, 1000.0) Hz
"""
function construct_interpolant(fi::T, Ai::T) where {T<:SVector}
f_min = 0.001
f_max = 1000.0
num_lnf = 1001
lnf_min = log(f_min)
# define initial linear interpolation once using the above irregular grid and extrapolation
itp = linear_interpolation(fi, Ai, extrapolation_bc=Flat())
# compute the amp function values at the regular (log-spaced) frequencies
lnfi = range(lnf_min, stop=log(f_max), length=num_lnf)
fi_reg = exp.(lnfi)
Δlnf_reg = lnfi[2] - lnfi[1]
Ai_reg = itp.(fi_reg)
# define a new interpolant that is highly efficient and works on the regular-spaced grid
itp_reg = interpolate(Ai_reg, BSpline(Linear()))
# return the interpolation function on the regular grid, that takes a scaled logarithmic frequency input
interpolant = function(f)
Tf = typeof(f)
return itp_reg((log(f) - lnf_min) / Δlnf_reg + 1.0)::Tf
end
return interpolant
# return (f) -> itp_reg((log(f) - lnf_min) / Δlnf_reg + 1.0)
end
"""
struct SiteAmpUnit <: SiteAmplification
Unit amplification function.
"""
struct SiteAmpUnit <: SiteAmplification
amplification::Function
function SiteAmpUnit()
new((f) -> oneunit(typeof(f)))
end
end
"""
struct SiteAmpConstant <: SiteAmplification
Constant amplification function
"""
struct SiteAmpConstant <: SiteAmplification
constant::Real
amplification::Function
function SiteAmpConstant(constant::T) where {T<:Real}
new(constant, (f) -> constant * oneunit(typeof(f)))
end
end
"""
struct SiteAmpBoore2016_760 <: SiteAmplification
Implementation of the Boore (2016) amplification function for Vs30 = 760 m/s
# Examples
```julia-repl
f = 5.0
sa = SiteAmpBoore2016_760()
Af = sa.amplification(f)
```
"""
struct SiteAmpBoore2016_760 <: SiteAmplification
amplification::Function
function SiteAmpBoore2016_760()
fi = @SVector [0.001, 0.010, 0.015, 0.021, 0.031, 0.045, 0.065, 0.095, 0.138, 0.200, 0.291, 0.423, 0.615, 0.894, 1.301, 1.892, 2.751, 4.000, 5.817, 8.459, 12.301, 17.889, 26.014, 37.830, 55.012, 80.000, 1e3]
Ai = @SVector [1.00, 1.00, 1.01, 1.02, 1.02, 1.04, 1.06, 1.09, 1.13, 1.18, 1.25, 1.32, 1.41, 1.51, 1.64, 1.80, 1.99, 2.18, 2.38, 2.56, 2.75, 2.95, 3.17, 3.42, 3.68, 3.96, 3.96]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_ask14_620 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Abrahamson _et al._ (2014) GMM, for Vs30 = 620 m/s
# Examples
```julia-repl
f = 5.0
sa = SiteAmpAlAtikAbrahamson2021_ask14_620()
Af = sa.amplification(f)
```
"""
struct SiteAmpAlAtikAbrahamson2021_ask14_620 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_ask14_620()
fi = @SVector [0.001, 0.100000007176552, 0.102329297485949, 0.104712901552804, 0.107151924117949, 0.109647824895946, 0.112201838507376, 0.114815405225881, 0.117489810861085, 0.1202264325802, 0.123026894039802, 0.12589255240632, 0.128824937117037, 0.131825709632546, 0.134896310600769, 0.138038400222065, 0.141253728327524, 0.144543992885956, 0.147910847244603, 0.151356116586059, 0.154881690648375, 0.158489312312177, 0.162181015370784, 0.16595871040885, 0.169824400428869, 0.173780103299513, 0.177828027447085, 0.181970116933159, 0.186208693439478, 0.19054610704757, 0.194984446661483, 0.199526230171352, 0.204173816020742, 0.208929612284355, 0.213796203551149, 0.218776177399838, 0.223872101209225, 0.229086813628305, 0.234422912331458, 0.239883270624677, 0.245470912442472, 0.251188578932815, 0.257039572485661, 0.26302683611382, 0.269153491176368, 0.275422860904314, 0.281838254809002, 0.288403100119285, 0.295120975682464, 0.301995149403153, 0.309029540026393, 0.316227757343325, 0.32359371997251, 0.331131183335223, 0.338844155010958, 0.346736907560462, 0.354813428224786, 0.36307811068037, 0.371535201243506, 0.380189408253386, 0.389045048821185, 0.398107252613262, 0.407380348956526, 0.416869343532483, 0.426579617417572, 0.436515672690002, 0.446683568718976, 0.457088323168438, 0.46773496922304, 0.478630314385223, 0.489778634661086, 0.501187255130982, 0.512861174281571, 0.524807531745957, 0.537031651679684, 0.549540848799636, 0.562341293577962, 0.575440237707926, 0.588843920258061, 0.602559902463521, 0.616594560798692, 0.630957710395976, 0.645654500162755, 0.660693848816064, 0.676082985461142, 0.691831301966495, 0.707945920028427, 0.724435954327771, 0.741310203831773, 0.758578319149634, 0.776247687487606, 0.794327531427445, 0.812831173158537, 0.831763755397804, 0.851137596165377, 0.87096361786093, 0.891250634906882, 0.912011758905137, 0.933255273423412, 0.954993810779107, 0.97723694421474, 0.999999633853153, 1.02329446506163, 1.04713043607716, 1.07151861129162, 1.09647640754566, 1.12201876367331, 1.14815236598752, 1.17489778192726, 1.20226469308904, 1.23026864708192, 1.25892719937347, 1.28824883491205, 1.31825422392517, 1.3489604744997, 1.38038656412012, 1.41253927391579, 1.44543987371868, 1.47911238259783, 1.51355825072426, 1.54881301667269, 1.5848905633235, 1.62181335008947, 1.65958238778041, 1.69824558697017, 1.73779898879862, 1.77828608776837, 1.8197035816424, 1.86208766520357, 1.90546503948543, 1.94984960247986, 1.99525559982877, 2.04173404813673, 2.08928745324258, 2.13795640238707, 2.18776989034643, 2.23872242386584, 2.29087401375753, 2.34423462055453, 2.39884036376148, 2.45470413173396, 2.51189897015488, 2.57038387151322, 2.63027372689445, 2.69152817520359, 2.75424481862134, 2.81838055555125, 2.88404782351028, 2.95120276858626, 3.01997665364079, 3.09027755270178, 3.16230509000893, 3.23591072890429, 3.3113196772554, 3.38845209360351, 3.46738703485683, 3.54810342861765, 3.6307572259458, 3.71538006523731, 3.80192328047219, 3.89049469017383, 3.98103970987384, 4.07377433470771, 4.16865402930154, 4.2658313673159, 4.36514888139538, 4.46688390379777, 4.57086791742096, 4.67741779690484, 4.78635650780478, 4.89775486557788, 5.0118487428658, 5.12859210973947, 5.24809233553927, 5.37040163878342, 5.49543147519744, 5.62335167756751, 5.75435700895086, 5.88845342866043, 6.02563531956834, 6.16588674725113, 6.30967936692519, 6.45651776048592, 6.60689624674967, 6.76082112782712, 6.91828688137004, 7.07959143533954, 7.24441582209855, 7.41306014051683, 7.58587311664298, 7.76249492667347, 7.94328044747604, 8.12822348094524, 8.31774103516475, 8.51139783908034, 8.70962052040683, 8.91240272293129, 9.12024982306876, 9.33264060910502, 9.55009706721427, 9.77261961256125, 10.0001910578874, 10.2327752801061, 10.4710140255772, 10.7149240936345, 10.9645054455084, 11.2205435989428, 11.4814213469585, 11.7487266632786, 12.0224913181046, 12.3027285474753, 12.5894301931157, 12.8825650343572, 13.1820751213882, 13.4902184788619, 13.8035252713909, 14.125541280801, 14.4537496705297, 14.7907638870534, 15.1352457785712, 15.4886663451631, 15.8495022769038, 16.2176073176065, 16.5963627451878, 16.9822974547711, 17.3771048059986, 17.7827957753744, 18.1974302837793, 18.6209015547347, 19.0554232691428, 19.4986547279176, 19.9529560695692, 20.4184012173967, 20.8921832484195, 21.3798822495437, 21.8787484054886, 22.3887129884931, 22.909659227327, 23.4414188072464, 23.9875410094608, 24.4615137952709, 25.0329093218529, 25.6148235017154, 26.2158518759445, 26.8272698465536, 27.4534661797527, 28.09446691795, 28.7502506564272, 29.4207416293659, 30.1117961312001, 30.811505268715, 31.5318949237336, 32.2666451061469, 33.0225752670797, 33.7926308086556, 34.5841820564937, 35.3893524130691, 36.216097853598, 37.0647605768429, 37.9260703333401, 38.8089621672073, 39.7241178868006, 40.6510900911763, 41.599966407565, 42.5707143949687, 43.5632194319038, 44.5772785797191, 45.6125872923706, 46.6833395460697, 47.7757780217904, 48.8893240325792, 50.0400743989436, 51.1942947913361, 52.4039387563387, 53.614957723063, 54.8639426278079, 56.152230540486, 57.4589003466977, 58.8055074891377, 60.168839494608, 61.5723166498931, 63.0170569484297, 64.5041794807385, 66.0052452133238, 67.5480638430476, 69.1334956085096, 70.7283580177624, 72.3998158815981, 74.0787547857259, 75.7996039156837, 77.5626562679972, 79.3680950075974, 81.2610319483109, 83.153414381699, 85.0880264319602, 87.0644638111256, 89.0821208913822, 91.1971203357681, 93.2971759818561, 95.4979057213378, 97.7410868864205, 100.025195173882, 1e3]
Ai = @SVector [1.0, 1.27131849966856, 1.27364786217161, 1.27603634853953, 1.27848592867056, 1.28099895478186, 1.28357786099471, 1.28622520519563, 1.2889434388998, 1.29173520188997, 1.29460344588835, 1.2975509498314, 1.30058076546606, 1.3036961769696, 1.30690034122135, 1.31019676038717, 1.31358915842919, 1.31708133239743, 1.3206771759199, 1.32438092055858, 1.32819702647961, 1.33212991697744, 1.33618459681898, 1.34036614557702, 1.34467994891009, 1.34913162943125, 1.353727283232, 1.35847298456236, 1.363375527856, 1.36844207057665, 1.37367981612773, 1.3790968414493, 1.3847014608445, 1.39050247305961, 1.39650939948657, 1.40273226553584, 1.40918165695063, 1.41586914366152, 1.42280665323052, 1.43000721599896, 1.43748488902678, 1.44525416858638, 1.45333038870041, 1.46172679282892, 1.47045481180741, 1.47952423032643, 1.48894310672955, 1.49871805295238, 1.50885449107557, 1.51935602406904, 1.5302260715545, 1.54146650237406, 1.55307876107356, 1.56506319254866, 1.57741983233271, 1.5901485779998, 1.60324838288661, 1.61671852084641, 1.63055775591691, 1.64476547137603, 1.65934039368577, 1.67428237920358, 1.68958701478223, 1.70524054060058, 1.72121790294409, 1.73748150584534, 1.75398619883415, 1.77067606186742, 1.78748731066872, 1.80435348984646, 1.82120683669339, 1.83799488215409, 1.85467197895587, 1.87120483603363, 1.88756584928089, 1.90373730740876, 1.91970625040889, 1.93546650295583, 1.9510152593158, 1.96635530570864, 1.98149114618527, 1.99643229005328, 2.01118329485831, 2.02575247931318, 2.04014641122666, 2.05437358672245, 2.06844032117375, 2.08235468419301, 2.09612436216508, 2.10975761252428, 2.12326084225104, 2.13664192539445, 2.14991154487293, 2.16307443060873, 2.17614033344739, 2.18911787206594, 2.20201423012552, 2.21483920620629, 2.22759955370566, 2.24030456464251, 2.25296154148033, 2.26557971725804, 2.27816467473245, 2.29071788271264, 2.3032400469491, 2.31572599647585, 2.32815556505631, 2.34054940209122, 2.35290715713082, 2.36522238277542, 2.37749051831689, 2.38970715274537, 2.4018633734267, 2.41395490786702, 2.42597554460696, 2.43791940595674, 2.4497757462845, 2.4615391505608, 2.47320480678957, 2.4847601322214, 2.49620408246273, 2.50752668443819, 2.51871060672102, 2.5297596074038, 2.54067584282881, 2.55144664044525, 2.56207261663909, 2.57254204204221, 2.58285360931613, 2.59300361000181, 2.60298551195721, 2.61279323256054, 2.6224286470533, 2.63188354354167, 2.64115762996102, 2.65024527504853, 2.65912810778427, 2.66782060123297, 2.67631755269486, 2.68461815999178, 2.69271817986727, 2.70062213382974, 2.70831871725709, 2.71581770156889, 2.72310883251496, 2.73019894373201, 2.73707865846449, 2.74375568118252, 2.75022140641828, 2.75648433771688, 2.76253232665129, 2.76837869241064, 2.77400770979689, 2.77943316921774, 2.7846347466576, 2.78961027235924, 2.79437303506795, 2.79892953960913, 2.80327862430555, 2.80741548398516, 2.81134322510281, 2.81505764409859, 2.81856591128218, 2.82186444735045, 2.82495695789317, 2.82783721427689, 2.83051212126031, 2.83297633132674, 2.83523639953662, 2.8372877156902, 2.83913143401513, 2.84077094014203, 2.84220512105643, 2.84338239396761, 2.84453752539754, 2.84569170133826, 2.84684594137068, 2.84800140850567, 2.84915737319923, 2.85031344233642, 2.85146887884798, 2.85262696721866, 2.85378303053006, 2.85494041625843, 2.85609851104183, 2.85725669775932, 2.85841651300168, 2.85957503865203, 2.86073384714995, 2.86189466638097, 2.86305449974859, 2.86421506638288, 2.86537569117408, 2.86653838525032, 2.86769978356148, 2.86886195554912, 2.87002416833799, 2.87118870499014, 2.87235206291314, 2.87351642567287, 2.87468120313107, 2.87584574300883, 2.87700920982724, 2.87817424036366, 2.87934030037972, 2.880506679293, 2.88167640401134, 2.88284155564091, 2.88400866295102, 2.88517716959085, 2.88634646120449, 2.88751592098892, 2.88868480884237, 2.88985237467466, 2.89102661665717, 2.89219376110607, 2.89336648561349, 2.89453497549384, 2.895707904823, 2.89687997662864, 2.89805545284443, 2.89922873972961, 2.90039879683353, 2.90157572463167, 2.90274806501943, 2.90392049668863, 2.90509824676344, 2.90627496465686, 2.90744978512103, 2.90862824445576, 2.90980342588609, 2.91098091930798, 2.91216025898202, 2.91333379520812, 2.91451474592521, 2.91569566571787, 2.91687578300107, 2.91805431552053, 2.91923034618551, 2.92041104624385, 2.92141282611799, 2.92259748894795, 2.92377684076637, 2.92496752931683, 2.92615159941094, 2.92733703087574, 2.92852325524016, 2.92970958073521, 2.93089524852177, 2.93208979416362, 2.93327213905911, 2.93446206595989, 2.93564847728727, 2.93684161114483, 2.93802978805933, 2.93922366236317, 2.94041080702049, 2.94160236434546, 2.94279806654809, 2.94398427376105, 2.94517293468467, 2.94637732449283, 2.94756988100288, 2.94876318656724, 2.94995654384797, 2.95114925098669, 2.95234047346702, 2.95352936452941, 2.9547313446324, 2.9559301177744, 2.95712457557147, 2.95833123099914, 2.95951433263599, 2.96072642625698, 2.96191259644968, 2.96310852156839, 2.96431434309621, 2.96550991642039, 2.96671434950427, 2.96790632397305, 2.96910584323222, 2.97031288839944, 2.97152742012084, 2.9727258335987, 2.97392991530171, 2.97513951470086, 2.97632893885952, 2.97754748893125, 2.97874405828706, 2.97994290437603, 2.98114356152975, 2.98234550965926, 2.98357737374197, 2.98478124669835, 2.98598439797552, 2.98718591838467, 2.98838495124345, 2.98961366346154, 2.99080627211428, 2.9920279941566, 2.99324532515824, 2.99445681071514, 2.99445681071514]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_ask14_760 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Abrahamson _et al._ (2014) GMM, for Vs30 = 760 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_ask14_760 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_ask14_760()
fi = @SVector [0.001, 0.102329291629789, 0.104712890010164, 0.107151914957207, 0.109647813102497, 0.112201836659156, 0.114815393694835, 0.117489795185623, 0.120226421637391, 0.123026889157653, 0.125892536389367, 0.128824935296206, 0.13182570291595, 0.134896294354494, 0.138038411921428, 0.141253715584794, 0.144543993245758, 0.147910831725714, 0.151356107872253, 0.154881694399225, 0.158489303339742, 0.162180978112495, 0.165958692627976, 0.169824387200124, 0.173780087479412, 0.177827987159618, 0.181970098272324, 0.186208709701579, 0.1905460700907, 0.194984407472064, 0.199526184904639, 0.204173763555912, 0.208929612563225, 0.213796165486253, 0.218776181039101, 0.223872120331069, 0.229086778100748, 0.234422848322377, 0.239883277899045, 0.245470899315408, 0.251188601619759, 0.257039480147694, 0.263026791244529, 0.269153392326978, 0.275422840939865, 0.281838278374961, 0.288403066962298, 0.295120927437312, 0.301995171485957, 0.309029453737916, 0.316227724229087, 0.323593559416164, 0.331131050939781, 0.338844123996532, 0.346736740907403, 0.354813422978372, 0.363078118172697, 0.37153517036869, 0.380189278371953, 0.389045079100575, 0.398107032945674, 0.407380141046479, 0.416869301624597, 0.426579390461964, 0.436515671631233, 0.446683430400802, 0.457088039005123, 0.46773511556702, 0.478629897807854, 0.489778872693707, 0.50118719863843, 0.512861176181064, 0.524807303576546, 0.537031671638095, 0.549540677985814, 0.562341420837777, 0.575439915771869, 0.588843687408805, 0.602559095335443, 0.616594498178253, 0.630956838282629, 0.645654416042027, 0.660693435579826, 0.676082666603497, 0.691830720734741, 0.707945795957969, 0.72443532781887, 0.741309624084325, 0.758577203919982, 0.77624745769222, 0.794328291514734, 0.812830676987017, 0.831763916668987, 0.851137859274074, 0.870962885444047, 0.891249875528529, 0.912010167053346, 0.933253679988854, 0.954992166274483, 0.977237551755246, 0.999999168813753, 1.0232925177164, 1.04712953459331, 1.07151857211678, 1.09647732276226, 1.12201805278287, 1.14815183764178, 1.17489782100591, 1.20226477971155, 1.23026962056445, 1.25892432815131, 1.28825074454752, 1.31825825555489, 1.34896263627262, 1.38038268450569, 1.41253552190051, 1.44544086549261, 1.47910458530454, 1.51356159519225, 1.54881530453188, 1.58489389973832, 1.62180870243341, 1.65958562234269, 1.69824588904663, 1.73779618369895, 1.77827624579108, 1.8196950734287, 1.86208930506452, 1.90545964702916, 1.94984645250691, 1.99526156164151, 2.04173991259483, 2.08929510892326, 2.137953540857, 2.18775791681998, 2.23871166806337, 2.29086258407858, 2.3442317459986, 2.39882309610215, 2.45471229794924, 2.51188920081331, 2.57039958766811, 2.63027351343954, 2.69154338255738, 2.7542199774598, 2.8183904204513, 2.88401933081082, 2.95120421062146, 3.01993722938914, 3.0903013725065, 3.1622906167405, 3.23592899478649, 3.31131792994546, 3.38845538724139, 3.46737641623156, 3.54811898133175, 3.63077222275196, 3.7153395206109, 3.80187246745282, 3.89042877823982, 3.98107343300018, 4.0738177070868, 4.16866925869073, 4.26577105198063, 4.36514527469599, 4.46681233698773, 4.57087241800643, 4.67735553529616, 4.7862938382588, 4.89782051909636, 5.01186817841011, 5.12857475720548, 5.24810170023344, 5.37028292809851, 5.49540706428733, 5.6234241270191, 5.75440312419696, 5.8884201663215, 6.02555999282607, 6.16591694805352, 6.3095969885328, 6.45646411719527, 6.60690986461733, 6.7607663559943, 6.91819515641402, 7.07936445998824, 7.2442336646087, 7.4129855022168, 7.58582915560075, 7.76246351980547, 7.94336389185347, 8.12819629982869, 8.31748830322892, 8.51120311935212, 8.70963007766765, 8.91236851110203, 9.12007863057234, 9.3323253763062, 9.54985042066809, 9.77218486971381, 10.0001661852962, 10.2327950905944, 10.4714698810819, 10.7151053301551, 10.9646942099711, 11.2202000511668, 11.481556688206, 11.7486642307561, 12.0228136506425, 12.3025402876746, 12.5892110270895, 12.882800311789, 13.1823742451315, 13.489549091985, 13.8033527682673, 14.1256461792077, 14.4543590459429, 14.7914832545465, 15.1358306960742, 15.4884466073567, 15.849255728102, 16.218139360028, 16.5963896654057, 16.9824668860576, 17.3777129943964, 17.7820306844788, 18.197062425104, 18.6209884397816, 19.0535517185925, 19.4986028224736, 19.9519735653357, 20.4178297858679, 20.8938834506942, 21.3798774703834, 21.8781767449478, 22.3859358255223, 22.9086386304349, 23.4434555840424, 23.9868906474195, 24.4617728210289, 25.030627194913, 25.6181897205504, 26.2130148419347, 26.8266427207605, 27.455172621907, 28.0937811170387, 28.751449890638, 29.4234015101268, 30.1092477949067, 30.8142629304006, 31.5326307205745, 32.2700319384226, 33.019847133834, 33.7952661610636, 34.5823741527521, 35.3877712008252, 36.2111912675171, 37.0609536812008, 37.9287301761387, 38.8139433054402, 39.7158673476879, 40.6442831286205, 41.5997404939946, 42.5709162935017, 43.5564642909024, 44.5810126496729, 45.6191146627162, 46.6833433167586, 47.7736556953069, 48.8898915488733, 50.0317617900903, 51.1988284390013, 52.3904910767017, 53.6257146986582, 54.86494081583, 56.1476929120039, 57.4528069787863, 58.8029351241702, 60.1743686855608, 61.5919359491351, 63.0290608028603, 64.4831587917317, 65.9825678305874, 67.5286047970775, 69.1225735455047, 70.7292127373549, 72.3826406821742, 74.0837712670898, 75.7908268990384, 77.5877527784319, 79.3872762217308, 81.2324006210061, 83.1231186036943, 85.0592352916312, 87.0403434241269, 89.0657885682727, 91.1988372294617, 93.31288331588, 95.4676758375373, 97.736133375685, 99.9701348747591, 1e3]
Ai = @SVector [1.0, 1.06703864090064, 1.06875586797083, 1.07052163674707, 1.07233767092153, 1.07420559831727, 1.07612720782859, 1.07810426753169, 1.08013864965441, 1.08223245944135, 1.08438765651816, 1.08660643976537, 1.08889111257429, 1.09124392886396, 1.0936674099055, 1.09616412964452, 1.09873685225255, 1.10138828109655, 1.10412144985124, 1.10693950131562, 1.10984556771971, 1.1128431741543, 1.11593592797726, 1.11912755522829, 1.12242200847979, 1.12582355013723, 1.12933647239317, 1.13296549688731, 1.13671552415173, 1.14059166416224, 1.14459947837975, 1.14874470649292, 1.15303347155909, 1.15747217527575, 1.16206785456776, 1.16682764058575, 1.1717593713337, 1.17687122452897, 1.18217209241337, 1.18767127364443, 1.1933786811155, 1.19930504685837, 1.20546194467564, 1.21186127452283, 1.2185164725599, 1.22544143262654, 1.2326512596971, 1.24016254091402, 1.24799260877242, 1.25616050094805, 1.26468707947706, 1.2735944077208, 1.2829069921853, 1.29265118602082, 1.30285389938649, 1.31343991498885, 1.32435199509725, 1.33559513989266, 1.34716756579281, 1.35906051889546, 1.37125849333225, 1.38374060422001, 1.39648017467787, 1.4094453018432, 1.42259992584518, 1.43590386337062, 1.4493134964406, 1.46278257976503, 1.4762620608898, 1.48970313149132, 1.50305925969573, 1.51629469007934, 1.52938261848903, 1.54230348253616, 1.55504478055455, 1.56759746094461, 1.57995140591516, 1.59212079860389, 1.60411040817598, 1.61592672351486, 1.62757481023298, 1.63906073226851, 1.65038876459038, 1.66156504265066, 1.67259543567938, 1.68348536624952, 1.69423966460146, 1.70486495800563, 1.71536659731093, 1.72575036157773, 1.73602109634979, 1.74618529536434, 1.75624844105561, 1.76621620848404, 1.77609444960205, 1.78588917663348, 1.79560652952295, 1.80525187170047, 1.81483135608769, 1.82435110438271, 1.83380601841381, 1.84321060533599, 1.85257372146419, 1.86189989720152, 1.87119722716341, 1.88047164444702, 1.88972866173761, 1.89897657283838, 1.90822005722035, 1.91746655581289, 1.92672185454918, 1.93599454630268, 1.94528802955623, 1.95460611351215, 1.96395205545783, 1.97332730096478, 1.98273292143254, 1.99216504568077, 2.00162710949167, 2.01111304111233, 2.02062288684835, 2.03015160820196, 2.03969749825877, 2.04925721106831, 2.05882351678941, 2.06839692816824, 2.07797039280434, 2.08754308076974, 2.09710589275194, 2.1066585347477, 2.11619441379135, 2.12571175557418, 2.13520445916782, 2.1446690118278, 2.15410507762589, 2.16350489052618, 2.17286898918743, 2.18219307462439, 2.19147010421682, 2.20070531634737, 2.20988960997688, 2.21902327005749, 2.22810402779576, 2.23713014542967, 2.24609682660765, 2.25501024943307, 2.26385952749534, 2.27265206044218, 2.2813812360854, 2.29005222814591, 2.29865916703363, 2.30720011746131, 2.31568211747521, 2.32410039642848, 2.33245450833281, 2.34074443847271, 2.34897537825235, 2.35714380777201, 2.36525112972899, 2.37329932311726, 2.38129096270607, 2.38922384784986, 2.39709585164769, 2.40491607654021, 2.41268355383092, 2.42039742245455, 2.42806297630066, 2.4356801397874, 2.4432482878922, 2.45077192942042, 2.45824908637873, 2.46568721066236, 2.47309486262213, 2.48046030626912, 2.48779963178117, 2.49510858410167, 2.50239001812315, 2.50964719361091, 2.51688373994356, 2.52410380233782, 2.53131197866005, 2.53847199813543, 2.54567344943883, 2.55289148164837, 2.56012610679884, 2.56738118224535, 2.57465113016471, 2.58194018564737, 2.58925340653725, 2.59657426728633, 2.60391872734924, 2.6112694708612, 2.61864366195085, 2.62603595781132, 2.63345331423361, 2.64087701333467, 2.64832730374271, 2.65578474655584, 2.66327146067633, 2.67076739569765, 2.67829669322392, 2.6858224787706, 2.6933861205713, 2.7009492293435, 2.70853884164594, 2.71614966449537, 2.72377572648241, 2.73141037067914, 2.73908620702659, 2.74675827002529, 2.75446014579853, 2.76218683742717, 2.7699100106748, 2.77766734440365, 2.7854302232962, 2.79324032632552, 2.80104324587815, 2.80888175823791, 2.81672477235592, 2.82459207194985, 2.83247784701687, 2.84037545866793, 2.84830823844775, 2.8562398498425, 2.86419400677171, 2.87216448824192, 2.88017916580779, 2.88819854391081, 2.89621418090161, 2.90429286386946, 2.91235462550598, 2.92046936044239, 2.92859258203706, 2.9367161877715, 2.94487552787013, 2.95301996803807, 2.96123304387097, 2.96946515777201, 2.97765917855897, 2.98467401591372, 2.99293053573537, 3.00128425508161, 3.00956834985056, 3.01793944199022, 3.02633874110576, 3.03469831060109, 3.04313136509235, 3.05157156429415, 3.06001024454111, 3.0685075676036, 3.07698897569764, 3.08551723420504, 3.0940118092181, 3.10261703281621, 3.11117372728503, 3.11975023387862, 3.12833938497636, 3.1370223080821, 3.14570846940482, 3.15438835859857, 3.16305136839715, 3.17178669857566, 3.18059320558372, 3.18936213624136, 3.19807901730661, 3.20695586331613, 3.21576683056899, 3.22461519007999, 3.23349546791687, 3.24240152116193, 3.2513263387366, 3.26026211950977, 3.26920006983149, 3.27827611014175, 3.28719598262357, 3.29624070601799, 3.30525544156978, 3.31439112122328, 3.32348222079511, 3.33268797330732, 3.34183110712135, 3.35089374047133, 3.36004796521199, 3.36929457925546, 3.37863434820875, 3.38785704285932, 3.39715515061964, 3.40652726934536, 3.41574060072069, 3.42524186793735, 3.434563876053, 3.44392739058654, 3.45332707129066, 3.46275674855456, 3.4722093556338, 3.48167703081897, 3.49144617416317, 3.50093264847628, 3.51040514481747, 3.5201753622639, 3.52959082307405, 3.52959082307405]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_ask14_1100 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Abrahamson _et al._ (2014) GMM, for Vs30 = 1100 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_ask14_1100 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_ask14_1100()
fi = @SVector [0.001, 0.0977009871629398, 0.0999999974066191, 0.102329292723223, 0.10471289115513, 0.107151916156133, 0.109647814357927, 0.112201837973753, 0.114815395071387, 0.117489796627051, 0.12022642314675, 0.123026890738146, 0.125892538044346, 0.128824937029181, 0.131825698037974, 0.134896294629028, 0.138038396066939, 0.141253712785238, 0.144543994114778, 0.147910821002263, 0.151356111737264, 0.15488169624427, 0.158489284937044, 0.162180990779373, 0.165958686142594, 0.169824397487713, 0.173780077682896, 0.177827989905068, 0.181970075789458, 0.186208696802254, 0.190546089530823, 0.194984390967264, 0.19952619872714, 0.204173791156713, 0.208929578476893, 0.213796157219783, 0.218776182483442, 0.223872073974258, 0.229086805382967, 0.234422887101731, 0.239883242654684, 0.245470849447296, 0.251188575845802, 0.257039494058099, 0.263026750987176, 0.269153396051622, 0.275422838647827, 0.281838211787, 0.288403047254166, 0.295120911515252, 0.30199515230416, 0.309029461082775, 0.316227810959307, 0.323593528220054, 0.331131014939867, 0.338843995274008, 0.346736787224427, 0.354813408075398, 0.363078003101169, 0.371535229845431, 0.380189370412531, 0.389045015362505, 0.398107129653939, 0.407380169972867, 0.416869387998658, 0.426579460490376, 0.436515642062981, 0.446683603942946, 0.457088011726756, 0.467735030372381, 0.478630059436938, 0.48977886174253, 0.501186900923732, 0.512861101135527, 0.524807426977635, 0.537031806989445, 0.549540539495192, 0.562341256619687, 0.575439855356368, 0.588843529560242, 0.602559464658751, 0.616594793588158, 0.630957122685767, 0.645653967098973, 0.660693346609629, 0.676082476533705, 0.691830380094231, 0.707945190893355, 0.724435846540562, 0.741309834383654, 0.758576929235547, 0.776246740734158, 0.794327667258409, 0.812830478038647, 0.831763668856544, 0.851138257025319, 0.870963800915754, 0.891250342744557, 0.912011002228203, 0.933253426960802, 0.954992169704093, 0.977237337184143, 0.999999431520578, 1.02329258802432, 1.04712873284538, 1.07151870290434, 1.09647737309909, 1.12201694252587, 1.14815218303086, 1.17489685409032, 1.20226345909574, 1.23026747271141, 1.25892554890496, 1.28824801873988, 1.31825585970448, 1.34896088340374, 1.38038380739445, 1.41253790846537, 1.44543991146322, 1.47910741518123, 1.51355897881738, 1.54881424565928, 1.58489013888922, 1.62180826292029, 1.65958737746723, 1.69824256006834, 1.73779828792432, 1.7782759683263, 1.81969809878839, 1.86208300469775, 1.90546073274021, 1.94984206152573, 1.99525798039047, 2.04173612727008, 2.08929487780124, 2.13796268150687, 2.18775720016312, 2.23872156828875, 2.29086319409698, 2.34422279927247, 2.39882720656895, 2.45470437951388, 2.5118831262352, 2.57039286287139, 2.63026340393243, 2.69153643345486, 2.75423092461459, 2.81837601483687, 2.88402755531517, 2.95120221165731, 3.01994301176439, 3.0902943436397, 3.16226791918128, 3.23592343978858, 3.31130639900788, 3.38844346520425, 3.46735829075066, 3.54813796982173, 3.63076229148808, 3.71534669081613, 3.801892180906, 3.89044610656452, 3.98105751405223, 4.07380854238369, 4.16869221231179, 4.26579468976477, 4.36513953987965, 4.46682411265725, 4.57087674263924, 4.67732286510221, 4.78627663067936, 4.89777211817101, 5.01184183117266, 5.12862521542859, 5.24805454537812, 5.37028060850859, 5.49541580776269, 5.62338453092948, 5.75437227828415, 5.88844607464468, 6.02559802172859, 6.16589398182084, 6.30958607432139, 6.45649876349053, 6.60690890495408, 6.760828758235, 6.91826280879999, 7.0794443841581, 7.24439895822411, 7.41301413135051, 7.58570315772501, 7.7623709696718, 7.94320167603534, 8.12824505786064, 8.31755037303491, 8.51135148759121, 8.70953361675237, 8.91256121414362, 9.12012223126881, 9.33243620666656, 9.54994255437179, 9.77238579015416, 9.99998079300324, 10.232879861281, 10.4712538288613, 10.7152949734939, 10.9648844956418, 11.2202146864893, 11.4815052803655, 11.7490074721504, 12.0225917857968, 12.3025220369835, 12.589103564177, 12.8821971342623, 13.1826526141445, 13.4892888965139, 13.8035425565483, 14.1253154493635, 14.4544590583405, 14.7907677635153, 15.1354174421594, 15.4882980859825, 15.8484371645514, 16.2180328252238, 16.5961517672835, 16.9825665808237, 17.3779810898009, 17.7821741443577, 18.1970908347437, 18.6203446881932, 19.053982058617, 19.4978468737616, 19.9531057948348, 20.4167255747922, 20.8927512271844, 21.3795343032608, 21.8767465388772, 22.3876321461927, 22.9083678904629, 23.4424212027064, 23.987524339405, 24.4611328388709, 25.0316992744836, 25.6170945647467, 26.2146717990403, 26.8266726818231, 27.4528300428137, 28.0927699486552, 28.7493251169649, 29.4223987334913, 30.108087751031, 30.813343104761, 31.5300579809116, 32.2657695904908, 33.0204385313945, 33.7939274806613, 34.5808256137391, 35.3908395432242, 36.212760526797, 37.0632487171366, 37.9240601780719, 38.8135353154471, 39.7182173175756, 40.6442660545585, 41.5912069613362, 42.5668541119602, 43.5627905245868, 44.5780338296613, 45.6213470331911, 46.6823109274263, 47.770375329313, 48.885319197145, 50.026760373473, 51.1941325267533, 52.4005309523462, 53.617862354211, 54.873591949379, 56.1522828539384, 57.469459825696, 58.807519879041, 60.1833856512864, 61.5769801307731, 63.0282396696194, 64.4949557174051, 65.9973082892216, 67.534697485468, 69.1064003046458, 70.7394762496497, 72.3771421349366, 74.0762326373562, 75.8061756762341, 77.5645386722037, 79.3856821717277, 81.2327436035212, 83.1435705160823, 85.0764783644605, 87.0731307538662, 89.0863780489238, 91.1620407295812, 93.3015037249044, 95.5060564600769, 97.7157245280178, 99.986853832442, 1e3]
Ai = @SVector [1.0, 1.07272009904468, 1.07461824650246, 1.07655171146224, 1.07854109520397, 1.08058819823652, 1.0826951497798, 1.08486397812369, 1.08709690939917, 1.08939615726736, 1.09176406893817, 1.09420327652032, 1.09671625725455, 1.09930578290889, 1.10191017953457, 1.10452493872894, 1.10715174175041, 1.10979243811057, 1.11244890835546, 1.11512289913659, 1.11781643572506, 1.12053128512129, 1.12326817918572, 1.12602703376797, 1.12880658505047, 1.13160477706513, 1.13441869676906, 1.13724495190875, 1.14007928263506, 1.14291720161923, 1.14575415957275, 1.14858592660218, 1.1514089643221, 1.15421987995924, 1.15701571909552, 1.15979392670495, 1.16255225966834, 1.1652885983998, 1.16800137297815, 1.1706889570505, 1.1733501619506, 1.1759840652315, 1.17858995753545, 1.18116744880569, 1.1837163884907, 1.18623676205161, 1.1887288695556, 1.19119303022579, 1.19362984302879, 1.19604001630278, 1.19842427160126, 1.20078352793097, 1.20311886539246, 1.20543119825006, 1.20772183720017, 1.20999191388274, 1.21224273635681, 1.21447550065783, 1.21669141739463, 1.21889180892343, 1.22107784804006, 1.22325078247076, 1.22541190626654, 1.22756238349845, 1.2297035270306, 1.23183650163022, 1.23396258564557, 1.23608311850285, 1.23819921920532, 1.24031229009923, 1.24242356583984, 1.24453433506328, 1.24664581247653, 1.24875948751423, 1.25087663538713, 1.25299853195304, 1.25512650122771, 1.25726208863782, 1.25940652727078, 1.26156125549539, 1.26372771341754, 1.26590732199988, 1.26810155720129, 1.27031189425135, 1.27253985810081, 1.27478687788863, 1.27705462288155, 1.27934276014941, 1.28165462411655, 1.28399198654355, 1.28635664067962, 1.28875037455688, 1.29117481695682, 1.29363193024651, 1.29612338951354, 1.29865122116436, 1.30121727928775, 1.30382351199079, 1.30647227682148, 1.30916528339693, 1.31190513928398, 1.31469392835841, 1.31753382854405, 1.32042751764099, 1.3233774564062, 1.32638600650979, 1.32945610373235, 1.3325904068269, 1.3357919662761, 1.33906372372302, 1.34240837939107, 1.34582891467241, 1.34932837994988, 1.35290898209872, 1.35657421353127, 1.36032641355398, 1.36416901384907, 1.36810455249425, 1.37213602407855, 1.37626657040445, 1.38049951606509, 1.38483839009469, 1.38928649325937, 1.39384780778565, 1.39852608936178, 1.40332475364739, 1.40824856544542, 1.41330205729258, 1.41849009964461, 1.42381723127328, 1.42928970963458, 1.43491029213688, 1.44068661703736, 1.44662599002522, 1.45273328458737, 1.45901308812765, 1.46546705130721, 1.47209871424575, 1.47890568795647, 1.48588873879748, 1.4930457675397, 1.50037382724259, 1.50786922046871, 1.5155275540678, 1.52334376876346, 1.53131376413294, 1.53942995149464, 1.54768560954972, 1.55607705944115, 1.56459529185976, 1.57323440509721, 1.58198845237596, 1.59084726340846, 1.59980654657903, 1.60886015557629, 1.61799967868031, 1.6272164217661, 1.63650914557563, 1.64586429703662, 1.65528391515161, 1.66475725330086, 1.67427892813077, 1.68384389875844, 1.69345075089038, 1.70308898687821, 1.71275793566168, 1.72245078705748, 1.73216819740151, 1.7419043416768, 1.7516534515231, 1.76141811934267, 1.77119384316637, 1.78097628509195, 1.79077051451167, 1.80056435016061, 1.81036399461194, 1.8201724868708, 1.82997835699894, 1.83979059989863, 1.84960922116068, 1.85942898812654, 1.86925038215246, 1.87908693190678, 1.88892282798721, 1.89877320923897, 1.90863559957257, 1.91850741363785, 1.92840065402361, 1.93831442165585, 1.94823997845153, 1.95819986775019, 1.96818692768151, 1.9782102887716, 1.98827162803559, 1.99837290811246, 2.00852605664248, 2.01872488554179, 2.02899325647068, 2.03931573558146, 2.04967418993201, 2.0601133763512, 2.07060372382565, 2.08113528731286, 2.09170972954, 2.10232933167292, 2.11299710662163, 2.12370244067942, 2.13444816749834, 2.14523802190605, 2.15607680791983, 2.1669537059346, 2.17787370041792, 2.1888430487277, 2.19985080665347, 2.21092307478773, 2.22201077493362, 2.23316030693854, 2.24436218544429, 2.2556054542483, 2.26687757989132, 2.27821218094849, 2.28959953097319, 2.3010027281741, 2.31248545169504, 2.32401250633251, 2.33557124555343, 2.34717697245005, 2.35881738764232, 2.37054226352417, 2.3822781308288, 2.39407600270815, 2.4059253507225, 2.4178508849077, 2.42976745923843, 2.44177306889645, 2.45381964595755, 2.46589329495152, 2.47806620561788, 2.49024109523032, 2.50249301689143, 2.51476373848892, 2.52522141545063, 2.53761560316165, 2.55010070088297, 2.56260604499172, 2.57517234514276, 2.58778760568597, 2.60043804807758, 2.61317290555668, 2.62598316336768, 2.63878838235406, 2.65171176644399, 2.6645984212046, 2.67757777859987, 2.69064164695608, 2.70378040744139, 2.71689614902714, 2.73014380516897, 2.74333383153553, 2.75672624835215, 2.77002707680706, 2.78351299093379, 2.79697254163969, 2.81049145410968, 2.82405589121605, 2.83776993956185, 2.85150757506944, 2.86524932646822, 2.87910670960228, 2.89293465834964, 2.90684990634723, 2.92084194148866, 2.9348985163986, 2.94900553381421, 2.96331261610237, 2.97748015891666, 2.99182138611405, 3.00615236768523, 3.02063939169015, 3.03508181862186, 3.04965531487661, 3.06414077639189, 3.07894459447328, 3.09362811047786, 3.10838779315418, 3.12321003239785, 3.13807573868171, 3.15323511660044, 3.16815460160513, 3.18334535102935, 3.19852502461294, 3.21366680703337, 3.22905782659867, 3.24437839387357, 3.25993439598707, 3.27537896464421, 3.29103764303801, 3.30653383328533, 3.32221368542922, 3.33807718010097, 3.35412348943361, 3.36991091436369, 3.3858217188871, 3.3858217188871]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_bssa14_620 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Boore _et al._ (2014) GMM, for Vs30 = 620 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_bssa14_620 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_bssa14_620()
fi = @SVector [0.001, 0.0988597583233483, 0.10000000905698, 0.102329313938003, 0.104712907225502, 0.107151928415835, 0.109647833806917, 0.112201853536817, 0.114815416755257, 0.11748980899071, 0.120226447690601, 0.123026907889884, 0.125892549490764, 0.128824947136627, 0.131825713083256, 0.134896318640697, 0.138038418217646, 0.141253742621104, 0.144544010331342, 0.147910858264061, 0.151356135757439, 0.154881715984271, 0.158489343800596, 0.162181024977386, 0.165958714245848, 0.169824426384122, 0.173780119618491, 0.177828026653765, 0.181970149492778, 0.186208745413493, 0.190546136191941, 0.194984472771739, 0.199526244867303, 0.204173849648116, 0.208929632051863, 0.213796259156406, 0.218776225790489, 0.223872160502327, 0.229086863604599, 0.234422963882157, 0.239883331593177, 0.245470952735973, 0.251188631268231, 0.257039566972664, 0.263026867052165, 0.269153479193755, 0.275422981993268, 0.281838430665289, 0.288403183240027, 0.295121036430249, 0.30199532016941, 0.309029681385659, 0.316227959453922, 0.323593815430701, 0.331131125293165, 0.33884413965573, 0.346736844105946, 0.354813571718636, 0.363078097884058, 0.37153533489662, 0.380189432953379, 0.389045387684826, 0.398107382434792, 0.40738045458149, 0.416869559055489, 0.426579848570301, 0.43651596623884, 0.44668400463115, 0.457088385344204, 0.467735261703718, 0.478630157887024, 0.489778747086552, 0.501187335766022, 0.512861581142204, 0.524807498332346, 0.537032210612533, 0.549540852571808, 0.562341870630425, 0.57544046521564, 0.588844308449063, 0.602559995333324, 0.616595844987953, 0.630957558958681, 0.645654794797108, 0.660694177542891, 0.676083899673177, 0.691830990537161, 0.707945672573651, 0.724437042167066, 0.741310651761912, 0.758578903635447, 0.776248662527666, 0.794328058553149, 0.812831315341774, 0.831763429555492, 0.85113774549701, 0.870964759497601, 0.89125283141736, 0.912012782125235, 0.933254304756467, 0.954991789969289, 0.977238521026131, 1.0000023432413, 1.02329199301602, 1.04713005392984, 1.07152077887013, 1.09647780112639, 1.12202176953535, 1.14815566129574, 1.17489868642837, 1.20226720726246, 1.23026752889531, 1.25892566850813, 1.28825121936761, 1.31825790247562, 1.34896343274778, 1.38038719333504, 1.41253637652755, 1.44544512052703, 1.47910568445794, 1.51356696971057, 1.54882323535081, 1.58489888950969, 1.62180984611921, 1.65958587061972, 1.69824796089502, 1.73780552331717, 1.77828217420365, 1.81970422254956, 1.86208515275049, 1.9054724229932, 1.94985012740896, 1.99527070787577, 2.04173630344276, 2.0893083951811, 2.13797175768858, 2.18777328777465, 2.23871864068967, 2.29087073444947, 2.34423024579319, 2.39883177562053, 2.45471482650006, 2.51189259796148, 2.5704096362536, 2.63028194393451, 2.69152489765904, 2.75422829217587, 2.81837812414992, 2.88403590342629, 2.95122773545922, 3.01998066568673, 3.09032260868609, 3.16228244386608, 3.23594330407204, 3.31134484354241, 3.38847095643201, 3.46735834163272, 3.54817498394486, 3.63078349322634, 3.71536572639437, 3.80190149002748, 3.8904465796713, 3.98106213681025, 4.07381551219341, 4.16869054376005, 4.2658511826137, 4.36518885955019, 4.46687936557587, 4.57090821709747, 4.67736536907894, 4.78635192086503, 4.89785462271124, 5.01184961533696, 5.12857918519133, 5.24806034044961, 5.3703242692595, 5.49549088729441, 5.62338735195922, 5.75448188593756, 5.88839072224789, 6.0256295160731, 6.16597957071741, 6.30960270593151, 6.45668573120628, 6.60695695440333, 6.76084384119688, 6.91831606724392, 7.07960762923677, 7.24439292930821, 7.41320680717793, 7.58569585774497, 7.76246077056568, 7.94348611541068, 8.12835237807942, 8.31775252136749, 8.51123657664752, 8.70959011881566, 8.91280701501557, 9.12036374628954, 9.33265604127413, 9.55015246249384, 9.77224591631989, 10.0000125297722, 10.2328175845497, 10.4712208696213, 10.7151748001665, 10.9646022666217, 11.2201783962418, 11.4818755272534, 11.7487660694211, 12.022458611423, 12.3029582831401, 12.5892293159785, 12.8821305829416, 13.1826882436444, 13.4897550794907, 13.8044007269437, 14.1252831922455, 14.4548879516212, 14.7918546960737, 15.1360273793202, 15.488804126609, 15.8484759238666, 16.2182817980509, 16.5965079631525, 16.9830034334309, 17.3775626417757, 17.7820985331221, 18.1966079272567, 18.6210449358712, 19.0553168235015, 19.499277325153, 19.9527202232158, 20.4183315756054, 20.8930982542792, 21.3798880657389, 21.8786989662917, 22.3894775667764, 22.9082936233792, 23.4424310548708, 23.9879960081905, 24.460383892312, 25.0326798266495, 25.6158540067528, 26.2145168077636, 26.8287704886367, 27.4529619590147, 28.0982185506974, 28.7527007922617, 29.4219449727912, 30.1126649436645, 30.8108103109316, 31.5303245328492, 32.2717738292055, 33.0185315147938, 33.7956233897451, 34.5857748541972, 35.3879391515523, 36.2219479825103, 37.0673806362718, 37.9227145659252, 38.8107470771415, 39.7202499156505, 40.6510388144964, 41.6028169233534, 42.5751549892028, 43.5674822949736, 44.5790713196024, 45.6265840882283, 46.6930952545201, 47.7774087260323, 48.8985833402475, 50.0364866202866, 51.2119943690208, 52.4025439343416, 53.6309809757702, 54.8720174783855, 56.1506397828695, 57.4677958921276, 58.8244100721625, 60.1888854751973, 61.5912822397116, 63.0321122532365, 64.5118013476349, 65.9908327291353, 67.5471812303265, 69.142876649141, 70.7313612927305, 72.4030445720195, 74.0616476165949, 75.8068914427253, 77.5886895663998, 79.4057707792604, 81.2565744543678, 83.1391628600678, 85.0512132395375, 87.0635050988493, 89.1065997043318, 91.1772654809007, 93.3575399968966, 95.475486683051, 97.7030783533799, 100.049025578562, 1e3]
Ai = @SVector [1.0, 1.16852001022416, 1.17079775558813, 1.17549243576777, 1.18035547957409, 1.18539461708148, 1.19061868119862, 1.1960365289652, 1.20165797121848, 1.20749309515359, 1.21355290678476, 1.21984946681944, 1.22639509922126, 1.23312093381688, 1.24002947681618, 1.24713134299229, 1.25443816901358, 1.2619624592546, 1.26971741940921, 1.27771686651422, 1.28597600573522, 1.29451111209051, 1.30333920927558, 1.3124791779239, 1.32195116574899, 1.331776707716, 1.34197893269775, 1.35258350017443, 1.36361750527889, 1.37510904143418, 1.38708171703191, 1.39955296281825, 1.4125356109455, 1.42603688229788, 1.44005869074998, 1.45459892974749, 1.46965020833269, 1.48520096709046, 1.50123586514995, 1.51773493846986, 1.53467480819576, 1.55202818636721, 1.5697632073289, 1.58784565595421, 1.60623781051806, 1.62489866043229, 1.6437868179371, 1.66285738790428, 1.68206487297593, 1.70136404384849, 1.72070760504375, 1.74004892012907, 1.75934194810429, 1.77854057540207, 1.79759995294883, 1.81647718025617, 1.83513000935443, 1.8535217521019, 1.87162242214568, 1.88941255272572, 1.90687780076733, 1.92401130377593, 1.94080941457954, 1.95727409653831, 1.97340995514258, 1.98922292272048, 2.00471807179774, 2.01990253139759, 2.03478072842117, 2.04935948180341, 2.06364451072219, 2.07764156534066, 2.09135709660062, 2.10479651336051, 2.11796557822619, 2.13087108092475, 2.14351749873696, 2.15591249225738, 2.16806034482347, 2.17996751811304, 2.19163921833107, 2.20308196703137, 2.21429984014348, 2.22529984531861, 2.23608642044641, 2.24666491296, 2.25703971450002, 2.26721707265114, 2.27720216870615, 2.28699795474133, 2.29661115471612, 2.30604515456765, 2.31530390963179, 2.32439429955309, 2.33331838340306, 2.34208211949183, 2.3506898685418, 2.35914131868225, 2.36744029516954, 2.37559564395953, 2.38361262925028, 2.39149589239825, 2.39924798897435, 2.40687177159353, 2.41437445939354, 2.42175720647081, 2.42902406190093, 2.43618092346483, 2.4432285288167, 2.45017201572293, 2.45701559261216, 2.46376077865167, 2.47041383682226, 2.47697697116147, 2.48344866944727, 2.48983434058688, 2.49614062074161, 2.50236906034215, 2.50852637608938, 2.51461125832967, 2.52063267268482, 2.52658971422462, 2.5324866539671, 2.53832634427074, 2.54411360296373, 2.54985171915201, 2.55554230033366, 2.56118889604372, 2.56679533022657, 2.57236361999384, 2.57790010899007, 2.58340298087726, 2.58887894228097, 2.59432847601493, 2.59975896910812, 2.60516895357878, 2.6105638526664, 2.61594465116197, 2.62131162282258, 2.62667189090808, 2.63202999377162, 2.63739013876162, 2.64275403769574, 2.6481263238693, 2.65350897203928, 2.65890396728779, 2.66431975476579, 2.66975569031906, 2.67521757147602, 2.68070832446159, 2.6862308772798, 2.69178829914687, 2.69738385815032, 2.703025010902, 2.70871579015758, 2.7144561228457, 2.72024997289303, 2.72611086425046, 2.73202821223489, 2.7380150018984, 2.74407462239375, 2.75021246773453, 2.75643435613377, 2.76274653322121, 2.76914970570235, 2.77565668059431, 2.78226217154989, 2.78897992990252, 2.79581117814499, 2.80276420246199, 2.80984800738925, 2.81706434550368, 2.82441438827793, 2.83191675510894, 2.83956602158246, 2.84729329742131, 2.85505124280977, 2.86281624903587, 2.87061255837141, 2.87841327596513, 2.88624430284398, 2.89408887463845, 2.90195206115551, 2.90983974040536, 2.91773332989093, 2.92565126054603, 2.93358774421819, 2.94155024897269, 2.94951865660694, 2.95751467858713, 2.96551741714752, 2.97355058849505, 2.98160897361581, 2.98966977885218, 2.9977591619403, 3.00585374518061, 3.0139820603, 3.02213920730227, 3.030300031461, 3.03847616292749, 3.04668114964609, 3.05488803711364, 3.06313216351745, 3.07138615416919, 3.07966556741002, 3.08796430757199, 3.09627552139215, 3.10461727824668, 3.1129839706072, 3.12134204688819, 3.12973759800806, 3.13816589795524, 3.14659154116638, 3.15503581308473, 3.16352345588758, 3.17201745225504, 3.1805430287924, 3.18905965203779, 3.1976286540199, 3.20620987311826, 3.21479525292585, 3.22341511426585, 3.23202358553016, 3.24069342682608, 3.24937927136952, 3.25807342197179, 3.26676729053254, 3.2754984735271, 3.28426181654091, 3.29305153896602, 3.3018610313924, 3.31068286760127, 3.3195087452895, 3.32838606965378, 3.33725279004637, 3.3461580434439, 3.35509655927376, 3.36406242922311, 3.37298303508608, 3.38197912197677, 3.39097974086048, 3.39861081876226, 3.40769614800642, 3.41676669713791, 3.42588721246344, 3.43505355499458, 3.44417723770067, 3.45341565746253, 3.46259423551111, 3.47178723635246, 3.4810808152818, 3.49028183382626, 3.49956986722198, 3.50894508089, 3.51819394054556, 3.52762120844497, 3.53701090587155, 3.54634776514436, 3.55585653517976, 3.56529847733069, 3.57465489115539, 3.58416958708424, 3.59371498600585, 3.60328401161063, 3.61286860245501, 3.62245992941058, 3.63204804986045, 3.64162183958739, 3.65133273396139, 3.66101764112691, 3.67066253687125, 3.68043122375501, 3.69014283075682, 3.69997010038884, 3.70971955082135, 3.71957348975725, 3.72932468594816, 3.7391652025581, 3.74909504558002, 3.75911382258568, 3.76898484207798, 3.77892230726438, 3.78892335989724, 3.7989844773555, 3.80883512598476, 3.81898849111315, 3.82918672185962, 3.83913128373885, 3.8493826833476, 3.8593459041022, 3.86961490702734, 3.87988549633358, 3.89014608065431, 3.90038312046918, 3.91058256858265, 3.92072913548489, 3.9311894664449, 3.94159368252546, 3.95192307260851, 3.96257802419261, 3.97271726066907, 3.98316253500384, 3.99393943022028, 3.99393943022028]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_bssa14_760 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Boore _et al._ (2014) GMM, for Vs30 = 760 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_bssa14_760 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_bssa14_760()
fi = @SVector [0.001, 0.0911162626259868, 0.093260321030032, 0.0954548276537386, 0.097700983456623, 0.0999999820952542, 0.102329288657437, 0.104712886897726, 0.107151898576338, 0.109647795949619, 0.112201818697888, 0.114815374887065, 0.117489775491468, 0.120226401015101, 0.123026884861295, 0.125892513777469, 0.128824911618647, 0.131825678122484, 0.134896268392557, 0.138038384735951, 0.141253709921094, 0.144543963437463, 0.147910800512607, 0.151356075188123, 0.154881660174717, 0.158489267502305, 0.162180970646285, 0.165958653333, 0.169824346053222, 0.173780044393326, 0.177827942042926, 0.181970051029366, 0.186208660232139, 0.190546059784457, 0.194984353229929, 0.199526128106147, 0.204173751722764, 0.20892955028489, 0.213796152511466, 0.218776112752252, 0.223872048825969, 0.229086703225714, 0.234422832723251, 0.239883195800222, 0.245470813347372, 0.25118851160021, 0.257039461393428, 0.263026692540031, 0.269153371763333, 0.275422819407075, 0.281838165047044, 0.288402948293457, 0.295120803175706, 0.301995031395083, 0.309029397959102, 0.316227608503954, 0.323593446557635, 0.331130969998632, 0.338843906713985, 0.346736597226246, 0.354813252116192, 0.363077901142721, 0.371535031156678, 0.380189215767494, 0.389044984220145, 0.398106816830357, 0.407380136811554, 0.416869160401731, 0.426579333548684, 0.436515548592194, 0.446683272378262, 0.45708795418994, 0.467734860095858, 0.478629668696382, 0.489778445447913, 0.501186718043336, 0.512861077069637, 0.524807326731799, 0.537031164483197, 0.549540349983891, 0.562340880014143, 0.575439553575671, 0.58884341827149, 0.602558931622333, 0.61659402334075, 0.630956723964703, 0.645653291142765, 0.66069312756252, 0.676082650590049, 0.69183056836225, 0.707945076523136, 0.724434752191284, 0.741308974581602, 0.758576209627959, 0.776246773030056, 0.79432748801736, 0.812829309782221, 0.831763442447971, 0.851137724527408, 0.870962906834318, 0.891249503642188, 0.912009605000737, 0.933252826456988, 0.954990037596422, 0.977236096699494, 0.999997856190628, 1.02329086792856, 1.04712732847849, 1.07151799175662, 1.09647479135, 1.12201789771688, 1.14815282104044, 1.17489622351163, 1.20226311696289, 1.23026620148268, 1.25892388582697, 1.28824778446107, 1.31825530797311, 1.34896087152802, 1.38038032106668, 1.41253692508557, 1.445439022341, 1.47910778317774, 1.51355422248531, 1.54881134487854, 1.58488795476428, 1.62180838171325, 1.65958368858436, 1.69824238595341, 1.73779847972394, 1.77827603600399, 1.81969150631633, 1.86208329217625, 1.90545034897491, 1.94983902731283, 1.9952507815335, 2.04172779890817, 2.08928355129046, 2.13795963836794, 2.18775727215626, 2.23870620493322, 2.29085569085141, 2.34422606728919, 2.39881914486294, 2.45469203673004, 2.51186859307884, 2.57039504560511, 2.63025420967004, 2.69151733278799, 2.75421557941965, 2.81838194026748, 2.88402339612077, 2.9512028216528, 3.0199292355183, 3.09027425274607, 3.16225046034222, 3.23590414452624, 3.31128592143274, 3.38841127459114, 3.46733561384397, 3.54812049289905, 3.63074056844326, 3.71530742348746, 3.8018467209065, 3.89043759863809, 3.98105454269997, 4.07378124969755, 4.16864907801435, 4.26575643477429, 4.36514527255278, 4.46678500319695, 4.57086520270523, 4.67728048823422, 4.78624047019078, 4.89771957141816, 5.01186900211919, 5.12856311530136, 5.2480628160809, 5.37023313546781, 5.49536746546279, 5.62332291499947, 5.754303052447, 5.88840999817014, 6.02547308113461, 6.1658736760049, 6.30943605583888, 6.4564762291969, 6.60681845059276, 6.7607717254324, 6.918312929425, 7.07936588393754, 7.24425747015809, 7.41292207965159, 7.58574578518812, 7.76242899518572, 7.94312555149321, 8.12829407379905, 8.31759010959621, 8.5112050404209, 8.70936112698272, 8.91231611946591, 9.12000099309567, 9.33231502050119, 9.54994079660182, 9.77239944707185, 10.0000001597799, 10.2326263405644, 10.471136803066, 10.7149551224552, 10.9644882366261, 11.2202174216049, 11.481450273086, 11.7486508677961, 12.0223720914911, 12.3025291219287, 12.5889952804829, 12.8824194005891, 13.1827051012315, 13.4897101260208, 13.8032410529247, 14.1250867438041, 14.4541781486353, 14.7903148709324, 15.1356308586337, 15.4876465864803, 15.8486432543548, 16.2171642979246, 16.5958596666274, 16.9816664566089, 17.3774298143529, 17.7831140008936, 18.1967920767022, 18.6199724968074, 19.0544793670653, 19.498175111712, 19.9529754896924, 20.4163755211705, 20.892912346942, 21.3800507670956, 21.8774716691975, 22.3877472701828, 22.9076855975856, 23.4400018755962, 23.9879916115976, 24.4597343241965, 25.0308911841329, 25.6135859625918, 26.2116059288632, 26.824939523369, 27.4535021675955, 28.0920598160859, 28.7502419903201, 29.4228448805403, 30.1093798910821, 30.8092265190817, 31.5282456680064, 32.2665483915277, 33.0167888291429, 33.793334298587, 34.5807677450142, 35.3862124015741, 36.2092233431454, 37.0588715126563, 37.9257367673275, 38.8089638768307, 39.7188586552412, 40.6439586236746, 41.5954881087888, 42.5604131037149, 43.5650231077962, 44.5818544068736, 45.6085878997718, 46.675623757658, 47.7676222037955, 48.884049300592, 50.0241840099151, 51.1870940695605, 52.3932632105272, 53.6218239035964, 54.8712133818895, 56.1395620572865, 57.451503152175, 58.8086644682486, 60.1827801874379, 61.5707814890962, 63.0024208862257, 64.4788171831622, 66.0011049249864, 67.5311883608651, 69.105169857874, 70.7236199043905, 72.3869859093085, 74.0470212505932, 75.7986325153462, 77.5413587183516, 79.3804361813949, 81.2035291512659, 83.1273218954462, 85.093198969761, 87.0288650268165, 89.0705440454914, 91.1483073695668, 93.2592711043505, 95.4876919544843, 97.75081441754, 99.9469401041666, 1e3]
Ai = @SVector [1.0, 1.08364234398491, 1.08586162583744, 1.08814730526576, 1.09050179138363, 1.09292756623953, 1.09540190454842, 1.0979513931251, 1.10057866656408, 1.10328683758114, 1.10607887745956, 1.10895805670094, 1.11192766354774, 1.11499119483819, 1.11815257551917, 1.12141549472601, 1.12478418772514, 1.12826304356699, 1.13185647450966, 1.13556938629872, 1.13940688690809, 1.14337436963043, 1.14747740913594, 1.15172210207447, 1.15611487583144, 1.16066228586858, 1.16537169899678, 1.17025063312829, 1.17530721624628, 1.18054999059327, 1.1859882627106, 1.19163164309922, 1.19749071384348, 1.20357671924515, 1.20990135521117, 1.21647779168358, 1.22331975755045, 1.23044186720427, 1.23786023490562, 1.24559202968568, 1.25365580305696, 1.26207173145057, 1.27086160427698, 1.28004897777845, 1.28965982494954, 1.29972199871975, 1.3102664347014, 1.32132661705483, 1.33293942599418, 1.34514560498503, 1.35798957118111, 1.37152116257721, 1.38579572462222, 1.40076722859397, 1.4157251995136, 1.43055370729663, 1.44522537197278, 1.45971823971733, 1.47401401012578, 1.48809929035606, 1.50196367821462, 1.51559921109471, 1.52900107663852, 1.54216660353197, 1.5550946936694, 1.56778559787145, 1.58024206161631, 1.59246616999708, 1.60446241798237, 1.61623515256263, 1.6277895136788, 1.63913048246185, 1.65026272448572, 1.66119120826138, 1.67192117847526, 1.68245722468501, 1.69280480837492, 1.70296852990295, 1.71295281949093, 1.72276364578743, 1.73240541599026, 1.74188303497685, 1.75120138626003, 1.76036482936819, 1.76937853375415, 1.77824754652269, 1.78697561303618, 1.79556821706716, 1.80402894254375, 1.81236248801982, 1.82057312873887, 1.82866517275189, 1.8366317010579, 1.84448535974719, 1.85223437956147, 1.85988175704966, 1.86743216710123, 1.87489020709522, 1.88225899266416, 1.88954271455607, 1.89674532185353, 1.90387123546318, 1.91092387874021, 1.91790706239415, 1.92482573751064, 1.93168227941724, 1.93848164305175, 1.9452276783545, 1.95192374244991, 1.95857353251229, 1.96518281160841, 1.97175341983825, 1.9782900454899, 1.98479687919082, 1.99127750153894, 1.99773677421567, 2.00417793311796, 2.01060551046604, 2.0170233256773, 2.02343547276264, 2.02984749436382, 2.03626191085848, 2.04268353875561, 2.049114602113, 2.05556084771603, 2.06202287844052, 2.0685036548133, 2.07500332318476, 2.08152466608446, 2.08806765067701, 2.09463361199228, 2.10122238518265, 2.10783707036405, 2.11447432622988, 2.12113499884932, 2.12781424713384, 2.13451956963627, 2.14124951350918, 2.14800661022883, 2.15478765632886, 2.16159339682423, 2.1684271104748, 2.17528816557151, 2.18217362577078, 2.18908761935105, 2.19603002639163, 2.20300351368397, 2.21000319758685, 2.21703470694882, 2.22409898451505, 2.2311972221775, 2.23832781958321, 2.24549538117795, 2.2526987664562, 2.25994346481583, 2.26722888065824, 2.27455793921908, 2.28193411358852, 2.28935753459416, 2.29683236874686, 2.3043633905498, 2.31194745870387, 2.31959420135704, 2.32730538253537, 2.33508774151048, 2.34293887835729, 2.35086603625359, 2.35887211445266, 2.36696575744595, 2.37515092948982, 2.38342582596344, 2.39180677070733, 2.40028643357407, 2.40888278386229, 2.41759536090252, 2.42643775463242, 2.43540229532395, 2.44451132297608, 2.45375713864841, 2.46316480256067, 2.47272675848702, 2.4824616712993, 2.49238096112596, 2.50247621182259, 2.51278005644824, 2.52328459530469, 2.53400459669908, 2.54482080340439, 2.55569228691112, 2.56660276366681, 2.57754142971351, 2.58852482518397, 2.59954284066688, 2.61061488013636, 2.62171598016116, 2.63285030329271, 2.64404020662793, 2.65525905027419, 2.66651256824853, 2.6778079007294, 2.68915376033145, 2.70054028705822, 2.7119562393715, 2.72343228376484, 2.73493710925336, 2.74648102444296, 2.75805235043705, 2.76968764453411, 2.78135267969627, 2.79306102505984, 2.80482891692235, 2.8166185142729, 2.82844500757262, 2.84032661392745, 2.85225330543254, 2.86421363347959, 2.8762285042368, 2.88828754085377, 2.90037895881915, 2.91248939932882, 2.92468148368883, 2.93690801495623, 2.9491556390582, 2.96149548540931, 2.97383256600454, 2.98624067565195, 2.99866340382951, 3.01118335725144, 3.02369287827608, 3.03627804951518, 3.04893057785931, 3.06158415136629, 3.07427892426899, 3.08706261807415, 3.09986553992361, 3.11273641536514, 3.12559813082232, 3.13856985463709, 3.15157524789462, 3.16459965605965, 3.17770366601632, 3.1907987943681, 3.20394736944601, 3.21722278176947, 3.22842357616881, 3.24176833114294, 3.25512378677881, 3.26856595639597, 3.2820866712014, 3.29567642336465, 3.30921614709875, 3.32290298108548, 3.33662052652846, 3.35035255916578, 3.36408076000853, 3.37791285360432, 3.39184244115442, 3.40572446603041, 3.41981670509913, 3.43383179087081, 3.44789098701598, 3.46197960670245, 3.47624422758958, 3.49051829584613, 3.5047817650066, 3.51919309288275, 3.53356349271198, 3.54806006042791, 3.5624775690411, 3.57719953201365, 3.59181448730171, 3.60628635222813, 3.62103589912565, 3.63584052451261, 3.65068559075673, 3.66555440665079, 3.68042816483525, 3.69555904026841, 3.71067592274549, 3.72575410093648, 3.74076605300308, 3.75599484014451, 3.77144717971867, 3.7867934023843, 3.80199625298696, 3.81737457761158, 3.83293031529568, 3.84866317013457, 3.86417349493963, 3.87982169469459, 3.89560324156142, 3.91151251638117, 3.92708445960429, 3.94319976493462, 3.95892568992393, 3.97520292066274, 3.99102935641841, 4.00740962554074, 4.02383037958937, 4.03968828470414, 4.05609239283177, 4.07246729952653, 4.0887846867556, 4.10568188902212, 4.1225184203158, 4.13853906719252, 4.13853906719252]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_bssa14_1100 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Boore _et al._ (2014) GMM, for Vs30 = 1100 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_bssa14_1100 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_bssa14_1100()
fi = @SVector [0.001, 0.0999999942707916, 0.102329289439609, 0.104712887716761, 0.107151912555722, 0.109647810587833, 0.11220183402598, 0.114815390937559, 0.117489792298401, 0.120226418614101, 0.123026885991878, 0.125892533074394, 0.128824931825004, 0.131825679420567, 0.134896290548396, 0.138038407935955, 0.141253711030388, 0.14454397891139, 0.147910809014606, 0.151356098582797, 0.154881696694555, 0.158489297243423, 0.162180974138637, 0.165958674331861, 0.169824392157856, 0.173780066819787, 0.177827977607297, 0.181970093315908, 0.186208684639896, 0.190546064687612, 0.194984400298219, 0.199526151255418, 0.204173764851596, 0.208929596943051, 0.213796152899848, 0.218776165415316, 0.223872062165998, 0.229086795091157, 0.234422839210589, 0.239883288165173, 0.245470839468972, 0.251188557388039, 0.25703952116282, 0.263026714586751, 0.269153406683434, 0.275422798880656, 0.281838241124289, 0.288403025855549, 0.295120803536784, 0.301995173753911, 0.309029502480207, 0.316227782943992, 0.323593500466634, 0.331130953508207, 0.338844036623896, 0.34673675462895, 0.354813392739313, 0.363078026106895, 0.371535181708974, 0.380189334311823, 0.389045073797216, 0.398107089497488, 0.407380173586767, 0.416869210701438, 0.426579417203211, 0.43651559882169, 0.446683401771556, 0.457088029401324, 0.467735011805406, 0.478629925081276, 0.489778715181216, 0.501187031937496, 0.512861236791132, 0.524807370945154, 0.537031434094109, 0.549540627902458, 0.562340918238859, 0.575439503820714, 0.588843301006728, 0.602559271619929, 0.616594838924024, 0.630956918926108, 0.645653987282243, 0.660693278719166, 0.676082386262125, 0.691830704330551, 0.707945463071725, 0.724435696155354, 0.74131024499222, 0.758576833362888, 0.776246967350283, 0.79432765983909, 0.812829847543139, 0.831763295436004, 0.851137257381919, 0.870963647695458, 0.89125063310826, 0.912010190336213, 0.933253876719992, 0.954991323260685, 0.977236674564363, 0.999999376704014, 1.02329216650515, 1.04712858016108, 1.07151802029997, 1.09647705386315, 1.12201813106039, 1.14815232082574, 1.17489711452937, 1.2022632761053, 1.23026893465442, 1.25892478169571, 1.28824925286246, 1.31825476678541, 1.34896226936176, 1.38038331625282, 1.41253536157361, 1.44544002786044, 1.47910755205328, 1.51355783588285, 1.54881556831327, 1.58489238265031, 1.62180711433383, 1.65958346288574, 1.69824231541703, 1.73780089595023, 1.77827646757433, 1.81969641187082, 1.86208481433417, 1.90545626586434, 1.94984475199332, 1.99526162858629, 2.04173373924813, 2.08929105688858, 2.13796119637597, 2.18776046050659, 2.2387215306585, 2.29086418676164, 2.34422580916097, 2.3988291206262, 2.45470634410607, 2.51188114589687, 2.57038711926446, 2.63025902311945, 2.69153260246708, 2.75421969068968, 2.81837995348003, 2.88402365216443, 2.95119935757395, 3.01994331510937, 3.09029180950475, 3.16226398102817, 3.23592925568545, 3.31130709484967, 3.38843294207687, 3.46736315436668, 3.54813581847585, 3.6307651436782, 3.71533568298211, 3.80188946845371, 3.89044115666823, 3.98105964067485, 4.07378964803908, 4.16867752173957, 4.26577171067028, 4.36516053182719, 4.4668254158747, 4.57086030476262, 4.67732851465, 4.78629925533731, 4.89774978439209, 5.01185370947343, 5.12859423484337, 5.24805927489683, 5.37028645796196, 5.49537951621125, 5.6233878102801, 5.75436328712337, 5.88843917410242, 6.02560553448902, 6.16592821030288, 6.30957217415461, 6.45653608003565, 6.60691210897118, 6.760804602669, 6.91833243844884, 7.07938781287924, 7.24434482940889, 7.41310826719381, 7.58569409562697, 7.76241731627088, 7.94317188337215, 8.12832595039509, 8.3176023537528, 8.51140752074882, 8.70962908279862, 8.91253998805093, 9.12001705818987, 9.33259809073417, 9.54976840803428, 9.77223833172881, 10.0000154584674, 10.23300524141, 10.4710754835424, 10.7150266728374, 10.9647907700409, 11.2202630001957, 11.4812971912249, 11.7489102165068, 12.0226227359966, 12.3027246006294, 12.5890770378463, 12.8824938912425, 13.1823630974293, 13.4895877351951, 13.8034850183452, 14.1250621277036, 14.4542171297727, 14.7907986463695, 15.1353290208207, 15.4876534354551, 15.8483711149959, 16.2181900174972, 16.5961299741433, 16.9819204095141, 17.37824271703, 17.7830169525712, 18.1970367629386, 18.6200661560741, 19.0542962143714, 19.4984106230298, 19.952167919195, 20.4166708483612, 20.8932695398002, 21.3786496995455, 21.8773864462395, 22.3877335357594, 22.90750432443, 23.4421462082247, 23.9875431882539, 24.4595049310709, 25.0319269878903, 25.6166097703306, 26.2130779475033, 26.8263113471932, 27.4535149251717, 28.0943122232752, 28.7514900856313, 29.4214814188544, 30.1071964789614, 30.8121657464104, 31.5324826105913, 32.2675988220233, 33.0213566963618, 33.7936159040409, 34.579074170418, 35.3872354433233, 36.2127668867604, 37.0609573167903, 37.9256441289802, 38.8124796011373, 39.7213308469351, 40.6445318091086, 41.5961301188189, 42.5685278399345, 43.5610008566936, 44.5726281197036, 45.6216075347537, 46.6789911567352, 47.773980830181, 48.8853621422687, 50.0351078965322, 51.1992803651972, 52.3886636425958, 53.6164785697481, 54.8689227094684, 56.1447051106333, 57.4588446996262, 58.8120630745198, 60.1679954909794, 61.5799079121313, 63.0304154891204, 64.497885722967, 66.0018126389695, 67.5418009953363, 69.117236380239, 70.7272485242521, 72.3706846807164, 74.0761580253903, 75.8148416156396, 77.5847393108404, 79.3834328727271, 81.245390419232, 83.1336688348237, 85.0861844185969, 87.0612501896228, 89.1005448083237, 91.1570157956521, 93.3280977544332, 95.4597653710987, 97.7091485760571, 99.9714285714285, 1e3]
Ai = @SVector [1.0, 1.07377424172191, 1.07568340471177, 1.07764765689837, 1.07966876479455, 1.08174881857823, 1.08388980782557, 1.08609391640319, 1.08836331477285, 1.09070030404772, 1.09310746523746, 1.09558722513272, 1.0981422996958, 1.10077552311629, 1.10348975891098, 1.10628809163659, 1.10913843677795, 1.1119862441656, 1.11482032357681, 1.11763348969258, 1.12041986774419, 1.12317468498611, 1.12589456554055, 1.12857701666666, 1.13122044460195, 1.13382399537393, 1.13638771748597, 1.13891205161871, 1.14139812609109, 1.14384729457583, 1.14626080510911, 1.14864002376794, 1.15098626482962, 1.15330074743668, 1.15558472198198, 1.15783950909849, 1.16006624659493, 1.16226627242009, 1.16444066637276, 1.16659074938093, 1.16871763839306, 1.17082256875985, 1.17290674545382, 1.17497098881197, 1.17701661304444, 1.17904472323173, 1.1810564402846, 1.18305283340685, 1.18503506676802, 1.18700424346501, 1.1889613920927, 1.19090768763071, 1.19284414873617, 1.19477198498936, 1.19669227954613, 1.19860612604854, 1.20051467448373, 1.2024189984736, 1.20432027155042, 1.20621964116529, 1.20811825260841, 1.21001727350919, 1.21191787262328, 1.21382122429834, 1.2157285626702, 1.21764102751111, 1.21955990799381, 1.22148640147232, 1.22342175358253, 1.22536721997457, 1.22732410176577, 1.22929364971439, 1.23127722537588, 1.23327612965734, 1.23529166096294, 1.23732531195325, 1.23937836912328, 1.24145231559765, 1.24354749289177, 1.24566554333833, 1.24780897539437, 1.2499792569878, 1.25217809355537, 1.25440701343445, 1.2566676191693, 1.25896178257908, 1.26129108887827, 1.26365739381181, 1.26606255846768, 1.26850829677884, 1.27099689683087, 1.27353004434842, 1.27611001171338, 1.27873893586496, 1.28141893992751, 1.28415254235385, 1.28694181625922, 1.28978939335592, 1.2926979191094, 1.29566982523915, 1.29870824175611, 1.30181572532181, 1.30499534613735, 1.30825038999295, 1.31158365403668, 1.31499901534591, 1.31849988955826, 1.32208961620671, 1.32577251378186, 1.32955179855246, 1.33343132606967, 1.33741357887289, 1.34150179466669, 1.34569812166275, 1.35000567098599, 1.3544260520849, 1.35896154743919, 1.36361490236401, 1.36838718131483, 1.37328072536624, 1.37829854584582, 1.38344177665736, 1.38871258893308, 1.39411388408896, 1.39964824530506, 1.40531779136425, 1.41112476128775, 1.41707296818823, 1.423165914765, 1.42940562445159, 1.43579526073916, 1.44233948342952, 1.44904300900007, 1.45591026098732, 1.46294377577838, 1.4701430068133, 1.47750842207663, 1.48503741802188, 1.49272885060967, 1.50057846594505, 1.50858248846468, 1.51673514116072, 1.52503138142624, 1.53346570997836, 1.54203225573951, 1.55072136469112, 1.55952965490261, 1.56844664272352, 1.57746682872857, 1.5865828595448, 1.59578726004598, 1.60507023827321, 1.61442848210392, 1.62385227018904, 1.63333398385059, 1.64286864207467, 1.65244910763165, 1.66206559908029, 1.67171669047243, 1.68139615123491, 1.69109489130831, 1.70081005746505, 1.7105363237882, 1.72026875507274, 1.73000284207063, 1.73973826625622, 1.74946440275484, 1.75918182984198, 1.76888828501048, 1.77858223152089, 1.7882542429275, 1.79791222543811, 1.80754789891303, 1.81716203507685, 1.82675150733127, 1.83631855455804, 1.84586136433489, 1.85537854764995, 1.8648747408499, 1.87434449935178, 1.88378803080827, 1.89321224044973, 1.90261311295528, 1.91199291860342, 1.92135475667402, 1.93070261245488, 1.94002726561405, 1.94934764561085, 1.95865579899324, 1.96795051189792, 1.97724668214133, 1.98653689629335, 1.99583838905708, 2.00513582401076, 2.01444803976094, 2.02376863922482, 2.03310968744784, 2.04246501089894, 2.05181609311956, 2.06121173032725, 2.07066458274414, 2.08015734029654, 2.08968114874409, 2.09922590184368, 2.10881876661101, 2.11845189129642, 2.12811625143497, 2.1378015484207, 2.14754048090738, 2.15731038499326, 2.16711663195644, 2.17694945369856, 2.18683162558877, 2.19673745095695, 2.2066916515308, 2.21666701444773, 2.22669041520284, 2.23675336485491, 2.24684609768205, 2.25697912727245, 2.26714268360788, 2.27734887295641, 2.28761212076916, 2.29789987370863, 2.30819997235961, 2.31857847380772, 2.32897531728647, 2.3394058792482, 2.3498590462889, 2.36038337973389, 2.37094068336684, 2.38151809194227, 2.3921384760639, 2.40282679650948, 2.4135035480742, 2.42426389889233, 2.43506415004308, 2.44585309227987, 2.45673813861894, 2.46762963485226, 2.47687509577523, 2.48790470398334, 2.49895459013647, 2.51001074938325, 2.52115955775645, 2.53234387408955, 2.54355153871219, 2.55482544462744, 2.56609879830649, 2.57741526963207, 2.58882656935048, 2.60026315087013, 2.61171104942407, 2.62322430649175, 2.63479438821278, 2.64633662881618, 2.65798476086959, 2.66965548300257, 2.68141714192981, 2.6931782663281, 2.70500988439125, 2.71690361145269, 2.72875549295849, 2.74073817576405, 2.7527489711529, 2.76477328510593, 2.77679473796317, 2.78902190862775, 2.80111149742784, 2.81339155369115, 2.82561739127939, 2.83802390290198, 2.85034656746604, 2.86269510132692, 2.87519926745502, 2.88771129849868, 2.90021311182686, 2.91284514811118, 2.92560594571757, 2.93814853329408, 2.95095963812371, 2.96387158874595, 2.97668665984961, 2.98957013452994, 3.00251182166991, 3.01549984515371, 3.02852071664694, 3.04155909263268, 3.05483342147564, 3.06811110345284, 3.08137173364153, 3.09459254417313, 3.10801932770893, 3.12137858766394, 3.13493150812508, 3.14838227829193, 3.16200828231978, 3.17548946061531, 3.18945462042179, 3.20290819766718, 3.21683654256236, 3.23041469686689, 3.23041469686689]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_cb14_620 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Campbell & Bozorgnia (2014) GMM, for Vs30 = 620 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_cb14_620 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_cb14_620()
fi = @SVector [0.001, 0.0999999960075922, 0.102329291970146, 0.104712897083861, 0.107151915826179, 0.109647820193404, 0.112201826611791, 0.11481539188404, 0.117489781977474, 0.120226413052329, 0.123026878155944, 0.125892534108239, 0.12882492604089, 0.131825673462998, 0.134896299505685, 0.138038403078452, 0.141253717665068, 0.144543977586134, 0.147910828038878, 0.1513561097844, 0.154881688910334, 0.158489270249457, 0.162180956299533, 0.165958652768952, 0.169824403593973, 0.17378007921449, 0.177827963368866, 0.181970051450291, 0.186208690172977, 0.190546100984621, 0.194984442453321, 0.199526172070992, 0.204173806745097, 0.208929601318305, 0.213796149585515, 0.218776122992034, 0.223872028310857, 0.229086734657301, 0.234422921222406, 0.23988324885248, 0.245470785537473, 0.251188484278206, 0.25703946055711, 0.263026674560631, 0.269153407076944, 0.275422773948591, 0.281838261914018, 0.288402967980864, 0.295120835838376, 0.301995143474081, 0.309029499502454, 0.31622766697645, 0.323593638658402, 0.331131118022553, 0.338844074067532, 0.346736845850547, 0.354813149043298, 0.363078172132964, 0.3715349775957, 0.380189376407706, 0.389044877600162, 0.398107205333068, 0.407380389280958, 0.416869425800305, 0.426579396739984, 0.436515457062149, 0.446683422598966, 0.457087947174548, 0.467734897047422, 0.478630212709465, 0.489778263708941, 0.501187178344085, 0.512861085254938, 0.524807227283619, 0.537031938860528, 0.549540293640881, 0.56234113214465, 0.575439992722043, 0.588842984739594, 0.602559388702931, 0.61659446082985, 0.630956660969879, 0.64565404595163, 0.660692477482551, 0.676083233360251, 0.691830448958141, 0.707945639355109, 0.724436060249336, 0.741309595360551, 0.758577006429437, 0.776245814931473, 0.794326521676393, 0.812830781572186, 0.831763706566927, 0.851138659821746, 0.870961957609269, 0.891249239427603, 0.91200862589844, 0.933252340414934, 0.954990587903553, 0.977234624287875, 1.00000079350021, 1.02329093361383, 1.04712770534758, 1.07151859370928, 1.09647590648705, 1.12201792525089, 1.14815429506382, 1.17489476400895, 1.2022611083602, 1.23026524717676, 1.25892597737345, 1.28825017880555, 1.31825834042905, 1.34895940575925, 1.38038211863746, 1.41253579162943, 1.44543802508952, 1.47910766627126, 1.51355508362719, 1.54881083941909, 1.58488860908463, 1.62180200826005, 1.65958603883503, 1.69824394199126, 1.73780316909269, 1.77828002289597, 1.81969123986389, 1.86208484018179, 1.90545082777332, 1.94984212098705, 1.99526550027925, 2.04172582192457, 2.08928518503298, 2.13795270811858, 2.18775757035363, 2.23870838137221, 2.29086039430598, 2.34422567655106, 2.39881473984119, 2.45469305825437, 2.51187628530218, 2.57037914400445, 2.63024799909587, 2.69154184700609, 2.75420699435402, 2.81836339944471, 2.88403732099006, 2.95121327088087, 3.01995632802365, 3.09029370438711, 3.16225327413674, 3.23591509294214, 3.31131632426641, 3.38843926600486, 3.46737644862356, 3.54810871326601, 3.63073920182982, 3.71532481633097, 3.80191715301573, 3.8904168412904, 3.98102517597589, 4.07381013041093, 4.16866930569122, 4.2657516979992, 4.36513308947507, 4.46679458151173, 4.57081398335729, 4.67727807509726, 4.78628382607805, 4.8978150175713, 5.01184374683731, 5.12860406183254, 5.24811501763448, 5.370354782551, 5.49541292766055, 5.62344224121309, 5.75440929301849, 5.88845028920835, 6.02552436197588, 6.16598535533968, 6.30959896434349, 6.45652784724631, 6.60695947044187, 6.76085595082843, 6.91816011314, 7.07935425017163, 7.24441981839727, 7.41300823943585, 7.58566898806598, 7.76236722449045, 7.94340960477486, 8.1283883699323, 8.31760068839723, 8.51139597978318, 8.70973668407653, 8.91256157472234, 9.12027591191496, 9.33231580217011, 9.54962715813997, 9.77218973081615, 9.99995871260699, 10.2328608720273, 10.4714644143944, 10.7150241702049, 10.9648567889945, 11.2201869719567, 11.4817058148805, 11.7484937722766, 12.0221659434902, 12.3027358475711, 12.5891758955214, 12.8823542344927, 13.1821839463439, 13.489720878884, 13.8037291969212, 14.1253071115601, 14.4543872700214, 14.79086154007, 15.1361059392185, 15.4885379957005, 15.847907430289, 16.2174688117694, 16.5955044741655, 16.9818658755626, 17.3784310156056, 17.7830619796974, 18.1977471964094, 18.6200176357248, 19.0545238754325, 19.4988048035604, 19.9526560907815, 20.4158065492293, 20.8910452127662, 21.3784189555268, 21.8779299082402, 22.3858674720414, 22.9092727160828, 23.4404201902772, 23.9869860567893, 24.4596396776056, 25.033196582825, 25.6177357509289, 26.2127288715371, 26.8284448979696, 27.454199013626, 28.0951754246842, 28.7512564075941, 29.4222442059403, 30.1078484229437, 30.807682121848, 31.5290964772775, 32.2643964180019, 33.0215786275117, 33.7919505340467, 34.5842004039283, 35.3885014295223, 36.2142816944529, 37.0616880861435, 37.9308016109299, 38.8091308114225, 39.7209573241117, 40.6403219683072, 41.5939194340003, 42.5680815430318, 43.5622048396415, 44.5755162204328, 45.6249575267801, 46.6744166561296, 47.7792678540101, 48.881282995356, 50.0196194346816, 51.1955716818627, 52.3860799284434, 53.6143917622613, 54.8816520551667, 56.1605432543999, 57.4478309651699, 58.8028448839455, 60.1646294174391, 61.5638001377288, 63.03757035448, 64.4757104760039, 65.9891828579598, 67.541089429508, 69.1313510023053, 70.7121318222854, 72.3758936550096, 74.076537038047, 75.8131413932449, 77.5844999532611, 79.3891069111205, 81.225118605628, 83.1585169339083, 85.0534289506107, 87.0474892610037, 89.0690364359942, 91.1982199782074, 93.2671864620731, 95.4439739205107, 97.7371972733264, 99.9502534854245, 1e3]
Ai = @SVector [1.0, 1.57033405486421, 1.57928537133846, 1.5882443552979, 1.59719965835096, 1.60615037691665, 1.61509589890235, 1.62403759131615, 1.63297715737857, 1.64191774399028, 1.65086388085234, 1.65982006375264, 1.66879202990905, 1.67778637671133, 1.68680976820965, 1.69586826072783, 1.70496711026745, 1.71411049690332, 1.7233013788726, 1.73254246374991, 1.74183579026946, 1.75118236586368, 1.7605837096383, 1.77004039615484, 1.77955290426151, 1.78912098882984, 1.79874517521443, 1.80842472278825, 1.81815838538661, 1.8279431990001, 1.83777482204266, 1.847648503946, 1.85755867843565, 1.86749840056441, 1.87746076155485, 1.88743842572507, 1.89742324314167, 1.90740740560039, 1.91738236364302, 1.92733937216075, 1.93727021584822, 1.94716638283987, 1.95701954525294, 1.96682109681485, 1.97656301068436, 1.9862370314421, 1.99583558310959, 2.00535062368774, 2.0147754565186, 2.02410291471308, 2.0333271817398, 2.04244361570107, 2.05144870568788, 2.06033931876222, 2.06911334678662, 2.0777696281856, 2.08630686305669, 2.09472576134762, 2.10302521344491, 2.11120721842349, 2.11927181347662, 2.12722134686463, 2.13505684751389, 2.14278036248588, 2.15039416362452, 2.15790068229876, 2.16530297151385, 2.17260321315676, 2.17980459911455, 2.18691032613591, 2.19392264524007, 2.20084615356824, 2.20768298715709, 2.21443711451096, 2.22111186161534, 2.22770982191876, 2.23423547911001, 2.24069159042248, 2.24708108770116, 2.25340840278104, 2.25967593176321, 2.26588752258148, 2.27204672331724, 2.27815610589955, 2.28422037781563, 2.2902413531033, 2.29622360202804, 2.30217007026641, 2.3080838666615, 2.31396904022813, 2.31982851395299, 2.32566610644972, 2.33148596514866, 2.33729013362996, 2.34308321614512, 2.34886759750601, 2.35464841876891, 2.3604284216875, 2.36621096026657, 2.37199820664638, 2.37779200513412, 2.38359500514961, 2.38940563224986, 2.39522716042303, 2.40105877713631, 2.40690047817613, 2.41275338473018, 2.4186163420362, 2.42448810932507, 2.43036984728744, 2.43626037019897, 2.44215988899846, 2.44806594190473, 2.45397887637024, 2.45989462958907, 2.46581733300886, 2.47174498373146, 2.4776771502338, 2.48361352566415, 2.48955235871665, 2.49549539168965, 2.50144029099867, 2.50738476075224, 2.51333259842791, 2.51928106312458, 2.52523129344264, 2.53118274865988, 2.5371349827321, 2.54309212911242, 2.54905001572751, 2.5550133144793, 2.56098043050294, 2.56694957836074, 2.57292648938209, 2.57890996786651, 2.58490147540621, 2.59089995904754, 2.59691000574735, 2.60293102740605, 2.60896245116745, 2.61500977726282, 2.62107303848077, 2.6271522095401, 2.63325068832288, 2.63936831634584, 2.64550058510771, 2.65166151868542, 2.65785253051351, 2.66407117592585, 2.67032266126765, 2.67660876019877, 2.6829313842409, 2.68929710317829, 2.69570878361406, 2.70216475706617, 2.70867278351802, 2.71523137759699, 2.72184913944897, 2.72852724055432, 2.73527126533899, 2.74207639150456, 2.74895873025397, 2.75592417006905, 2.76296587824797, 2.77009595428481, 2.77732099249509, 2.78464089712506, 2.79206268905525, 2.79959408419579, 2.80724358071353, 2.81501183363214, 2.82289893456872, 2.83092330320293, 2.83907582550249, 2.84730018640715, 2.85555328637664, 2.86383095493905, 2.87212663469594, 2.88044452184487, 2.88877774715998, 2.89714331231447, 2.9055228463282, 2.91392149979111, 2.92234551866876, 2.93078838320923, 2.93924265146354, 2.94772982803101, 2.95624421000921, 2.9647634804854, 2.97331109764328, 2.98188075759158, 2.99048268860332, 2.99909303455435, 3.00772136112323, 3.01637899018538, 3.02505962628115, 3.0337560497031, 3.04248113777928, 3.0512068177085, 3.05996757109523, 3.06875768335127, 3.07757061462058, 3.08639905796099, 3.09525984142472, 3.10412083889499, 3.11302529099264, 3.12194082614448, 3.13088687907477, 3.13982764732355, 3.14881265843947, 3.15783705140395, 3.16686309421443, 3.17591375916796, 3.18498164952413, 3.19409373759506, 3.20320853771863, 3.21235342726676, 3.22152158334157, 3.23070531974662, 3.23993702000599, 3.24916962731165, 3.25839259184477, 3.26768430453487, 3.27699608714072, 3.28631970927527, 3.29569529879741, 3.30506739375089, 3.31447732989456, 3.32386468982047, 3.33332789297788, 3.34280760438601, 3.3522949155104, 3.36177981099647, 3.37131453562767, 3.38089422257278, 3.39051328314514, 3.40009606457532, 3.40977020114658, 3.41938819505795, 3.42908426997333, 3.43729703928329, 3.44708996317642, 3.45687126433619, 3.46662471908397, 3.47651254297438, 3.48635738496203, 3.49623660010644, 3.50614293449502, 3.5160682080079, 3.52600342040139, 3.53593824695989, 3.54597106668068, 3.55598908309274, 3.56609567812751, 3.57616939738255, 3.58631878730317, 3.59641309240748, 3.60656607584072, 3.61677334812992, 3.62702952128797, 3.6371837435942, 3.64751090270576, 3.6577117152396, 3.66807717840373, 3.67845146777531, 3.68882335291022, 3.6991805679675, 3.70968940062124, 3.71998474093807, 3.73060326020412, 3.74097956442553, 3.75147967527224, 3.76210655840206, 3.77264675104285, 3.78330083425741, 3.79407041521322, 3.80471878819626, 3.8152187962405, 3.82604651276174, 3.83670771854379, 3.8474388315386, 3.85851371609353, 3.86910186430903, 3.88001792479987, 3.89098475034529, 3.90199566072941, 3.91271860783396, 3.92377506043213, 3.93484827303173, 3.94592700775264, 3.95699898517208, 3.96805033005292, 3.97906573257979, 3.99043107177771, 4.00134459652396, 4.0125958139824, 4.02377110140484, 4.03530425374715, 4.04628442747604, 4.05760168138967, 4.0692845999532, 4.08033135924049, 4.08033135924049]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_cb14_760 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Campbell & Bozorgnia (2014) GMM, for Vs30 = 760 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_cb14_760 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_cb14_760()
fi = @SVector [0.001, 0.100000014603706, 0.102329318159967, 0.104712915012989, 0.107151944005561, 0.109647834841026, 0.112201860006149, 0.114815417052971, 0.117489816119846, 0.120226465083992, 0.123026917598311, 0.12589255847292, 0.128824980611895, 0.131825718608755, 0.13489631959351, 0.138038448458978, 0.141253778162648, 0.144544046818743, 0.14791085550833, 0.15135613998006, 0.154881728490947, 0.158489361043098, 0.162181066114414, 0.165958739473193, 0.169824462314567, 0.173780134007044, 0.177828057012465, 0.181970178254594, 0.186208750403258, 0.190546170351366, 0.194984503373748, 0.199526253525846, 0.204173881532292, 0.208929659763176, 0.213796267563971, 0.218776303013584, 0.223872214384926, 0.229086862026185, 0.23442302280373, 0.239883411745978, 0.245470999998042, 0.251188676985345, 0.257039624252806, 0.263026937897839, 0.269153625701278, 0.27542302191172, 0.281838464424222, 0.288403301147695, 0.29512107452525, 0.301995393129344, 0.30902977845631, 0.316228002125454, 0.323593765761453, 0.331131283999689, 0.338844310340282, 0.346736913437449, 0.354813558809766, 0.363078396657601, 0.371535418861104, 0.380189571348915, 0.389045434107864, 0.398107399490668, 0.407380657208765, 0.416869685071214, 0.42657993322434, 0.436516004536019, 0.446683859270794, 0.457088421802735, 0.46773557493424, 0.478630341437807, 0.489779219952398, 0.501187729749159, 0.51286184118858, 0.524808020308976, 0.537032011051797, 0.549541310846063, 0.562342002103819, 0.575440541048431, 0.588843839501076, 0.60256016086967, 0.616595892595373, 0.630957770918203, 0.64565488528681, 0.660694099005814, 0.676083721255284, 0.691831588655876, 0.707947245243919, 0.724437261196506, 0.741311001398856, 0.758578542847393, 0.77624787433371, 0.7943289003767, 0.812832326143451, 0.83176463922089, 0.851139588339233, 0.87096487176409, 0.89125241684504, 0.912013175488765, 0.933256759031112, 0.954993351540294, 0.977238752862432, 1.00000281507724, 1.02329589536783, 1.04713183702237, 1.07151977051983, 1.09647863942794, 1.12201969918408, 1.14815484858075, 1.17490036562259, 1.20226644031, 1.23027166414146, 1.25892824290883, 1.28825410786601, 1.31826027308295, 1.3489636293766, 1.38038825747881, 1.41253934332401, 1.44544429134379, 1.47910969949534, 1.51356676547177, 1.5488237651326, 1.58489501625938, 1.62181751695932, 1.65959380063872, 1.6982485957995, 1.73780868148322, 1.77828487949496, 1.81970612142534, 1.86209381862123, 1.90547035876538, 1.94984787932165, 1.99527276508788, 2.04174773586109, 2.08929818858466, 2.1379648707227, 2.18776405288898, 2.23872658201823, 2.29086951510372, 2.34424314082561, 2.39885056394356, 2.45470985693216, 2.51189788648169, 2.57039937860281, 2.63027865661929, 2.69153980303586, 2.75423167942888, 2.81840878980984, 2.88405112983486, 2.95121458203317, 3.01996235953973, 3.09030294817901, 3.16230771221273, 3.23595279682673, 3.31131420269854, 3.38847875979375, 3.46738234844352, 3.54815630214939, 3.63081856141197, 3.71538457921618, 3.80191738456751, 3.89048765512902, 3.9811191290653, 4.07383423833312, 4.16871555438765, 4.26585690197907, 4.36516008275251, 4.46685890411257, 4.57092745527101, 4.67740612206366, 4.78633645892996, 4.89784971892356, 5.01191184077053, 5.12866862527161, 5.24808342973394, 5.37031988154554, 5.49545434590912, 5.62345032003805, 5.75450629367736, 5.88845682702725, 6.02564882727567, 6.16605471650829, 6.30963041580404, 6.45668342983238, 6.60703911972332, 6.76082665306519, 6.91837183250296, 7.07962072387972, 7.24449391639376, 7.41310687103337, 7.58582639814176, 7.76259086720391, 7.9433108188294, 8.12841975058345, 8.3178495102927, 8.51150146777084, 8.70989612339629, 8.91262221663962, 9.12025383033394, 9.33271197764874, 9.54988323105152, 9.7724721984205, 9.99996812811373, 10.2331611680284, 10.4714887348519, 10.7153094829665, 10.9650477156109, 11.2206102509667, 11.4818638675441, 11.7492897173357, 12.0227614826089, 12.3028436308968, 12.5894276885153, 12.8823599384561, 13.183168411495, 13.4900328731246, 13.8045707148106, 14.1256810079244, 14.4552285070842, 14.7909197203426, 15.1359344891696, 15.4890678426225, 15.8488063029024, 16.2189403486686, 16.5966169802554, 16.9830373797447, 17.3779909265311, 17.7829518929512, 18.1978387440727, 18.6205542822369, 19.054714481358, 19.4981687206825, 19.9528554447325, 20.4186812309659, 20.892918427583, 21.3803477657443, 21.8781975901788, 22.3890774682986, 22.9097567367247, 23.4429911673855, 23.9885714919413, 24.4601011242133, 25.0325539431898, 25.6166830021738, 26.2163678794803, 26.8269705537117, 27.4525567236701, 28.0980792478464, 28.7531530453907, 29.4222858562447, 30.1110072308346, 30.8131796776573, 31.534781791216, 32.26876583596, 33.0215757243594, 33.793093567672, 34.5830953354176, 35.3912379831092, 36.2170412322082, 37.0598739432464, 37.9294021644798, 38.8152454026809, 39.7162806545213, 40.6434811545621, 41.5971967887437, 42.5639610481806, 43.5707930432651, 44.5893263185931, 45.617083905354, 46.6853663549747, 47.7782634755642, 48.8951335569009, 50.0351265950035, 51.1971650151556, 52.4023375999969, 53.6289101690096, 54.8751195274679, 56.1652603104612, 57.4731641472552, 58.8255726590189, 60.1929261276225, 61.6046338578044, 63.0272953425698, 64.4932276749624, 66.0033220481268, 67.558393760812, 69.1160679775367, 70.761078527248, 72.4046872926073, 74.0902793585822, 75.8175739578802, 77.5860562396035, 79.3949372542713, 81.2431323797365, 83.1292864603112, 85.1218876134366, 87.0813329925696, 89.1504849158889, 91.1729673616224, 93.3072493997223, 95.4704730122531, 97.7555535899792, 100.06993006993, 1e3]
Ai = @SVector [1.0, 1.32056069012663, 1.32603400047941, 1.33153115429065, 1.33704192096276, 1.34256105272891, 1.34808429250704, 1.35360891684945, 1.3591331271623, 1.36465634908849, 1.37017920927597, 1.37570278846732, 1.38122931992161, 1.38676157440047, 1.39230292960457, 1.3978573940284, 1.40342899645319, 1.40902181854226, 1.41463965646993, 1.42028685431035, 1.42596752147355, 1.43168565135368, 1.43744569958573, 1.44325194656313, 1.44910894930871, 1.45502037208018, 1.46098871709202, 1.46701423830498, 1.47309610841515, 1.4792322941317, 1.48541907997794, 1.49165227506658, 1.49792662436597, 1.50423577746584, 1.51057319564515, 1.51693156350907, 1.5233028433285, 1.52967904845444, 1.53605176524847, 1.54241298337792, 1.54875602626771, 1.55507511477207, 1.56136568270716, 1.56762385269554, 1.57384639125894, 1.58003107047782, 1.58617624104497, 1.59228080478892, 1.59834428373847, 1.60436669894146, 1.61034833855344, 1.61629007677353, 1.62219297364697, 1.62805880524461, 1.63388915306101, 1.63968607693572, 1.6454520901278, 1.65118961694146, 1.65690111890984, 1.66258981922363, 1.66825878629818, 1.67391107830085, 1.67955023403617, 1.68517890218943, 1.69079974948912, 1.69641437838303, 1.70202471010731, 1.70763166851762, 1.71323631309792, 1.71883895859837, 1.72444036202574, 1.73004057600699, 1.73563963802825, 1.74123765381658, 1.74683425086243, 1.75242969974443, 1.75802350982855, 1.7636153048555, 1.76920481084361, 1.77479224587072, 1.78037702574427, 1.78595866540977, 1.79153755443377, 1.79711323880513, 1.80268579842259, 1.80825510826782, 1.81382167385918, 1.81938506363411, 1.82494595688218, 1.83050542748661, 1.83606399854169, 1.84162298907452, 1.84718406429254, 1.852747728261, 1.85831676939687, 1.86389228560237, 1.86947671242034, 1.87507227354385, 1.88068091427872, 1.88630483353614, 1.89194774475376, 1.89761189731552, 1.90329977019013, 1.90901476642492, 1.9147592278953, 1.92053788888662, 1.92635372575522, 1.93220991902594, 1.9381107690584, 1.94405923379357, 1.950060256213, 1.95611727020876, 1.96223429816703, 1.96841298305583, 1.97465537155953, 1.98096419972217, 1.98733776515465, 1.9937782279461, 2.00028311901377, 2.00685433181804, 2.0134889397255, 2.02018492074876, 2.02694410658894, 2.03376179348014, 2.04063710890531, 2.04756937194912, 2.05455497856335, 2.06159336288426, 2.06868261205738, 2.07582086545397, 2.0830046205529, 2.09023590329493, 2.0975097114807, 2.10482473610792, 2.1121819717276, 2.11957875797072, 2.12701462950716, 2.13448719883305, 2.1419988887457, 2.14954551624292, 2.15712513438802, 2.16474387518341, 2.17239548283667, 2.18008437807076, 2.18780727810779, 2.19556666765425, 2.20336574388772, 2.21119878208701, 2.21906941973291, 2.22698205773577, 2.23493480695697, 2.24293300965878, 2.25097155398781, 2.25905654209919, 2.26719527668687, 2.27537932962888, 2.28362096166113, 2.29192080670653, 2.30027952855885, 2.30870270580237, 2.31719669394349, 2.3257634597216, 2.33440500590197, 2.34312913380319, 2.3519446901907, 2.36084323440092, 2.36984638829516, 2.37895267180433, 2.38816669309536, 2.3974934303111, 2.40694575307286, 2.41652262380314, 2.42623847874389, 2.43609278812133, 2.44610183134625, 2.45627494375819, 2.46661267459907, 2.47713485083718, 2.48783244747041, 2.49873779400636, 2.50985379201636, 2.52118247263782, 2.53273926231377, 2.54440279665817, 2.5561160609005, 2.56788748643363, 2.57970669214853, 2.59156182988486, 2.60345523756733, 2.61540659871786, 2.62740531921539, 2.6394392357933, 2.65153103963213, 2.66366987863253, 2.67584337963277, 2.68807792889929, 2.70034186549141, 2.71266375198116, 2.72503238119288, 2.73743498722108, 2.74990532665102, 2.76240829303884, 2.77498078554551, 2.78758597969827, 2.80023652556741, 2.8129478327389, 2.82570852837824, 2.83850546334257, 2.85135577225083, 2.86424685261516, 2.87719856224376, 2.89019917903797, 2.90323515645431, 2.91636738285546, 2.92950965958332, 2.94272471175322, 2.9559595897534, 2.96928421491422, 2.98259927045833, 2.99602405710977, 3.00950399150925, 3.02297516196798, 3.03657236069564, 3.05018336872153, 3.06384496491314, 3.07754284824993, 3.09132098863743, 3.10516899701852, 3.11901029556148, 3.13295621206184, 3.14693022663014, 3.1609861656685, 3.17511338319784, 3.18922267849747, 3.20344899745745, 3.21770382372386, 3.23205424552593, 3.24640249313657, 3.26081762014288, 3.27528649552171, 3.28754788245527, 3.30219388807186, 3.31686139493491, 3.33163320089763, 3.3463878501201, 3.36121668688659, 3.37622764355535, 3.39117157622034, 3.40614554704339, 3.42126474829806, 3.43638635248179, 3.45163103083242, 3.46684254774001, 3.48214729260749, 3.49753420443772, 3.51299048002675, 3.52850132810062, 3.54404996064957, 3.55961726221174, 3.57537260062747, 3.59111910556542, 3.60683088921204, 3.62269107170706, 3.63869537055127, 3.65461051656197, 3.6708713142347, 3.68701037951836, 3.70298531929649, 3.71927379598479, 3.73562181986193, 3.75201168809436, 3.76842341990972, 3.78483438783388, 3.80153176224347, 3.81820445242663, 3.83482245355856, 3.85170026708352, 3.86848651721064, 3.88551555883894, 3.90240684772645, 3.91951572335549, 3.93643008056024, 3.9535269898401, 3.97080506478297, 3.98826204144463, 4.0054168678399, 4.0231911021823, 4.04061583790366, 4.05814659523329, 4.07577071255674, 4.09347341856746, 4.11123788393748, 4.12904466415009, 4.14686985021962, 4.16534497497708, 4.18317065401943, 4.20163867675546, 4.21934796252626, 4.23767970135547, 4.25590810783666, 4.27480156227835, 4.29357949644977, 4.29357949644977]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_cb14_1100 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Campbell & Bozorgnia (2014) GMM, for Vs30 = 1100 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_cb14_1100 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_cb14_1100()
fi = @SVector [0.001, 0.107151935453737, 0.109647834565003, 0.112201844745437, 0.11481541722802, 0.117489804052062, 0.120226447440993, 0.123026916177356, 0.125892546569393, 0.128824945955999, 0.131825714078132, 0.134896306042729, 0.138038424160509, 0.141253751203674, 0.14454400666565, 0.147910845778061, 0.151356122586865, 0.154881709807325, 0.158489319473994, 0.162181025067334, 0.165958710318836, 0.169824438685114, 0.173780141390804, 0.177828043611803, 0.181970119541417, 0.18620873197305, 0.190546134906447, 0.194984475342449, 0.199526210475698, 0.204173837974327, 0.208929640601348, 0.213796247084416, 0.218776211782296, 0.223872152523143, 0.229086871788025, 0.234422946424962, 0.239883314860486, 0.245470938018794, 0.251188642147164, 0.257039598092891, 0.263026835681957, 0.269153521651332, 0.275422976359149, 0.281838329395954, 0.288403215446539, 0.295120983380726, 0.301995230065901, 0.309029624220641, 0.316227902746474, 0.323593746346755, 0.331131246680177, 0.3388441977443, 0.346736961606689, 0.354813433633056, 0.363078259538029, 0.371535260202758, 0.380189545842012, 0.389045181735103, 0.39810727171514, 0.407380375529606, 0.416869489133838, 0.426579731304667, 0.43651591390959, 0.446683836016586, 0.457088344310272, 0.467735362157079, 0.478630277106537, 0.489778904972026, 0.501187289285747, 0.51286142354831, 0.524807868760027, 0.537032155540723, 0.549541011276866, 0.562341531322902, 0.575440020570062, 0.588843861667092, 0.602560003343154, 0.616595264861423, 0.630957736954371, 0.645654518798835, 0.660693557110258, 0.676083280102802, 0.691831491646336, 0.707945991428218, 0.724436553358675, 0.74131051179263, 0.758577769375232, 0.776247559858663, 0.794328977075606, 0.812830810032516, 0.831764029522309, 0.851138571729408, 0.870963922685582, 0.891251996967617, 0.912011247769634, 0.933254698528794, 0.954992787026339, 0.97723758486003, 1.0000005062702, 1.02329347485744, 1.04713040496121, 1.07152004409775, 1.09647897265996, 1.12201844543814, 1.14815528026766, 1.17489835814305, 1.20226604254383, 1.23027018193224, 1.25892734508558, 1.28825079908837, 1.318259163803, 1.34896505843724, 1.38038665711632, 1.41253792667885, 1.44544207656103, 1.47910913805971, 1.51356162108749, 1.5488172358058, 1.58489465883479, 1.62181367335723, 1.65958733700612, 1.69824539848406, 1.7378031878117, 1.77828083283144, 1.81970452337863, 1.86208794334205, 1.90546520741094, 1.94984557553173, 1.99526746389236, 2.04174258587913, 2.08929688261176, 2.137968038963, 2.18776325462817, 2.23872789932023, 2.29087330073668, 2.34423561131071, 2.39883687869452, 2.45471125310074, 2.51189079709591, 2.57040089862653, 2.63027799720795, 2.69153693925965, 2.75423946975239, 2.81838862731573, 2.88403684826771, 2.9512120467315, 3.01995664775724, 3.09029886559892, 3.16228306310782, 3.23593774690871, 3.31132894099924, 3.3884479777074, 3.46738448436814, 3.54814938834072, 3.63079641398924, 3.71535811383629, 3.80189371410457, 3.89046814362258, 3.98109246261088, 4.07380423161549, 4.16870979107803, 4.26582434364337, 4.3651582267743, 4.46683722178704, 4.57088071215204, 4.67734925332799, 4.78630945056098, 4.89778471638987, 5.01190281582109, 5.12864306805199, 5.24809157322569, 5.37034653309144, 5.49545357878399, 5.62346020566487, 5.75441680055487, 5.88845685362517, 6.02565210012032, 6.16599284660048, 6.30964647562554, 6.45661147569388, 6.60698203384398, 6.76088045132855, 6.91830256679691, 7.07948784544066, 7.24446554472023, 7.41312220760793, 7.58574960014797, 7.76254169346153, 7.94339746512847, 8.12835461278235, 8.31763266541652, 8.51149031718433, 8.70962148345103, 8.91249964207197, 9.12023990175558, 9.33250964785959, 9.55009558905348, 9.77253934629245, 10.0000507473303, 10.2330980382324, 10.4712975342726, 10.7151532131155, 10.9649166549558, 11.2201404474293, 11.4818091737881, 11.7490636915642, 12.0225588043305, 12.3026241711845, 12.5891610107431, 12.8825325867975, 13.1826273392915, 13.489849571919, 13.8040774158165, 14.1257655547166, 14.4547859850637, 14.7909591027162, 15.135516773819, 15.4883873310213, 15.8494511209435, 16.2185340183152, 16.596310619533, 16.9826200621376, 17.3782522441654, 17.7830741509695, 18.196892983888, 18.6206353014046, 19.0554026077809, 19.4985300407455, 19.9523177626254, 20.4180811199692, 20.89272169942, 21.3806209556572, 21.8784563347614, 22.387569371586, 22.9095949660671, 23.442429963151, 23.987749119062, 24.4620357500815, 25.0316841957193, 25.6180740535195, 26.2162255117421, 26.8283164660661, 27.4540559607676, 28.096132775273, 28.7512675224258, 29.4222766176383, 30.1089392418281, 30.8147536270626, 31.5318189879249, 32.2674699378919, 33.0216612714318, 33.7942567772711, 34.5850167285209, 35.388313764356, 36.2195077508899, 37.0620713160324, 37.9266985360148, 38.8133730566014, 39.7219756846267, 40.645001386875, 41.5962694155783, 42.5683179538513, 43.5604570068404, 44.5808076412297, 45.6201979729562, 46.6873914210834, 47.771880369061, 48.8942482643485, 50.0324439699154, 51.1966799577741, 52.399433145376, 53.6281299541173, 54.8672478615497, 56.1594363974676, 57.4592813129032, 58.8139200609086, 60.1905090554239, 61.5868188953173, 63.0203244915951, 64.491094304094, 65.9990752044332, 67.5440188946363, 69.1254709414305, 70.7427414108178, 72.394877541108, 74.080632612254, 75.7984354316832, 77.5788807365932, 79.3904112524522, 81.2304780583983, 83.1342530299609, 85.1041774559473, 87.057646940651, 89.1183937383861, 91.2006398887539, 93.299093611543, 95.5130345351385, 97.7408567124562, 100.035271317829, 1e3]
Ai = @SVector [1.0, 1.02754725519808, 1.02820826952511, 1.02888599630737, 1.02958091766671, 1.03029346852874, 1.03102414038011, 1.0317734650096, 1.03254191876817, 1.03333005763436, 1.03413844319424, 1.03496760589708, 1.03581815111239, 1.03669068782925, 1.03758584430214, 1.03850424100261, 1.03944656285786, 1.04041351096469, 1.04140575375438, 1.04242407109357, 1.04346920356693, 1.04454195496302, 1.04564310667862, 1.04677353699283, 1.04793407015976, 1.04912565608339, 1.05034923240789, 1.05160572535366, 1.0528961688031, 1.05422162980225, 1.05558313657458, 1.05698183992073, 1.0584188948002, 1.05989550117098, 1.06141294102939, 1.06297246082026, 1.06457544425836, 1.06622331610232, 1.06791749739882, 1.06965954942584, 1.07145103252663, 1.07329359100737, 1.0751889615415, 1.07713887192198, 1.07914525536852, 1.08121001390809, 1.08333518446315, 1.08552288943526, 1.08777533980318, 1.09009480033728, 1.0924837416722, 1.09494462221245, 1.09748016882279, 1.10009305244087, 1.1027862863768, 1.10556272234172, 1.10842568083809, 1.11136784469061, 1.11435355003379, 1.11738141633584, 1.12045031913697, 1.12355927550719, 1.12670731516118, 1.12989390082523, 1.13311829129987, 1.13638018549887, 1.13967921599906, 1.14301524754049, 1.14638830840526, 1.14979850858202, 1.15324621483428, 1.1567315885543, 1.16025523623697, 1.16381793878799, 1.16742036336823, 1.17106355608351, 1.17474853091004, 1.17847636368001, 1.18224854983406, 1.18606641729104, 1.18993161151923, 1.19384598114918, 1.19781129475583, 1.20182909102924, 1.20590103406501, 1.21002786120417, 1.21421064602407, 1.21845006862633, 1.22274654155754, 1.2271002381186, 1.23151168439212, 1.2359810313511, 1.24050823143457, 1.24509370110001, 1.24973701876179, 1.25443874469405, 1.25919884040249, 1.26401760004218, 1.26889519984859, 1.27383192291399, 1.27882851643492, 1.28388468478728, 1.28900180359891, 1.29418021864743, 1.2994214782991, 1.30472560497598, 1.31009459262257, 1.31552915024034, 1.32103083952586, 1.3266005801871, 1.33224028006065, 1.33795072191015, 1.34373376089976, 1.3495905021026, 1.35552379964638, 1.36153418186804, 1.36762450845223, 1.37379687912623, 1.38005366319019, 1.38639754202026, 1.3928301859908, 1.39935624048714, 1.40597807171151, 1.41269903285634, 1.41952366414661, 1.42645419789768, 1.43349703021265, 1.44065490973256, 1.44793524785183, 1.45534128438651, 1.46287749715587, 1.47054851918107, 1.47835265120915, 1.4862927780237, 1.49436524717492, 1.50256914493868, 1.51090030083193, 1.51935419619566, 1.52792774102079, 1.53661503766433, 1.54541127373826, 1.55430795530326, 1.56330300769557, 1.572385566197, 1.58155154577689, 1.59079317030895, 1.60010452227965, 1.6094776474509, 1.61890670396021, 1.62838374933906, 1.63790564281385, 1.64745986727507, 1.65704624667635, 1.66665499794966, 1.67628164844266, 1.6859193933619, 1.69556462637196, 1.70521444996092, 1.71486024791311, 1.72449656312858, 1.73412525344792, 1.7437389062475, 1.75333004291949, 1.76290258170278, 1.77245033628628, 1.78197124553899, 1.7914639265763, 1.80092341488628, 1.8103537955354, 1.81974693738443, 1.82910370605815, 1.83842595995007, 1.84771158226806, 1.85695887787945, 1.86616654981164, 1.87533922635142, 1.88447723531203, 1.89357569237835, 1.90264145845155, 1.91167063861534, 1.92066553222247, 1.92962642827777, 1.93855244152431, 1.94745576840511, 1.95633525932969, 1.96518249341382, 1.97401063388319, 1.982827379544, 1.99162573649249, 2.00040599974566, 2.00917715895918, 2.01794974150186, 2.02670878822112, 2.03547434661141, 2.04425042070715, 2.05297568659385, 2.06177350989524, 2.07060345759516, 2.07945917170465, 2.08835423592739, 2.09726942461957, 2.10621907638622, 2.11520760348828, 2.12421430988326, 2.13326921145113, 2.14233790152115, 2.15143812801247, 2.16057604753109, 2.16974365971957, 2.17894779640365, 2.18818016422479, 2.19744841549616, 2.2067440754367, 2.21607579216373, 2.22543502484972, 2.23481207869526, 2.24423642137433, 2.25370092138661, 2.26319737877306, 2.27271645916396, 2.28227072290856, 2.29185122267207, 2.30147255470604, 2.31112645511759, 2.32080343019524, 2.33052018144713, 2.34029652509159, 2.35006769198692, 2.35987972916044, 2.36975549721751, 2.37962439286674, 2.38957173268132, 2.39952367822879, 2.4095037248115, 2.4195385338672, 2.42958260764245, 2.43966263551656, 2.44826127984448, 2.4584168763621, 2.46866791868729, 2.47892169787595, 2.48921070944454, 2.49952484697339, 2.5099029094798, 2.52028649474119, 2.53071515346962, 2.54117997379675, 2.55172823308834, 2.56223680122082, 2.57280835156284, 2.58343616926067, 2.59411244055014, 2.60482814951695, 2.61550255073071, 2.62633360410579, 2.63710025127131, 2.64793443436663, 2.65882964397415, 2.6697782751069, 2.68068520784913, 2.69170797485315, 2.70275373008123, 2.71380949891863, 2.72495971113114, 2.73609837531697, 2.74731382544185, 2.75849047719981, 2.76983395569256, 2.78111529169552, 2.79243132399273, 2.80389605864023, 2.81538267075703, 2.82674275161086, 2.83836055592965, 2.84982179705231, 2.86153584939425, 2.87321111527154, 2.88482520854258, 2.89651828163281, 2.9082846005574, 2.92011638767014, 2.9320050701364, 2.94394078416375, 2.95591231132987, 2.96790691104069, 2.97991020185413, 2.991905991553, 3.00410033351606, 3.01626982969244, 3.02839336223732, 3.0406957276131, 3.05318299686852, 3.06532876423155, 3.07789607819706, 3.09035278260366, 3.10266558971082, 3.11540789445756, 3.12798668687108, 3.14066648243057, 3.14066648243057]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_cy14_620 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Chiou & Youngs (2014) GMM, for Vs30 = 620 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_cy14_620 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_cy14_620()
fi = @SVector [0.001, 0.0999999976652677, 0.102329302559524, 0.104712899705854, 0.107151922989684, 0.109647828995156, 0.112201842696072, 0.11481541089106, 0.117489809378079, 0.120226445776095, 0.123026909458668, 0.125892543532019, 0.128824940148533, 0.131825713266556, 0.134896296983383, 0.138038409311518, 0.141253749305678, 0.144543997655653, 0.147910842278198, 0.151356137537707, 0.15488169337686, 0.158489303595042, 0.162181004512454, 0.165958719179296, 0.169824391893398, 0.173780092333096, 0.177827996145802, 0.181970117416829, 0.186208734415521, 0.190546109357795, 0.194984457628401, 0.199526242691258, 0.204173813286818, 0.208929592034584, 0.213796238584529, 0.2187762493612, 0.223872144370144, 0.229086835045603, 0.23442290250074, 0.239883271573778, 0.245470902647703, 0.25118864038462, 0.257039633852038, 0.263026746068401, 0.269153491549264, 0.27542291591493, 0.281838388993556, 0.288403255925135, 0.295121024058995, 0.301995126127994, 0.309029604841999, 0.316227931529218, 0.323593614975621, 0.331131069452825, 0.338844245205114, 0.346736772309639, 0.354813575838685, 0.363078225718974, 0.371535219004033, 0.380189390728033, 0.389045046146597, 0.398107161691699, 0.407380508152432, 0.416869557404415, 0.426579406652838, 0.436515931430506, 0.446683454307402, 0.457088153096857, 0.467735056430679, 0.478629876540239, 0.489779099866922, 0.50118693836304, 0.512861667967552, 0.524807676772549, 0.537031867432931, 0.549541200445333, 0.56234152115601, 0.575440464532454, 0.588844296122595, 0.602559893922469, 0.616594876327047, 0.630957658073171, 0.645654646063062, 0.66069423786917, 0.676082399828016, 0.691830540350792, 0.707945998165234, 0.724436595494636, 0.741310700488815, 0.758577297086523, 0.776248385474137, 0.794327772623156, 0.812831358119426, 0.831763986545778, 0.851138538780708, 0.870963429537979, 0.89125049813546, 0.912012592563694, 0.933253442052435, 0.954994171529599, 0.977235937307919, 0.999998805375704, 1.02329280366624, 1.04712852187349, 1.07152197527833, 1.09647602264793, 1.12201883715915, 1.14815530337399, 1.17489542276462, 1.20226202750818, 1.23026811928943, 1.25892769214851, 1.2882486488801, 1.31825399709005, 1.34896180039626, 1.38038352538763, 1.41254005943251, 1.44544529540811, 1.47911398130551, 1.51356193372786, 1.54881707745128, 1.58489956887586, 1.62180735282214, 1.65958637551936, 1.69824989899918, 1.73779729406129, 1.77828448946428, 1.81969887518605, 1.86208779112509, 1.9054543333368, 1.94985352787541, 1.99527311144687, 2.04173508683357, 2.0893051336317, 2.13797123362986, 2.18776191655018, 2.23873283609303, 2.29087102929548, 2.34423796842628, 2.39884781988837, 2.45471400144894, 2.511880091243, 2.57039510551677, 2.63027965310721, 2.69155421647587, 2.75423951576535, 2.81839609775087, 2.88405090257416, 2.95123164803845, 3.01996716410099, 3.09028750979791, 3.16227509284513, 3.23591745184899, 3.31130626470979, 3.38842932293713, 3.46738992240694, 3.54811160360915, 3.63076945311162, 3.71535442092829, 3.80192419136001, 3.89046340636454, 3.98111235975458, 4.0737739992345, 4.16868824170493, 4.2657561712032, 4.36515121132422, 4.4668652059137, 4.57088048539599, 4.67739949206702, 4.786295133735, 4.89778717629173, 5.01186630518887, 5.1286521059794, 5.24808226229213, 5.37027721599142, 5.49538226227858, 5.62336817840178, 5.75436927581519, 5.88853864913959, 6.02565307702634, 6.16606017862807, 6.30951109892382, 6.45662098303551, 6.60690524504259, 6.76079098661223, 6.91824567875567, 7.07950157366777, 7.24452892812175, 7.41327778010241, 7.58567623087047, 7.76232417539447, 7.94320265842556, 8.12827310567713, 8.31747401364312, 8.5115727059095, 8.70968476478233, 8.91261544753868, 9.12033265272673, 9.33278033873792, 9.54987524925011, 9.77266347562167, 9.99995236582352, 10.2328495146228, 10.4713310895162, 10.7153467856455, 10.9648168734375, 11.220415214923, 11.481281797322, 11.7489745722971, 12.0226074114367, 12.3030150474414, 12.589154319388, 12.8829520048479, 13.1822172447431, 13.4901993826242, 13.8033298484174, 14.1251356107456, 14.4543495498987, 14.7908540561393, 15.1360143919102, 15.4882383432476, 15.848957724656, 16.2181055509997, 16.5955707472823, 16.9831652499188, 17.3788959801615, 17.782498830651, 18.1982415618891, 18.6215754095712, 19.0545903354785, 19.4998054296033, 19.9517653945402, 20.4186748032945, 20.8916998179073, 21.3798185481755, 21.876592318871, 22.388724887306, 22.9089776595424, 23.4406285116069, 23.9876462125801, 24.4611810638043, 25.0304353881407, 25.6151373396459, 26.2154380805413, 26.8260113521301, 27.4518039604166, 28.0927715913549, 28.7488005082378, 29.4196999330841, 30.1122048289434, 30.8122344526922, 31.5337746712797, 32.269216867667, 33.0178739029947, 33.7970297127673, 34.5798334266531, 35.3939002732706, 36.2198517187626, 37.0674347729588, 37.9250384135495, 38.815527268243, 39.7146910637927, 40.6476598657917, 41.6017669360864, 42.5614794901379, 43.5557410416839, 44.5861329379982, 45.6190677798908, 46.6879684576793, 47.7748219499769, 48.8987423243348, 50.0395561486413, 51.1954464339143, 52.3882302992812, 53.6190884819327, 54.8626899373696, 56.1440795380313, 57.4642183008033, 58.7931299932705, 60.192060004592, 61.5980795163853, 63.0427913269658, 64.4886848417301, 66.0101801162325, 67.5292356025776, 69.1279644465855, 70.7196167323996, 72.3947924900772, 74.057021287325, 75.8062482577471, 77.5922945719624, 79.4139009601905, 81.2694908799235, 83.1571343713345, 85.0745198625965, 87.0926546875546, 89.0642939141243, 91.2194706679196, 93.3207893198619, 95.5324228492403, 97.7678473288137, 100.021978021978, 1e3]
Ai = @SVector [1.0, 1.43770241338022, 1.45016787169638, 1.46262454089254, 1.47506954446146, 1.4875032820005, 1.49992636965784, 1.51234180697138, 1.5247529223422, 1.53716475354566, 1.54958405816321, 1.56201737581464, 1.57447313258116, 1.58696060323328, 1.59948897271967, 1.61206931166247, 1.62471240114601, 1.63742528130861, 1.65021024760093, 1.66306589337842, 1.67598680368875, 1.6889641838872, 1.70198714824542, 1.71504181008475, 1.72811216588793, 1.7411807603792, 1.75422891589671, 1.76723619345155, 1.78018337692914, 1.79305328990608, 1.80583076079616, 1.8185032630888, 1.83105967940179, 1.84349068085707, 1.85578895086534, 1.86794800786156, 1.87996254635489, 1.89182916026216, 1.90354456326478, 1.91510698529507, 1.92651538016369, 1.93776906215491, 1.94886842373616, 1.95981376147573, 1.97060694489046, 1.98124927169874, 1.99174289867486, 2.00209017936097, 2.01229386115204, 2.02235673002841, 2.0322825729852, 2.04207439107915, 2.05173532871477, 2.06126973721357, 2.07068138943787, 2.07997366611491, 2.08915149661157, 2.09821815137207, 2.107177996807, 2.11603566959446, 2.1247952191208, 2.13346129161745, 2.14203831430708, 2.15053031049951, 2.15894190392058, 2.16727828847451, 2.17554324021112, 2.18374201605683, 2.19187893599667, 2.199958720043, 2.20798664627671, 2.21596612288845, 2.22390264827575, 2.23179796019478, 2.23965456530301, 2.24747416994563, 2.25525698088987, 2.26300369255647, 2.27071359119099, 2.27838589422441, 2.28601973247664, 2.29361432874004, 2.30116749996813, 2.3086778356036, 2.31614246908875, 2.32356100141267, 2.33093092939542, 2.33824981714173, 2.34551537549608, 2.35272554679509, 2.3598793895228, 2.36697264291035, 2.37400578716703, 2.38097495005529, 2.38787931996052, 2.39471648051213, 2.40148541810272, 2.40818570002686, 2.41481417437546, 2.42137350269376, 2.42786038034924, 2.43427730762559, 2.44062404245448, 2.44690066141568, 2.45310879514176, 2.45924683690326, 2.46531959118402, 2.47132617807982, 2.47726715655229, 2.4831459587665, 2.48896386728503, 2.49472238892009, 2.50042193775653, 2.50606585942444, 2.5116565033774, 2.51719510112322, 2.52268444138543, 2.52812616926381, 2.53352210977711, 2.53887424152971, 2.54418639048603, 2.54946111207599, 2.55469777767125, 2.55990258293713, 2.56507702827636, 2.57022091276869, 2.57534127336485, 2.58043642448844, 2.58551213835869, 2.59056876953017, 2.59561273694766, 2.60064266491665, 2.60566114763947, 2.61067538498963, 2.61568429867945, 2.62069108211207, 2.62570155924051, 2.63071474081604, 2.63573686785813, 2.64076965035807, 2.64581473404395, 2.65087659127751, 2.6559599807492, 2.66106717721275, 2.66620056913522, 2.6713624883885, 2.67655862119629, 2.68179180173664, 2.68706503247137, 2.69238140763953, 2.69774416968228, 2.70316051272804, 2.70863043864547, 2.71416182660125, 2.71975477246343, 2.72541777755935, 2.73114690776991, 2.73695590437774, 2.74284555208644, 2.74882134784057, 2.75488382444996, 2.76104426912801, 2.76729788279163, 2.7736627502061, 2.78013423665675, 2.78672602937371, 2.79343983347924, 2.80027692924534, 2.80725315077232, 2.814362847559, 2.82162331360779, 2.82903694748673, 2.83661476441152, 2.8443206041498, 2.8520511877403, 2.8598037746113, 2.86757243990086, 2.875361246825, 2.88317505759392, 2.89099690156617, 2.89884252206407, 2.90669402806585, 2.91458089482491, 2.92247297709132, 2.93038865266971, 2.93832205666209, 2.94628067082922, 2.95425865017668, 2.9622495348731, 2.97024603444418, 2.97827180113265, 2.98632157144484, 2.99438928056263, 3.00246817559146, 3.01058658006503, 3.0187032248018, 3.026847073473, 3.03501243241576, 3.04319282444565, 3.05138099124304, 3.05961193178662, 3.06783730096053, 3.07609307589279, 3.08437380669606, 3.09267333573152, 3.10098467953501, 3.10932597146677, 3.11766492555021, 3.12604695408217, 3.13443972680896, 3.14286435755985, 3.15128526682163, 3.15975469356089, 3.16820522174391, 3.176723970201, 3.18520799445835, 3.19374858930422, 3.20230709657814, 3.2108761883538, 3.21948596929976, 3.22809231538926, 3.23672600296876, 3.24538073379847, 3.25404942554169, 3.26276879153558, 3.2714892521925, 3.28020129743411, 3.28899195109764, 3.29776022041696, 3.30654556003318, 3.31539381860346, 3.3241924704965, 3.33309635042727, 3.34193250145537, 3.35086420237266, 3.35976851638599, 3.36876064179229, 3.37770877149997, 3.38666591577686, 3.39569365553722, 3.40336128011046, 3.41240444748267, 3.42150263892667, 3.43065244885735, 3.43976835149571, 3.4489200680504, 3.4581017634771, 3.46730683156448, 3.47652774775042, 3.48585109898529, 3.49508310600139, 3.5044040094006, 3.51371021423701, 3.52298951241011, 3.53244940197633, 3.5417593689859, 3.55124314831317, 3.56066891069682, 3.57014379913305, 3.57953452542909, 3.58908587962355, 3.59853308319482, 3.60813502113749, 3.61775428403747, 3.62723216085909, 3.63685006074365, 3.64661438492979, 3.65620309560786, 3.66592287374757, 3.67560418251516, 3.68541142885049, 3.69516310864239, 3.70484159030479, 3.71462470355701, 3.7245142324531, 3.73430225802669, 3.74418162900315, 3.7541524596334, 3.76398469248638, 3.77412429347026, 3.78410841347155, 3.79415840059195, 3.80401131424911, 3.81416782825724, 3.82410151631852, 3.83434326044182, 3.84433203673702, 3.85463092634442, 3.86464222983466, 3.87496297029135, 3.88528746895873, 3.89560403281376, 3.90589970622295, 3.91616032332114, 3.92637033463232, 3.93689861761273, 3.94697505070503, 3.95776590239446, 3.96807466174167, 3.97870464642664, 3.98923199048823, 3.99963202873836, 3.99963202873836]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_cy14_760 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Chiou & Youngs (2014) GMM, for Vs30 = 760 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_cy14_760 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_cy14_760()
fi = @SVector [0.001, 0.100000005278119, 0.102329305685959, 0.104712901088038, 0.10715191734136, 0.1096478161355, 0.112201844312325, 0.114815399493054, 0.117489811269133, 0.120226426884127, 0.123026912673429, 0.125892543180806, 0.128824943888933, 0.131825701931171, 0.134896292542321, 0.138038419685919, 0.141253726031804, 0.144543991682274, 0.147910841016824, 0.15135612531762, 0.154881699105396, 0.158489298275321, 0.162180994731809, 0.165958688177051, 0.169824406249264, 0.173780124732544, 0.177827987234069, 0.181970104503309, 0.18620874216892, 0.190546088276735, 0.194984413397179, 0.199526234462532, 0.204173818378493, 0.208929629962364, 0.213796203501538, 0.218776216272469, 0.223872092751581, 0.229086773295876, 0.234422913440041, 0.239883346374602, 0.245470959191782, 0.251188647299664, 0.257039583965111, 0.263026839625322, 0.269153386068061, 0.275422892536035, 0.281838357206786, 0.288403136014915, 0.29512088643951, 0.301995147118928, 0.309029636270837, 0.316227726764557, 0.323593743035287, 0.331131074274485, 0.338844138033324, 0.346736738117816, 0.354813374379999, 0.363078069427477, 0.371535318437207, 0.38018929961147, 0.389044995694541, 0.398107060813636, 0.407380379735427, 0.416869369537323, 0.426579727361764, 0.436515887692042, 0.446683606986212, 0.457088019319652, 0.46773532542682, 0.478629981874554, 0.489778948828998, 0.501187304961605, 0.512861186273828, 0.524807402402299, 0.537031596210482, 0.549541299892976, 0.562341327015613, 0.575439822942147, 0.588843516357273, 0.602559763585899, 0.61659488244124, 0.630957589108888, 0.645654602589703, 0.660693172670039, 0.676083352446191, 0.69183061540227, 0.707945609900711, 0.724435639005472, 0.741310319666438, 0.758577791401586, 0.776247032532349, 0.794327972885161, 0.812829888313304, 0.83176450189098, 0.85113745411528, 0.870963690655165, 0.891251760400126, 0.912010408577856, 0.933255245295474, 0.954991724274509, 0.977236931585538, 0.99999931915226, 1.0232926583713, 1.04712871370939, 1.07151972559382, 1.09647839861261, 1.12201798920987, 1.14815239015486, 1.17489619113164, 1.20226482282661, 1.230270509361, 1.25892568257472, 1.28825221490343, 1.31825970420816, 1.34896234511787, 1.38038569480746, 1.4125355875376, 1.44544035634817, 1.4791067005516, 1.51355991769356, 1.54881419338307, 1.58489135570109, 1.62180741098713, 1.65958724224312, 1.69824098493074, 1.73780538614063, 1.77828384029801, 1.81969768325487, 1.86209132642581, 1.90545951786295, 1.94984000723927, 1.99526323502638, 2.04173666608573, 2.08929373051144, 2.13795720949869, 2.18776679563686, 2.23871864940605, 2.29087274897834, 2.34422665758295, 2.398830455509, 2.45470143491059, 2.51187774934974, 2.57040187591233, 2.63027473614656, 2.69154228983537, 2.75423051595883, 2.81839385215467, 2.88403692114349, 2.95122086420034, 3.01995215562392, 3.09030065678915, 3.16227642295472, 3.23592346631478, 3.31132891490246, 3.3884299172534, 3.46735946910046, 3.54813821074709, 3.63078533725135, 3.71536846377799, 3.80191135853523, 3.89043708383884, 3.98108381905827, 4.07382969500055, 4.16870567544569, 4.26581070164795, 4.36518697265844, 4.46680411703705, 4.57085377834242, 4.67739610111622, 4.78632242414544, 4.89776678860413, 5.0118843229469, 5.12865332406043, 5.24803935339088, 5.37032511094351, 5.49537847413284, 5.62339713074269, 5.75435457691296, 5.88847905118778, 6.02561155450687, 6.16599641750948, 6.30960714497232, 6.45659960120723, 6.60689861529496, 6.76084973072587, 6.91824357308313, 7.07938541613807, 7.24442301919855, 7.41307142632331, 7.58568641738688, 7.76244066564601, 7.94326569146627, 8.12834448596361, 8.31759182767968, 8.51151566867657, 8.70973318814878, 8.91245786665494, 9.12030564789694, 9.33246351716575, 9.54996668260048, 9.77234156401459, 9.99990153906584, 10.2330151684908, 10.4711008559889, 10.7150364469821, 10.964750490257, 11.2201347329491, 11.4816670597186, 11.7492496241653, 12.022742813086, 12.3026981000034, 12.5889920759082, 12.8822769465087, 13.182459265256, 13.489400932834, 13.8038791736706, 14.1258004265005, 14.4539459356652, 14.7913578984967, 15.1357324856635, 15.4880193842308, 15.8493619845298, 16.2183086824161, 16.5960326767835, 16.9823769767776, 17.3787778053556, 17.7834601578259, 18.1979135417807, 18.6200418512582, 19.0554824815177, 19.49807748989, 19.9517012657342, 20.4186610376656, 20.8940733113534, 21.379997361205, 21.8789412825561, 22.387937087537, 22.9096392147486, 23.4439269263859, 23.9870856553391, 24.46058662679, 25.0340588613218, 25.6152039490899, 26.2158596298214, 26.8275446219964, 27.4542925051998, 28.0959151088508, 28.7521309339848, 29.4225501552548, 30.1066616578723, 30.8101318295223, 31.5331607803149, 32.2688473500071, 33.0235676906087, 33.7894041350745, 34.5814827413102, 35.3920282683592, 36.2114034095699, 37.0570384215831, 37.9296731960298, 38.808356830246, 39.7246511532133, 40.6446342457211, 41.5904771517877, 42.5624316552899, 43.5606664842275, 44.58525356566, 45.6203356517073, 46.679926731282, 47.7811828082431, 48.889095202211, 50.0392749799897, 51.1923784631563, 52.3876989427786, 53.6271327545174, 54.8639723203735, 56.1438945185322, 57.4685744162854, 58.8111011775592, 60.1686734628619, 61.6017896398734, 63.0158092367494, 64.5080917430415, 66.010239337733, 67.5570266517399, 69.1074610525002, 70.7437395379651, 72.3800126937281, 74.0584033514694, 75.8305646487854, 77.5949512656221, 79.4004309784528, 81.2461188644527, 83.1308139099541, 85.0529665055861, 87.0822300450569, 89.0763954752011, 91.1807407221922, 93.3202913166248, 95.4916631049442, 97.6908631563263, 100.012267904509, 1e3]
Ai = @SVector [1.0, 1.26474365754693, 1.27187168763244, 1.27901461204394, 1.2861668468288, 1.29332769860997, 1.30049545713136, 1.30766852765824, 1.3148448358383, 1.32202240367609, 1.32920111176275, 1.33638102751286, 1.34356422475535, 1.35075365610266, 1.35795288790118, 1.36516683588672, 1.37240078818257, 1.37965956984633, 1.38694651866824, 1.3942644665929, 1.40161534480099, 1.40900004959024, 1.41641948596057, 1.42387361692424, 1.43136209798135, 1.43888401061133, 1.44643774756037, 1.45402034276764, 1.46162798960857, 1.46925573360015, 1.47689789847254, 1.48454848588452, 1.49220043010574, 1.49984643882526, 1.50747891120157, 1.51509009761108, 1.52267156234887, 1.53021542332592, 1.53771329159611, 1.54515767577195, 1.5525423017734, 1.55986193063354, 1.56711260297083, 1.57429107685139, 1.58139470109949, 1.58842230933339, 1.59537254872675, 1.60224497526539, 1.6090399193016, 1.61575793863017, 1.62240013364471, 1.62896756722738, 1.63546241542315, 1.64188624895108, 1.64824169962538, 1.65453105215902, 1.660757253143, 1.66692298962119, 1.67303139815318, 1.67908545861599, 1.68508877287354, 1.69104474095905, 1.69695691445104, 1.70282847890391, 1.70866337029487, 1.71446466460501, 1.72023619436562, 1.72598137429174, 1.73170412937894, 1.73740741092509, 1.74309547823134, 1.74877153446106, 1.7544392973187, 1.76010278844154, 1.7657654338474, 1.77143153644529, 1.77710410272141, 1.7827876649385, 1.78848607318854, 1.79420347226643, 1.79994358407784, 1.80571108575488, 1.81150988535825, 1.81734412132426, 1.82321904347219, 1.82913817252675, 1.83510670026067, 1.84112756121076, 1.84720347424249, 1.85333562714735, 1.85952470296974, 1.8657708979849, 1.87207351949043, 1.87843213317722, 1.8848436987637, 1.89130781117208, 1.89782159094484, 1.90438189213204, 1.91098741512956, 1.91763345905683, 1.92431870117879, 1.93103904302077, 1.9377917893536, 1.94457361968632, 1.95138121657727, 1.95821137709387, 1.96506101732005, 1.97192719683423, 1.97880718423323, 1.98569844861012, 1.99259770558709, 1.99950182429154, 2.00641002878188, 2.01331868946611, 2.02022543975041, 2.02713050388327, 2.03402982723964, 2.04092437374658, 2.04781056500155, 2.05468885904031, 2.0615574700588, 2.06841626488153, 2.0752640907423, 2.08210150758018, 2.08892649642953, 2.09574183898203, 2.10254459906843, 2.10933506179724, 2.11611724811337, 2.12288728136106, 2.12964821625687, 2.13640189502178, 2.14314680483325, 2.14988534511825, 2.15661842855298, 2.16334930355606, 2.17007541648867, 2.17680275350116, 2.18352920748937, 2.19025940643645, 2.19699395722506, 2.2037360384332, 2.21048929651311, 2.21725267854449, 2.22403035334881, 2.23082429847101, 2.23763960582685, 2.24447608988636, 2.25133959947153, 2.25823040581599, 2.26515517696813, 2.27211465284156, 2.279113030692, 2.28615863788022, 2.29324589179053, 2.30038750095143, 2.30758593730311, 2.31484372550238, 2.32216775190769, 2.32956116012962, 2.33702714372695, 2.34457871599795, 2.35221548594714, 2.35994167884065, 2.36776709937289, 2.37569708603435, 2.38373136578869, 2.39188740715789, 2.4001723655651, 2.40858055742088, 2.41712532444938, 2.42582176653978, 2.43467176969305, 2.44367644631041, 2.45286124704223, 2.46222059889919, 2.47177408512471, 2.48152482557902, 2.49149534670758, 2.50167973724668, 2.5121025424396, 2.52276859362371, 2.53368621015369, 2.54471244064013, 2.55579887509383, 2.56691556730856, 2.57807828112741, 2.58929124755218, 2.60052938345122, 2.61181075197994, 2.6231406506567, 2.63450877844716, 2.64592079024619, 2.65736566297975, 2.66886801235028, 2.68039925680379, 2.6919660621504, 2.70359735310195, 2.71524178942724, 2.72695021810889, 2.73869095536778, 2.75047462230107, 2.76231402600025, 2.77417366427405, 2.78609125336844, 2.79805689620922, 2.81005922472766, 2.82211450958847, 2.83421194016232, 2.84633914825058, 2.85851444304052, 2.87072623771478, 2.88299593842877, 2.89531316315953, 2.90766594630464, 2.92007909343311, 2.93254220452969, 2.94500235859685, 2.95756836203094, 2.97014763145451, 2.98276880579325, 2.99546605253435, 3.00818177435952, 3.02095009321979, 3.03375911466721, 3.04664949155654, 3.05955682058631, 3.07252220143771, 3.08547407825541, 3.09857806889149, 3.11164189991262, 3.1247740454825, 3.13803326445637, 3.15127392356254, 3.16454764394741, 3.17791564782097, 3.19129151012199, 3.20473834661461, 3.21824566667958, 3.23171364822652, 3.24322176393691, 3.25693690766748, 3.27057303493195, 3.28439587776679, 3.2982023981508, 3.3120769920673, 3.32600819520374, 3.33998266349085, 3.35398523152793, 3.36799876948903, 3.38213175244099, 3.39637913151413, 3.41059795760726, 3.42490457070842, 3.43914277447917, 3.45358581167583, 3.46808249458969, 3.4824554766011, 3.49700354471659, 3.51172864029507, 3.52627127838015, 3.54114568729358, 3.55579375948015, 3.57056350893963, 3.58544956703106, 3.60044533617299, 3.61554285093282, 3.63050282206819, 3.64552230305604, 3.66083358332543, 3.67594250063318, 3.69132730927766, 3.70645512356833, 3.72183502705042, 3.73747813266146, 3.75278864636778, 3.76832751756716, 3.78410258957844, 3.79978518957619, 3.81533904720756, 3.83144482482593, 3.84703224899097, 3.86316870335808, 3.87910227339303, 3.89519546271496, 3.91101665356257, 3.92739373576442, 3.94345781904698, 3.95961844868298, 3.97635732852111, 3.99270630339808, 4.00911573850308, 4.02556924273202, 4.04204836767728, 4.05853233081845, 4.07560361892911, 4.09205960420983, 4.10909253284836, 4.12608173443567, 4.14299493817811, 4.15979664012907, 4.17719144318364, 4.17719144318364]
new(construct_interpolant(fi, Ai))
end
end
"""
struct SiteAmpAlAtikAbrahamson2021_cy14_1100 <: SiteAmplification
Implementation of the Al Atik & Abrahamson (2021) amplification function for the Chiou & Youngs (2014) GMM, for Vs30 = 1100 m/s
"""
struct SiteAmpAlAtikAbrahamson2021_cy14_1100 <: SiteAmplification
amplification::Function
function SiteAmpAlAtikAbrahamson2021_cy14_1100()
fi = @SVector [0.001, 0.0977010025977648, 0.100000002147813, 0.102329309655048, 0.104712908884942, 0.107151921599752, 0.109647820058097, 0.112201843942563, 0.114815401321503, 0.117489803171727, 0.120226429999859, 0.123026915212088, 0.125892545558633, 0.128824944897604, 0.131825712969856, 0.134896304882222, 0.138038422945309, 0.141253749931204, 0.144544005333209, 0.147910844382825, 0.151356121125874, 0.154881708277479, 0.158489317872049, 0.162181023389891, 0.165958708562337, 0.169824403885452, 0.173780104951092, 0.177828005454721, 0.181970117429641, 0.18620872976175, 0.190546132590931, 0.194984429467593, 0.199526207936787, 0.204173835315759, 0.208929637817485, 0.213796244169354, 0.218776208729851, 0.223872149326841, 0.229086808463051, 0.234422942920286, 0.239883311190641, 0.245470934175994, 0.25118863812326, 0.257039593879345, 0.263026831269832, 0.26915351703127, 0.275422971521348, 0.281838324330158, 0.288403210141998, 0.295120977826189, 0.301995224249587, 0.309029618130213, 0.31622789636901, 0.323593739668733, 0.331131114375592, 0.338844190421997, 0.346736816537615, 0.354813425604309, 0.363078100472879, 0.371535251399413, 0.380189508791034, 0.389045231112729, 0.398107137135727, 0.407380370581322, 0.416869580502438, 0.426579602266325, 0.436515915885663, 0.446683660333047, 0.457088251100418, 0.467735265470384, 0.478630196128666, 0.489779026173635, 0.501187390878715, 0.512861330755075, 0.524807658522541, 0.537032041448618, 0.549541127929602, 0.56234162744386, 0.575440262356433, 0.588843710293594, 0.602559835951633, 0.616595216384171, 0.630957615277879, 0.645654729513682, 0.660693600957462, 0.676083165254278, 0.691831208109039, 0.707945826928056, 0.724436133611112, 0.74131042217303, 0.758578038308524, 0.77624736932336, 0.794328682342172, 0.812830431366386, 0.831763953983852, 0.851138672022375, 0.87096442965993, 0.891251525828283, 0.91201081083974, 0.933254870536159, 0.954992557324465, 0.977237796174617, 1.00000050289132, 1.02329361857925, 1.04712955845278, 1.07151999189293, 1.09647874351814, 1.12201896666043, 1.14815462914034, 1.17489878135328, 1.20226520272396, 1.23027062883789, 1.25892726545553, 1.2882504677093, 1.31825698358287, 1.34896511219286, 1.38038441048487, 1.41253793942796, 1.44543969181007, 1.47911015332597, 1.51356193891812, 1.54881767314568, 1.58489488713915, 1.621811871956, 1.65958777981605, 1.69824683685932, 1.73780222064615, 1.77828027313385, 1.81970479554162, 1.86209113089599, 1.90546494045257, 1.94984823759762, 1.99526402188307, 2.04174270078569, 2.08929854854814, 2.13796117486418, 2.18776490616744, 2.23872629924922, 2.2908704807379, 2.3442329469835, 2.39883512074943, 2.45470793115014, 2.5118939542785, 2.57039815360423, 2.63027562282402, 2.69154135747925, 2.75423171284814, 2.8183845786919, 2.88403946249489, 2.95120968480996, 3.01995159639335, 3.09030429791269, 3.16227816307602, 3.23594997794318, 3.31131159033704, 3.38844532186045, 3.46738106905059, 3.54814747811791, 3.63079559295023, 3.71535519042189, 3.80190823989626, 3.89046320082663, 3.98108192520036, 4.07380120055439, 4.16869189434466, 4.26579788322738, 4.36516522519641, 4.4668426288625, 4.57088216476806, 4.67734021450466, 4.78632839646284, 4.89777907530505, 5.01190181635595, 5.12862260920556, 5.24807767416142, 5.37030248071806, 5.49539859737328, 5.6234130037025, 5.75439508692842, 5.88847553534566, 6.02564127802564, 6.16595510961186, 6.30957907152021, 6.45660585885845, 6.60693292036847, 6.76086350668524, 6.91829867839757, 7.07947441276088, 7.24441264482972, 7.41313009899397, 7.58578237749003, 7.76255094245573, 7.9433251675949, 8.1282996056464, 8.3177033323344, 8.51142533453252, 8.7097194742949, 8.91246199817186, 9.12016156219638, 9.332696243291, 9.55003805171751, 9.77239450509741, 10.0000029907508, 10.2330553726513, 10.4714586173544, 10.7154077869287, 10.9647806593532, 11.2201385083976, 11.4817667385852, 11.749182692662, 12.0226308508435, 12.3028451426025, 12.5892753879456, 12.8827326835533, 13.1825992921692, 13.4897749635231, 13.8041598088759, 14.1256063708026, 14.4545696058549, 14.7908914452525, 15.1358192657506, 15.4885347993343, 15.8488225194303, 16.2181192725222, 16.5963419405375, 16.9823973303689, 17.3779567228685, 17.7829075841531, 18.1970772186461, 18.6214126043814, 19.0545338392523, 19.4986930161533, 19.9524286446679, 20.416864999908, 20.8933470739312, 21.3801959413476, 21.877050819294, 22.3871039554581, 22.908439141657, 23.4427335942745, 23.9877078447875, 24.4615823340943, 25.031202431116, 25.6177047771876, 26.2161483984282, 26.8259478798891, 27.4552051755687, 28.0951333985226, 28.751315395343, 29.4236385219517, 30.1082477908273, 30.811958621233, 31.5308613988034, 32.2686893997017, 33.0208884169828, 33.7914032028601, 34.579975130502, 35.391548861299, 36.2152106058876, 37.0613062814607, 37.9299347343757, 38.8144960833807, 39.7208188221605, 40.6486334289266, 41.5975541496905, 42.5669911664598, 43.5648564777589, 44.5824470987695, 45.6186722516438, 46.6823777382087, 47.7735736024154, 48.8921454797594, 50.0378325855946, 51.1975836707781, 52.395445399495, 53.6185421737629, 54.8658219542705, 56.1516372230445, 57.4603259933358, 58.8075338769039, 60.175447350898, 61.5810960994084, 63.024723286493, 64.5063997612122, 66.0032231305981, 67.5354572618034, 69.1279139189578, 70.7299653329548, 72.3931067306596, 74.0903777983319, 75.8201354700951, 77.5803564100812, 79.4038019330799, 81.2559529418577, 83.1336398315252, 85.0745163971121, 87.0807659823219, 89.1084652652259, 91.2011614865688, 93.3092685329326, 95.4805967926651, 97.7163690175498, 100.018001618123, 1e3]
Ai = @SVector [1.0, 1.02292145226887, 1.02347193269187, 1.02403057751128, 1.02460319134443, 1.02519011266872, 1.02579176831187, 1.02640853342845, 1.02704082826441, 1.02768905430581, 1.02835363474967, 1.02903505952671, 1.02973373980831, 1.03045017460176, 1.0311848633099, 1.03193827633036, 1.0327109513952, 1.03350342871595, 1.03431626515321, 1.0351500096106, 1.03600526856439, 1.03688266214622, 1.03778277978816, 1.0387063108895, 1.03965390800433, 1.04062627142124, 1.04162410427155, 1.04264817195258, 1.04369920691201, 1.04477802541463, 1.04588545877383, 1.04702230584016, 1.04818950553136, 1.04938795776172, 1.05061856972311, 1.05188234591929, 1.05318029207605, 1.05451345188998, 1.05588292447437, 1.05728983693677, 1.05873534230198, 1.06022069021328, 1.06174710746976, 1.06331594325248, 1.06492854161542, 1.06658631765947, 1.06829076469872, 1.07004336284863, 1.0718457712776, 1.07369961506345, 1.07560663398471, 1.07756863757093, 1.07958750732489, 1.08166516497738, 1.08380367238586, 1.08600521377592, 1.08827195000029, 1.09060628203965, 1.0930105879726, 1.09548742323904, 1.09803949700572, 1.10066953312697, 1.10338046279428, 1.10617545421057, 1.10905764392622, 1.11203034763532, 1.11509721225581, 1.11825553420698, 1.12144917852688, 1.1246796539187, 1.12794829299106, 1.13125624742406, 1.13460429000094, 1.13799306931939, 1.14142322536332, 1.14489489015684, 1.14840831096586, 1.15196361033023, 1.15556079375142, 1.15919975704052, 1.16288063682518, 1.16660315861036, 1.17036730769621, 1.17417302685345, 1.17802006078517, 1.18190862619046, 1.18583863984576, 1.18981011780842, 1.19382332702879, 1.19787836695458, 1.20197562199144, 1.20611528409883, 1.21029802809752, 1.21452416846484, 1.21879471752033, 1.22311033084606, 1.22747180290555, 1.23188011703117, 1.23633643956717, 1.24084239220589, 1.24539887918669, 1.25000795860436, 1.25467094418524, 1.2593898676351, 1.26416675226572, 1.2690035743003, 1.27390284995903, 1.27886707264258, 1.28389900631067, 1.28900137786973, 1.29417717088048, 1.29942997972775, 1.30476222314791, 1.3101765352044, 1.31567550654443, 1.32126173528755, 1.32693599996809, 1.33270134122456, 1.33855901638881, 1.34451134371996, 1.3505591519097, 1.35670499399946, 1.36295050038664, 1.36929744696008, 1.37574778516408, 1.38230438623046, 1.388968313675, 1.39574296878562, 1.40263144734258, 1.40963555128996, 1.41675897819501, 1.42400498055988, 1.43137720353972, 1.43888069172586, 1.44651763482068, 1.45429126519843, 1.46220404573045, 1.47025422831336, 1.4784401930991, 1.48676085496561, 1.49521194341356, 1.50378978556612, 1.51249174592764, 1.52130875754207, 1.53023878441403, 1.5392732835319, 1.54840646886376, 1.55763243232209, 1.56694520621564, 1.57633446807761, 1.58579484589713, 1.5953215555526, 1.60490419160944, 1.61454123113567, 1.6242199810549, 1.63393955229688, 1.64369237447499, 1.65347088883277, 1.66327040535463, 1.67308386455574, 1.68291038791816, 1.69274086388146, 1.70257239762523, 1.71239953852971, 1.72222060085856, 1.73203128225791, 1.74182768716387, 1.75160641484959, 1.76136461193462, 1.7710999990701, 1.78081437519508, 1.79049296371695, 1.80015003736033, 1.80977303709577, 1.81936727071378, 1.82892990714556, 1.83846347170023, 1.84796639243239, 1.85743750459596, 1.86688165331811, 1.87629358252266, 1.8856736527025, 1.8950288840274, 1.90436165066947, 1.91366219165397, 1.92294620623536, 1.93220485121666, 1.94144937133627, 1.95067852479334, 1.95989108471327, 1.96909361501791, 1.97829392522576, 1.9874846673211, 1.99667446850001, 2.00587343176446, 2.01507515603444, 2.02429093618278, 2.03351451411184, 2.0427685885531, 2.05200835048918, 2.06129846975702, 2.07063233834377, 2.08000295297832, 2.08941323937857, 2.09885457878688, 2.10832985289235, 2.11782956098308, 2.12737020834432, 2.13695728579534, 2.14656816953363, 2.15620690857747, 2.16589428783657, 2.17560626370137, 2.18536526516532, 2.19514576543929, 2.20497210102333, 2.2148358498885, 2.22472736252484, 2.23465562018838, 2.24461085240881, 2.25462463207177, 2.26466785090401, 2.27472952825745, 2.28484459422524, 2.29500521882397, 2.30517703409137, 2.31539895840579, 2.32566256141126, 2.3359582202847, 2.34630404776055, 2.35666125692194, 2.36707841037313, 2.37751582151233, 2.38799409394066, 2.39853782035382, 2.4091042877289, 2.41968080309917, 2.43032975604236, 2.44100536528213, 2.45173644910413, 2.46247192861055, 2.47162153106358, 2.48244396248787, 2.49337663294825, 2.50431761351121, 2.5152516264796, 2.52631760041526, 2.53735514381143, 2.54845541134747, 2.5596102315799, 2.5707504876661, 2.5819814097096, 2.59323437974958, 2.60456179747344, 2.61588810012201, 2.6272672323506, 2.63868932517327, 2.65021919295664, 2.66169639382403, 2.67325977972402, 2.68490368042331, 2.69653388068794, 2.70822161597118, 2.71995708946518, 2.73172820368481, 2.74352318663082, 2.7554315670374, 2.76734304435521, 2.77924007834796, 2.79121828669927, 2.80327079986881, 2.81538948486291, 2.82756495832855, 2.83965389962159, 2.85190084056504, 2.86416685159584, 2.87643600596561, 2.88884248273541, 2.90122863794132, 2.91373609924084, 2.92619338563946, 2.93874979637281, 2.95139980678776, 2.96413759574585, 2.97676045753032, 2.98943468223343, 3.00235625109584, 3.0151082390744, 3.02809427260794, 3.04109550561551, 3.05409394159766, 3.06706942999362, 3.08025557152477, 3.09339547933017, 3.10646287098568, 3.11971287329116, 3.13315030041192, 3.14647480120328, 3.15996638094659, 3.17329994536433, 3.18677262243827, 3.20038298587724, 3.21412318639176, 3.21412318639176]
new(construct_interpolant(fi, Ai))
end
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 2809 |
"""
magnitude_to_moment(m::T) where T<:Real
Converts moment magnitude to seismic moment (in dyne-cm).
# Examples
```julia-repl
m = 6.0
M0 = magnitude_to_moment(m)
```
"""
function magnitude_to_moment(m::T) where T<:Real
# equivalent to: return 10.0^( 1.5*( m + 10.7 ) )
return 10.0^( 1.5m + 16.05 )
end
"""
corner_frequency_brune(m::S, Δσ::T, β::Float64=3.5) where {S<:Real, T<:Real}
Computes the corner frequency using the Brune model.
- `m` is the moment magnitude
- `Δσ` is the stress drop in units of bars
- `β` is the shear-wave velocity at the source in units of km/s
# Examples
```julia-repl
m = 6.0
Δσ = 100.0
β = 3.5
fc = corner_frequency_brune(m, Δσ, β)
```
"""
function corner_frequency_brune(m::S, Δσ::T, β::Float64=3.5) where {S<:Real, T<:Real}
Mo = magnitude_to_moment(m)
return 4.9058e6 * β * ( Δσ / Mo )^(1/3)
end
"""
corner_frequency_atkinson_silva_2000(m::T) where T<:Real
Computes the corner frequencies, `fa`, `fb`, and the mixing parameter `ε` from the Atkinson & Silva (2000) double corner frequency model.
This is the default source corner frequency model used by Boore & Thompson (2014) to define their source duration. But note that they just use fa. This function returns fb and ε also
# Examples
```julia-repl
m = 6.0
fa, fb, ε = corner_frequency_atkinson_silva_2000(m)
```
See also: [`corner_frequency`](@ref)
"""
function corner_frequency_atkinson_silva_2000(m::T) where T<:Real
fa = 10.0^( 2.181 - 0.496*m )
fb = 10.0^( 2.410 - 0.408*m )
ε = 10.0^( 0.605 - 0.255*m )
return fa, fb, ε
end
"""
corner_frequency(m::U, src::SourceParameters{S,T}) where {S<:Float64, T<:Real, U<:Real}
Computes a 3-tuple of corner frequency components, depending upon source spectrum type.
By default the single-corner Brune spectrum is considered, but if `src.model` equals `:Atkinson_Silva_2000` then the components of the double-corner spectrum are returned.
If some other symbol is passed then the Brune model is returned.
# Examples
```julia-repl
m = 6.0
Δσ = 100.0
κ0 = 0.035
fas = FASParams(Δσ, κ0)
# compute single corner frequency
src.model = :Brune
fc, tmp1, tmp2 = corner_frequency(m, src)
# compute double corner frequencies
src.model = :Atkinson_Silva_2000
fa, fb, ε = corner_frequency(m, src)
```
"""
function corner_frequency(m::U, src::SourceParameters{S,T}) where {S<:Float64, T<:Real, U<:Real}
if src.model == :Atkinson_Silva_2000
fa, fb, ε = corner_frequency_atkinson_silva_2000(m)
if T <: Dual
return T(fa), T(fb), T(ε)
else
return fa, fb, ε
end
else
# default to Brune
fc = corner_frequency_brune(m, src.Δσ, src.β)
V = typeof(fc)
return fc, V(NaN), V(NaN)
end
end
corner_frequency(m, fas::FourierParameters) = corner_frequency(m, fas.source)
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 4015 |
"""
Oscillator{T<:Float64}
Custom type to represent a SDOF oscillator. The type has two fields:
- `f_n` is the natural frequency of the oscillator
- `ζ_n` is the damping ratio
# Examples
```julia-repl
sdof = Oscillator( 1.0, 0.05 )
```
"""
struct Oscillator{T<:Float64}
f_n::T
ζ_n::T
end
"""
Oscillator(f_n)
Default initializer setting the damping ratio to 5% of critical
- `f_n` is the natural frequency of the oscillator (in Hz)
# Examples
```julia-repl
f_n = 2.0
sdof = Oscillator(f_n)
```
"""
Oscillator(f_n::T) where {T<:Float64} = Oscillator(f_n, 0.05)
"""
period(sdof::Oscillator)
Natural period (s) of the sdof Oscillator.
"""
function period(sdof::Oscillator)
return 1.0/sdof.f_n
end
@doc raw"""
transfer(f::T, sdof::Oscillator) where {T<:Real}
Compute the modulus of the transfer function for a SDOF system.
The transfer function is defined as:
```math
|H(f,f_n,\zeta_n)| = \frac{1}{\sqrt{ \left(1 - \beta^2 \right)^2 + \left(2\zeta_n\beta\right)^2 }}
```
where ``\beta`` is the tuning ratio defined by ``f/f_n``.
# Examples
```julia-repl
f = 2.0
sdof = Oscillator(1.0, 0.05)
Hf = transfer(f, sdof)
```
See also: [`squared_transfer`](@ref)
"""
function transfer(f, sdof::Oscillator)
# tuning ratio
β = f / sdof.f_n
return 1.0 / sqrt( (1.0 - β^2)^2 + (2sdof.ζ_n*β)^2 )
end
"""
squared_transfer(f, sdof::Oscillator)
Compute the square of the transfer function for a SDOF system, `sdof`, at frequency `f`.
# Examples
```julia-repl
f = 2.0
# create sdof with natural frequency f_n=1.0 and damping ζ=0.05
sdof = Oscillator( 1.0, 0.05 )
Hf2 = squared_transfer( f, sdof )
```
See also: [`transfer`](@ref)
"""
function squared_transfer(f, sdof::Oscillator)
# tuning ratio
β = f / sdof.f_n
return 1.0 / ( (1.0 - β^2)^2 + (2sdof.ζ_n*β)^2 )
end
"""
transfer(f::Vector{T}, sdof::Oscillator) where T<:Real
Computes the modulus of the transfer function of a SDOF for a vector of frequencies
- `f::Vector` is the vector of frequencies
- `sdof::Oscillator` is the oscillator instance
# Examples
```julia-repl
f = collect(range(0.1, stop=10.0, step=0.01))
sdof = Oscillator(1.0)
Hf = transfer(f, sdof)
```
"""
function transfer(f::Vector{T}, sdof::Oscillator) where T<:Real
# tuning ratio
Hf = similar(f)
for (i, fi) in pairs(f)
# for i in 1:lastindex(f)
@inbounds Hf[i] = transfer(fi, sdof)
end
return Hf
end
"""
transfer!(Hf::Vector{T}, f::Vector{T}, sdof::Oscillator) where T<:Real
Computes the modulus of the transfer function of a SDOF for a vector of frequencies in place
- `Hf::Vector` is the pre-allocated vector into which the results are stored
- `f::Vector` is the vector of frequencies
- `sdof::Oscillator` is the oscillator instance
# Examples
```julia-repl
f = collect(range(0.1, stop=10.0, step=0.01))
sdof = Oscillator(1.0)
Hf = similar(f)
transfer!(Hf, f, sdof)
```
"""
function transfer!(Hf::Vector{T}, f::Vector{T}, sdof::Oscillator) where T<:Real
for (i, fi) in pairs(f)
# for i in 1:lastindex(f)
@inbounds Hf[i] = transfer(fi, sdof)
end
return nothing
end
"""
squared_transfer!(Hf2::Vector{T}, f::Vector{T}, sdof::Oscillator) where T<:Real
Computes the square of the modulus of the transfer function of a SDOF for a vector of frequencies in place:
- `Hf2::Vector` is the pre-allocated vector into which the results are stored
- `f::Vector` is the vector of frequencies
- `sdof::Oscillator` is the oscillator instance
Inputs derive from the `Real` type and so are differentiable.
# Examples
```julia-repl
f = collect(range(0.1, stop=10.0, step=0.01))
sdof = Oscillator(1.0)
Hf2 = similar(f)
squared_transfer!(Hf2, f, sdof)
```
"""
function squared_transfer!(Hf2::Vector{T}, f::Vector{U}, sdof::Oscillator) where {T<:Real,U<:Real}
for (i, fi) in pairs(f)
# for i in 1:lastindex(f)
@inbounds Hf2[i] = squared_transfer(fi, sdof)
end
return nothing
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 2129 |
"""
simpsons_rule(x::Vector, y::Vector)
Numerical integration via Simpson's rule.
Lengths of vectors must be equal to each other, and be odd (to have an even number of intervals).
Values in `x` represent abcissa values, while `y` are the integrand counterparts.
"""
function simpsons_rule(x::Vector, y::Vector)
n = length(y)-1
n % 2 == 0 || error("`y` length (number of intervals) must be odd")
length(x)-1 == n || error("`x` and `y` length must be equal")
h = (x[end]-x[1])/n
@inbounds @views s = sum(y[1:2:n] .+ 4y[2:2:n] .+ y[3:2:n+1])
return h/3 * s
end
"""
trapezoidal_rule(x::Vector, y::Vector)
Numerical integration via the Trapezoidal rule.
Lengths of vectors must be equal to each other.
Values in `x` represent equally-spaced abcissa values, while `y` are the integrand counterparts.
"""
function trapezoidal_rule(x::Vector, y::Vector)
return (x[2] - x[1]) * ( sum(y) - (y[1] + y[end])/2 )
end
"""
trapezoidal(fun::Function, n, flim...)
Applies the `trapezoidal_rule` using `n` points over the frequency intervals specified by `flim...`.
"""
function trapezoidal(fun::Function, n, flim...)
ii = 0.0
for i in 2:lastindex(flim)
xi = collect(range(flim[i-1], stop=flim[i], length=n))
yi = fun.(xi)
ii += trapezoidal_rule(xi, yi)
end
return ii
end
"""
gauss_interval(integrand::Function, n, fmin, fmax)
Computes Gauss-Legendre integration using `n` nodes and weights over the intervals `[fmin,fmax]`.
"""
function gauss_interval(integrand::Function, n, fmin, fmax)
xi, wi = gausslegendre(n)
ifi = @. integrand( (fmax-fmin)/2 * xi + (fmin+fmax)/2 )
return (fmax-fmin)/2 * dot( wi, ifi )
end
"""
gauss_intervals(fun::Function, n, flim...)
Computes Gauss-Legendre integration using `n` nodes and weights of the intervals specified in `flim...`.
"""
function gauss_intervals(fun::Function, n, flim...)
xi, wi = gausslegendre(n)
ii = 0.0
for i in 2:lastindex(flim)
ii += (flim[i]-flim[i-1])/2 * dot( wi, fun.( (flim[i]-flim[i-1])/2 * xi .+ (flim[i]+flim[i-1])/2 ) )
end
return ii
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 13581 |
@doc raw"""
peak_factor_cl56(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {S<:Real,T<:Real}
Peak factor computed using the Cartwright and Longuet-Higgins (1956) formulation.
Evaluates the integral to obtain the peak factor ``\psi``:
```math
\psi = \sqrt{2} \int_0^\infty 1 - \left( 1 - \xi \exp\left( -z^2 \right)\right)^{n_e} dz
```
where ``n_e`` is the number of extrema, ``\xi`` is the ratio ``n_z/n_e`` with ``n_z`` being the number of zero crossings.
The integral is evaluated using Gauss-Legendre integration -- and is suitable for use within an automatic differentiation environment.
See also: [`peak_factor`](@ref), [`peak_factor_dk80`](@ref)
"""
function peak_factor_cl56(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {S<:Real,T<:Real}
# get the numbers of zero crossing and extrema
rvt = RandomVibrationParameters(:CL56)
n_z, n_e = zeros_extrema_numbers(m, r_ps, fas, sdof, rvt)
# get the ratio of zero crossings to extrema
ξ = n_z / n_e
# compute the Gauss Legendre nodes and weights
if nodes != length(glxi)
glxi, glwi = gausslegendre(nodes)
end
z_min = 0.0
z_max = 8.0
dfac = (z_max-z_min)/2
pfac = (z_max+z_min)/2
# scale the nodes to the appropriate range
zi = @. dfac * glxi + pfac
# define the integrand
integrand(z) = 1.0 - (1.0 - ξ*exp(-z^2))^n_e
int_sum = dfac * dot( glwi, integrand.(zi) )
return sqrt(2.0) * int_sum
end
@doc raw"""
peak_factor_cl56(Dex::U, mi::SpectralMoments; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {U<:Real}
Peak factor computed using the Cartwright and Longuet-Higgins (1956) formulation, using pre-computed `Dex` and `m0` values.
Evaluates the integral to obtain the peak factor ``\psi``:
```math
\psi = \sqrt{2} \int_0^\infty 1 - \left( 1 - \xi \exp\left( -z^2 \right)\right)^{n_e} dz
```
where ``n_e`` is the number of extrema, ``\xi`` is the ratio ``n_z/n_e`` with ``n_z`` being the number of zero crossings.
The integral is evaluated using Gauss-Legendre integration -- and is suitable for use within an automatic differentiation environment.
See also: [`peak_factor`](@ref), [`peak_factor_dk80`](@ref)
"""
function peak_factor_cl56(Dex::U, mi::SpectralMoments; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {U<:Real}
# get all necessary spectral moments
m0 = mi.m0
m2 = mi.m2
m4 = mi.m4
# get the peak factor
n_z = Dex * sqrt( m2 / m0 ) / π
n_e = Dex * sqrt( m4 / m2 ) / π
# get the ratio of zero crossings to extrema
ξ = n_z / n_e
# compute the Gauss Legendre nodes and weights
if nodes != length(glxi)
glxi, glwi = gausslegendre(nodes)
end
z_min = 0.0
z_max = 8.0
dfac = (z_max-z_min)/2
pfac = (z_max+z_min)/2
# scale the nodes to the appropriate range
zi = @. dfac * glxi + pfac
# define the integrand
integrand(z) = 1.0 - (1.0 - ξ*exp(-z^2))^n_e
int_sum = dfac * dot( glwi, integrand.(zi) )
return sqrt(2.0) * int_sum
end
@doc raw"""
peak_factor_cl56(n_z::T, n_e::T; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where T<:Real
Peak factor computed using the Cartwright and Longuet-Higgins (1956) formulation, using pre-computed `n_z` and `n_e` values.
Evaluates the integral to obtain the peak factor ``\psi``:
```math
\psi = \sqrt{2} \int_0^\infty 1 - \left( 1 - \xi \exp\left( -z^2 \right)\right)^{n_e} dz
```
where ``n_e`` is the number of extrema, ``\xi`` is the ratio ``n_z/n_e`` with ``n_z`` being the number of zero crossings.
The integral is evaluated using Gauss-Legendre integration -- and is suitable for use within an automatic differentiation environment.
See also: [`peak_factor`](@ref), [`peak_factor_dk80`](@ref)
"""
function peak_factor_cl56(n_z::T, n_e::T; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where T<:Real
# get the ratio of zero crossings to extrema
ξ = n_z / n_e
# compute the Gauss Legendre nodes and weights
if nodes != length(glxi)
glxi, glwi = gausslegendre(nodes)
end
z_min = 0.0
z_max = 8.0
dfac = (z_max-z_min)/2
pfac = (z_max+z_min)/2
# scale the nodes to the appropriate range
zi = @. dfac * glxi + pfac
# define the integrand
integrand(z) = 1.0 - (1.0 - ξ*exp(-z^2))^n_e
int_sum = dfac * dot( glwi, integrand.(zi) )
pf = sqrt(2.0) * int_sum
return pf
end
@doc raw"""
peak_factor_cl56_gk(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator) where {S<:Real,T<:Real}
Peak factor computed using the Cartwright and Longuet-Higgins (1956) formulation, using adaptive Gauss-Kronrod integration.
Evaluates the integral to obtain the peak factor ``\psi``:
```math
\psi = \sqrt{2} \int_0^\infty 1 - \left( 1 - \xi \exp\left( -z^2 \right)\right)^{n_e} dz
```
where ``n_e`` is the number of extrema, ``\xi`` is the ratio ``n_z/n_e`` with ``n_z`` being the number of zero crossings.
The integral is evaluated using Gauss-Kronrod integration via the QuadGK.jl package -- and is not suitable for use within an automatic differentiation environment.
See also: [`peak_factor`](@ref), [`peak_factor_dk80`](@ref)
"""
function peak_factor_cl56_gk(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator) where {S<:Real,T<:Real}
# get the numbers of zero crossing and extrema
rvt = RandomVibrationParameters(:CL56)
n_z, n_e = zeros_extrema_numbers(m, r_ps, fas, sdof, rvt)
# get the ratio of zero crossings to extrema
ξ = n_z / n_e
# define the integrand
integrand(z) = 1.0 - (1.0 - ξ*exp(-z^2))^n_e
return sqrt(2.0) * quadgk(integrand, 0.0, Inf)[1]
end
"""
peak_factor_integrand_cl56(z, n_z, n_e)
Integrand of the Cartwright Longuet-Higgins (1956) peak factor formulation.
See also: [`peak_factor_cl56`](@ref)
"""
function peak_factor_integrand_cl56(z, n_z, n_e)
ξ = n_z / n_e
return 1.0 - (1.0 - ξ*exp(-z^2))^n_e
end
"""
vanmarcke_cdf(x, n_z::T, δeff::T) where T<:Real
CDF of the Vanmarcke (1975) peak factor distribution -- used within the Der Kiureghian (1980) peak factor expression.
"""
function vanmarcke_cdf(x, n_z::T, δeff::T) where T<:Real
if x < eps()
return zero(T)
else
xsq = x^2
eδe = exp( -sqrt(π/2) * δeff * x )
Fx = ( 1.0 - exp(-xsq/2) ) * exp( -n_z * (1.0 - eδe)/(exp(xsq/2) - 1.0) )
return Fx
end
end
"""
vanmarcke_ccdf(x, n_z::T, δeff::T) where T<:Real
CCDF of the Vanmarcke (1975) peak factor distribution -- used within the Der Kiureghian (1980) peak factor expression.
"""
function vanmarcke_ccdf(x, n_z::T, δeff::T) where T<:Real
return 1.0 - vanmarcke_cdf(x, n_z, δeff)
end
@doc raw"""
peak_factor_dk80(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {S<:Real,T<:Real}
Peak factor computed using the Der Kiureghian (1980)/Vanmarcke (1975) formulation.
Evaluates the integral to obtain the peak factor ``\psi``:
```math
\psi = \int_0^\infty 1 - F_Z(z)dz
```
where ``F_Z(z)`` is the CDF defined by:
```math
F_Z(z) = \left[ 1-\exp\left(-\frac{z^2}{2}\right) \right] \exp\left[ -n_z \frac{1 - \exp\left( -\sqrt{\frac{\pi}{2}}\delta_{eff} z \right)}{\exp\left(\frac{z^2}{2}\right) - 1} \right]
```
The effective bandwidth ``\delta_{eff}=\delta^{1.2}`` where the bandwidth is:
```math
\delta = \sqrt{ 1 - \frac{m_1^2}{m_0 m_2} }
```
The integral is evaluated using Gauss-Legendre integration -- and is suitable for use within an automatic differentiation environment.
See also: [`peak_factor`](@ref), [`peak_factor_cl56`](@ref)
"""
function peak_factor_dk80(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {S<:Real,T<:Real}
# compute first three spectral moments
mi = spectral_moments([0, 1, 2], m, r_ps, fas, sdof)
m0 = mi.m0
m1 = mi.m1
m2 = mi.m2
# bandwidth, and effective bandwidth
δ = sqrt( 1.0 - (m1^2 / (m0*m2)) )
δeff = δ^1.2
# excitation duration
Dex = boore_thompson_2014(m, r_ps, fas)
# number of zero crossings
n_z = Dex * sqrt( m2/m0 ) / π
# compute the Gauss Legendre nodes and weights
if nodes != length(glxi)
glxi, glwi = gausslegendre(nodes)
end
z_min = 0.0
z_max = 6.0
dfac = (z_max-z_min)/2
pfac = (z_max+z_min)/2
# scale the nodes to the appropriate range
zi = @. dfac * glxi + pfac
# evaluate integrand
yy = vanmarcke_ccdf.(zi, n_z, δeff)
return dfac * dot( glwi, yy )
end
@doc raw"""
peak_factor_dk80(Dex::U, mi::SpectralMoments; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {U<:Real}
Peak factor computed using the Der Kiureghian (1980)/Vanmarcke (1975) formulation, using precomputed `Dex` and `m0`.
Evaluates the integral to obtain the peak factor ``\psi``:
```math
\psi = \int_0^\infty 1 - F_Z(z)dz
```
where ``F_Z(z)`` is the CDF defined by:
```math
F_Z(z) = \left[ 1-\exp\left(-\frac{z^2}{2}\right) \right] \exp\left[ -n_z \frac{1 - \exp\left( -\sqrt{\frac{\pi}{2}}\delta_{eff} z \right)}{\exp\left(\frac{z^2}{2}\right) - 1} \right]
```
The effective bandwidth ``\delta_{eff}=\delta^{1.2}`` where the bandwidth is:
```math
\delta = \sqrt{ 1 - \frac{m_1^2}{m_0 m_2} }
```
The integral is evaluated using Gauss-Legendre integration -- and is suitable for use within an automatic differentiation environment.
See also: [`peak_factor`](@ref), [`peak_factor_cl56`](@ref)
"""
function peak_factor_dk80(Dex::U, mi::SpectralMoments; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {U<:Real}
# compute first three spectral moments
m0 = mi.m0
m1 = mi.m1
m2 = mi.m2
# bandwidth, and effective bandwidth
δ = sqrt( 1.0 - (m1^2 / (m0*m2)) )
δeff = δ^1.2
# number of zero crossings
n_z = Dex * sqrt( m2/m0 ) / π
# compute the Gauss Legendre nodes and weights
if nodes != length(glxi)
glxi, glwi = gausslegendre(nodes)
end
z_min = 0.0
z_max = 6.0
dfac = (z_max-z_min)/2
pfac = (z_max+z_min)/2
# scale the nodes to the appropriate range
zi = @. dfac * glxi + pfac
# evaluate integrand
yy = vanmarcke_ccdf.(zi, n_z, δeff)
return dfac * dot( glwi, yy )
end
@doc raw"""
peak_factor_dk80_gk(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator) where {S<:Float64,T<:Real}
Peak factor computed using the Der Kiureghian (1980)/Vanmarcke (1975) formulation, using precomputed `Dex` and `m0`.
Evaluates the integral to obtain the peak factor ``\psi``:
```math
\psi = \int_0^\infty 1 - F_Z(z)dz
```
where ``F_Z(z)`` is the CDF defined by:
```math
F_Z(z) = \left[ 1-\exp\left(-\frac{z^2}{2}\right) \right] \exp\left[ -n_z \frac{1 - \exp\left( -\sqrt{\frac{\pi}{2}}\delta_{eff} z \right)}{\exp\left(\frac{z^2}{2}\right) - 1} \right]
```
The effective bandwidth ``\delta_{eff}=\delta^{1.2}`` where the bandwidth is:
```math
\delta = \sqrt{ 1 - \frac{m_1^2}{m_0 m_2} }
```
The integral is evaluated using adaptive Gauss-Kronrod integration from the QuadGK.jl package -- and is therefore not suitable for use within an automatic differentiation environment.
See also: [`peak_factor`](@ref), [`peak_factor_dk80`](@ref), [`peak_factor_cl56`](@ref)
"""
function peak_factor_dk80_gk(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator) where {S<:Float64,T<:Real}
# compute first three spectral moments
mi = spectral_moments([0, 1, 2], m, r_ps, fas, sdof)
m0 = mi.m0
m1 = mi.m1
m2 = mi.m2
# bandwidth, and effective bandwidth
δ = sqrt( 1.0 - (m1^2 / (m0*m2)) )
δeff = δ^1.2
# excitation duration
Dex = boore_thompson_2014(m, r_ps, fas)
# number of zero crossings
n_z = Dex * sqrt( m2/m0 ) / π
integrand(x) = vanmarcke_ccdf(x, n_z, δeff)
return quadgk(integrand, 0.0, Inf)[1]
end
@doc raw"""
peak_factor(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {S<:Real,T<:Real}
Peak factor ``u_{max} / u_{rms}`` with a switch of `pf_method` to determine the approach adopted.
`rvt.pf_method` can currently be one of:
- `:CL56` for Cartright Longuet-Higgins (1956)
- `:DK80` for Der Kiureghian (1980), building on Vanmarcke (1975)
Defaults to `:DK80`.
"""
function peak_factor(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real}
if rvt.pf_method == :CL56
return peak_factor_cl56(m, r_ps, fas, sdof, glxi=glxi, glwi=glwi)
elseif rvt.pf_method == :DK80
return peak_factor_dk80(m, r_ps, fas, sdof, glxi=glxi, glwi=glwi)
else
U = get_parametric_type(fas)
return U(NaN)
end
end
"""
peak_factor(Dex::U, m0::V, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi)) where {U<:Real}
Peak factor u_max / u_rms with a switch of `pf_method` to determine the approach adopted.
`pf_method` can currently be one of:
- `:CL56` for Cartright Longuet-Higgins (1956)
- `:DK80` for Der Kiureghian (1980), building on Vanmarcke (1975)
Defaults to `:DK80`.
"""
function peak_factor(Dex::U, mi::SpectralMoments, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {U<:Real}
if rvt.pf_method == :CL56
return peak_factor_cl56(Dex, mi, glxi=glxi, glwi=glwi)
elseif rvt.pf_method == :DK80
return peak_factor_dk80(Dex, mi, glxi=glxi, glwi=glwi)
else
return U(NaN)
end
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 6927 |
const xn31i, wn31i = gausslegendre(31)
@doc raw"""
zeros_extrema_frequencies(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real}
Defines the frequencies of extrema and zero-crossings using moments ``m_0``, ``m_2`` and ``m_4``. Returns a tuple of ``(f_z,f_e)``.
The frequency of zero crossings is:
```math
f_{z} = \frac{1}{2\pi}\sqrt{\frac{m_2}{m_0}}
```
The frequency of extrema is:
```math
f_{e} = \frac{1}{2\pi}\sqrt{\frac{m_4}{m_2}}
```
See also: [`zeros_extrema_numbers`](@ref)
"""
function zeros_extrema_frequencies(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real}
mi = spectral_moments([0, 2, 4], m, r_ps, fas, sdof, glxi=glxi, glwi=glwi)
m_0 = mi.m0
m_2 = mi.m2
m_4 = mi.m4
fzero = sqrt( m_2 / m_0 ) / (2π)
fextrema = sqrt( m_4 / m_2 ) / (2π)
return fzero, fextrema
end
@doc raw"""
zeros_extrema_numbers(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters) where {S<:Real,T<:Real}
Defines the numbers of extrema and zero-crossings using moments ``m_0``, ``m_2`` and ``m_4``. Returns a tuple of ``(2f_z D_{ex}, 2f_e D_{ex})``.
The frequency of zero crossings is:
```math
n_{z} = \frac{D_{ex}}{\pi}\sqrt{\frac{m_2}{m_0}}
```
The frequency of extrema is:
```math
n_{e} = \frac{D_{ex}}{\pi}\sqrt{\frac{m_4}{m_2}}
```
In both cases, the excitaion duration, ``D_{ex}`` is computed from the `excitation_duration` function.
See also: [`zeros_extrema_frequencies`](@ref), [`excitation_duration`](@ref)
"""
function zeros_extrema_numbers(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real}
fz, fe = zeros_extrema_frequencies(m, r_ps, fas, sdof, glxi=glxi, glwi=glwi)
Dex = excitation_duration(m, r_ps, fas, rvt)
return 2fz*Dex, 2fe*Dex
end
@doc raw"""
rvt_response_spectral_ordinate(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real}
Response spectral ordinate (units of ``g``) for the specified scenario.
The spectral ordinate is computed using the expression:
```math
S_a = \psi \sqrt{\frac{m_0}{D_{rms}}}
```
where ``\psi`` is the peak factor computed from `peak_factor`, ``m_0`` is the zeroth order spectral moment from `spectral_moment`, and ``D_{rms}`` is the RMS duration computed from `rms_duration`.
See also: [`rvt_response_spectral_ordinate`](@ref), [`rvt_response_spectrum`](@ref), [`rvt_response_spectrum!`](@ref)
"""
function rvt_response_spectral_ordinate(m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real}
# get the duration metrics
Drms, Dex, ~ = rms_duration(m, r_ps, fas, sdof, rvt)
# compute the necessary spectral moments
if rvt.pf_method == :DK80
order = [0, 1, 2]
elseif rvt.pf_method == :CL56
order = [0, 2, 4]
end
mi = spectral_moments(order, m, r_ps, fas, sdof, glxi=glxi, glwi=glwi)
# get the rms response
y_rms = sqrt(mi.m0 / Drms)
# get the peak factor
pf = peak_factor(Dex, mi, rvt, glxi=glxi, glwi=glwi)
# response spectral value (in g)
Sa = pf * y_rms / 9.80665
return Sa
end
@doc raw"""
rvt_response_spectral_ordinate(period::U, m::S, r_ps::T, fas::FourierParameters, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real,U<:Float64}
Response spectral ordinate (units of ``g``) for the specified scenario.
The spectral ordinate is computed using the expression:
```math
S_a = \psi \sqrt{\frac{m_0}{D_{rms}}}
```
where ``\psi`` is the peak factor computed from `peak_factor`, ``m_0`` is the zeroth order spectral moment from `spectral_moment`, and ``D_{rms}`` is the RMS duration computed from `rms_duration`.
See also: [`rvt_response_spectral_ordinate`](@ref), [`rvt_response_spectrum`](@ref), [`rvt_response_spectrum!`](@ref)
"""
function rvt_response_spectral_ordinate(period::U, m::S, r_ps::T, fas::FourierParameters, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real,U<:Float64}
# create a sdof instance
sdof = Oscillator(1.0/period)
return rvt_response_spectral_ordinate(m, r_ps, fas, sdof, rvt, glxi=glxi, glwi=glwi)
end
@doc raw"""
rvt_response_spectrum(period::Vector{U}, m::S, r_ps::T, fas::FourierParameters, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real,U<:Float64}
Response spectrum (units of ``g``) for the vector of periods `period` and the specified scenario.
Each spectral ordinate is computed using the expression:
```math
S_a = \psi \sqrt{\frac{m_0}{D_{rms}}}
```
where ``\psi`` is the peak factor computed from `peak_factor`, ``m_0`` is the zeroth order spectral moment from `spectral_moment`, and ``D_{rms}`` is the RMS duration computed from `rms_duration`. The various terms are all functions of the oscillator period.
See also: [`rvt_response_spectral_ordinate`](@ref), [`rvt_response_spectrum!`](@ref)
"""
function rvt_response_spectrum(period::Vector{U}, m::S, r_ps::T, fas::FourierParameters, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real,U<:Float64}
if S <: Dual
Sa = zeros(S,length(period))
else
V = get_parametric_type(fas)
Sa = zeros(V,length(period))
end
for i in 1:length(period)
@inbounds Sa[i] = rvt_response_spectral_ordinate(period[i], m, r_ps, fas, rvt, glxi=glxi, glwi=glwi)
end
return Sa
end
@doc raw"""
rvt_response_spectrum!(Sa::Vector{U}, period::Vector{V}, m::S, r_ps::T, fas::FourierParameters, rvt::RandomVibrationParameters) where {S<:Real,T<:Real,U<:Real,V<:Float64}
In-place response spectrum (units of ``g``) for the vector of periods `period` and the specified scenario.
Each spectral ordinate is computed using the expression:
```math
S_a = \psi \sqrt{\frac{m_0}{D_{rms}}}
```
where ``\psi`` is the peak factor computed from `peak_factor`, ``m_0`` is the zeroth order spectral moment from `spectral_moment`, and ``D_{rms}`` is the RMS duration computed from `rms_duration`. The various terms are all functions of the oscillator period.
See also: [`rvt_response_spectral_ordinate`](@ref), [`rvt_response_spectrum!`](@ref)
"""
function rvt_response_spectrum!(Sa::Vector{U}, period::Vector{V}, m::S, r_ps::T, fas::FourierParameters, rvt::RandomVibrationParameters; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i) where {S<:Real,T<:Real,U<:Real,V<:Float64}
for i in 1:length(period)
@inbounds Sa[i] = rvt_response_spectral_ordinate(period[i], m, r_ps, fas, rvt, glxi=glxi, glwi=glwi)
end
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 1852 |
"""
RandomVibrationParameters
Struct holding parameters/methods for Random Vibration Theory.
- `pf_method` is the method used for peak factor computation
- `:DK80` (default) is Der Kiureghian (1980), building on Vanmarcke (1975)
- `:CL56` is Cartwright Longuet-Higgins (1956)
- `dur_ex` is the model for excitation duration
- `:BT14` (default) is the Boore & Thompson (2014) model for ACRs - note that this is adpated to work with `r_ps`
- `:BT15` is the Boore & Thompson (2015) model for SCRs
- `:BE23` is an excitation duration model from Ben Edwards (2023), suggested for a South African NPP project
- `dur_rms` is the model for rms duration
- `:BT12` is the Boore & Thompson (2012) model
- `:BT15` (default) is the Boore & Thompson (2015) model
- `:LP99` is the Liu & Pezeshk (1999) model linking rms, excitation and oscillator durations
- `dur_region` is the region specified for the duration model
- `:ACR` (default) is active crustal regions (like western North America)
- `:SCR` is stable crustal regions (like eastern North America)
Note that only certain combinations are meaningful:
- `:CL56` peak factor method should be paired with `:BT12` or `:LP99` rms duration
- `:DK80` peak factor method should be paired with `:BT15` rms duration
Constructors that take only the peak factor as input, or the peak factor and duration region automatically assign the appropriate rms duration method.
"""
struct RandomVibrationParameters
pf_method::Symbol
dur_ex::Symbol
dur_rms::Symbol
dur_region::Symbol
end
RandomVibrationParameters() = RandomVibrationParameters(:DK80, :BT15, :BT15, :ACR)
RandomVibrationParameters(pf) = RandomVibrationParameters(pf, :BT15, ((pf == :DK80) ? :BT15 : :BT12), :ACR)
RandomVibrationParameters(pf, region) = RandomVibrationParameters(pf, :BT15, ((pf == :DK80) ? :BT15 : :BT12), region)
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 8284 | """
@kwdef struct SpectralMoments{T<:Real}
Struct holding spectral moments `m0` to `m4`
"""
@kwdef struct SpectralMoments{T<:Real}
m0::T = NaN
m1::T = NaN
m2::T = NaN
m3::T = NaN
m4::T = NaN
end
"""
create_spectral_moments(order::Vector{Int}, value::Vector{T}) where {T<:Real}
Create a `SpectralMoments` instance from vectors of order integers and moment values.
Allows for encapsulation of named moments within the returned instance.
"""
function create_spectral_moments(order::Vector{Int}, value::Vector{T}) where {T<:Real}
dict = Dict{Symbol, T}()
for (i, o) in enumerate(order)
dict[Symbol("m$o")] = value[i]
end
return SpectralMoments{T}(; dict...)
end
@doc raw"""
spectral_moment(order::Int, m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; nodes::Int=31, control_freqs::Vector{Float64}=[1e-3, 1e-1, 1.0, 10.0, 100.0, 300.0] ) where {S<:Real,T<:Real}
Compute spectral moment of a specified order.
Evaluates the expression:
```math
m_k = 2\int_{0}^{\infty} \left(2\pi f\right)^k |H(f;f_n,\zeta_n)|^2 |A(f)|^2 df
```
where ``k`` is the order of the moment.
Integration is performed using Gauss-Legendre integration using `nodes` nodes and weights.
The integration domain is partitioned over the `control_freqs` as well as two inserted frequencies at `f_n/1.5` and `f_n*1.5` in order to ensure good approximation of the integral around the `sdof` resonant frequency.
See also: [`spectral_moments`](@ref)
"""
function spectral_moment(order::Int, m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int = length(glxi), control_freqs::Vector{Float64}=[1e-3, 1e-1, 1.0, 10.0, 100.0, 300.0]) where {S<:Real,T<:Real}
# pre-allocate for squared fourier amplitude spectrum
if S <: Dual
Af2 = Vector{S}(undef, nodes)
Hf2 = Vector{S}(undef, nodes)
int_sum = zero(S)
else
U = get_parametric_type(fas)
Af2 = Vector{U}(undef, nodes)
Hf2 = Vector{U}(undef, nodes)
int_sum = zero(U)
end
# partition the integration domain to make sure the integral captures the key change in the integrand
f_n = sdof.f_n
# note that we start slightly above zero to avoid a numerical issue with the frequency dependent Q(f) gradients
fidLO = findall(control_freqs .< f_n/1.5)
fidHI = findall(control_freqs .> f_n*1.5)
# perform the integration with a logarithmic transformation
lnflims = log.([ control_freqs[fidLO]; f_n/1.5; f_n*1.5; control_freqs[fidHI] ])
# compute the Gauss Legendre nodes and weights
if nodes != length(glxi)
glxi, glwi = gausslegendre(nodes)
end
for i in 2:lastindex(lnflims)
@inbounds dfac = (lnflims[i]-lnflims[i-1])/2
@inbounds pfac = (lnflims[i]+lnflims[i-1])/2
lnfi = @. dfac * glxi + pfac
fi = exp.(lnfi)
squared_transfer!(Hf2, fi, sdof)
squared_fourier_spectrum!(Af2, fi, m, r_ps, fas)
# note that the integrand here is scaled by exp(lnfi)=fi for the logarithmic transformation of the integrand
Yf2 = @. (2π * fi)^order * Hf2 * Af2 * fi
# weighted combination of amplitudes with Gauss-Legendre weights
int_sum += dfac * dot( glwi, Yf2 )
end
# return 2.0 * int_sum
return create_spectral_moments([order], [2.0 * int_sum])
end
@doc raw"""
spectral_moments(order::Vector{Int}, m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi), control_freqs::Vector{Float64}=[1e-3, 1e-1, 1.0, 10.0, 100.0, 300.0] ) where {S<:Real,T<:Real}
Compute a vector of spectral moments for the specified `order`.
Evaluates the expression:
```math
m_k = 2\int_{0}^{\infty} \left(2\pi f\right)^k |H(f;f_n,\zeta_n)|^2 |A(f)|^2 df
```
for each order, where ``k`` is the order of the moment.
Integration is performed using Gauss-Legendre integration using `nodes` nodes and weights.
The integration domain is partitioned over the `control_freqs` as well as two inserted frequencies at `f_n/1.5` and `f_n*1.5` in order to ensure good approximation of the integral around the `sdof` resonant frequency.
See also: [`spectral_moment`](@ref), [`spectral_moments_gk`](@ref)
"""
function spectral_moments(order::Vector{Int}, m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator; glxi::Vector{Float64}=xn31i, glwi::Vector{Float64}=wn31i, nodes::Int=length(glxi), control_freqs::Vector{Float64}=[1e-3, 1e-1, 1.0, 10.0, 100.0, 300.0]) where {S<:Real,T<:Real}
# partition the integration domain to make sure the integral captures the key change in the integrand
f_n = sdof.f_n
# note that we start slightly above zero to avoid a numerical issue with the frequency dependent Q(f) gradients
fidLO = findall(control_freqs .< f_n / 1.5)
fidHI = findall(control_freqs .> f_n * 1.5)
# perform the integration with a logarithmic transformation
lnflims = log.([control_freqs[fidLO]; f_n / 1.5; f_n * 1.5; control_freqs[fidHI]])
# number of frequency segments
num_freq_segs = length(lnflims) - 1
# compute the Gauss Legendre nodes and weights
if nodes != length(glxi)
glxi, glwi = gausslegendre(nodes)
end
# pre-allocate for squared fourier amplitude spectrum
if S <: Dual
Af2 = Vector{S}(undef, nodes * num_freq_segs)
Hf2 = Vector{S}(undef, nodes * num_freq_segs)
int_sumi = zeros(S, length(order))
else
U = get_parametric_type(fas)
Af2 = Vector{U}(undef, nodes * num_freq_segs)
Hf2 = Vector{U}(undef, nodes * num_freq_segs)
int_sumi = zeros(U, length(order))
end
# make sure the orders are listed as increasing for the following loop approach
sort!(order)
dorder = diff(order)
# generate a single set of frequencies and weights
dfaci = diff(lnflims) / 2
pfaci = (lnflims[1:(end-1)] .+ lnflims[2:end]) / 2
lnfii = zeros(nodes * num_freq_segs)
wii = zeros(nodes * num_freq_segs)
j = 1
for i in 1:num_freq_segs
k = j + nodes - 1
lnfii[j:k] .= @. dfaci[i] * glxi + pfaci[i]
wii[j:k] .= @. dfaci[i] * glwi
j = k + 1
end
fi = exp.(lnfii)
# now populate FAS and transfer function for these frequencies
squared_transfer!(Hf2, fi, sdof)
squared_fourier_spectrum!(Af2, fi, m, r_ps, fas)
# compute default zeroth order integrand amplitude
# note that the integrand here is scaled by exp(lnfi)=fi for the logarithmic transformation of the integrand
Yf2 = @. Hf2 * Af2 * fi
for (idx, o) in enumerate(order)
if idx == 1
Yf2 .*= (2π * fi) .^ o
else
@inbounds Yf2 .*= (2π * fi) .^ (dorder[idx-1])
end
# weighted combination of amplitudes with Gauss-Legendre weights
@inbounds int_sumi[idx] = dot(wii, Yf2)
end
# return the spectral moments in a named tuple using the `create_spectral_moments` function
return create_spectral_moments(order, 2.0 * int_sumi)
end
@doc raw"""
spectral_moments_gk(order::Vector{Int}, m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator) where {S<:Real,T<:Real}
Compute a vector of spectral moments for the specified `order` using Gauss-Kronrod integration from the `QuadGK.jl` package.
Evaluates the expression:
```math
m_k = 2\int_{0}^{\infty} \left(2\pi f\right)^k |H(f;f_n,\zeta_n)|^2 |A(f)|^2 df
```
for each order, where ``k`` is the order of the moment.
Integration is performed using adaptive Gauss-Kronrod integration with the domain split over two intervals from ``[0,f_n]`` and ``[f_n,\infty]`` to ensure that the resonant peak is not missed.
Note that due to the default tolerances, the moments computed by this method are more accurate than those from `spectral_moments` using the Gauss-Legendre approximation. However, this method is also significantly slower, and cannot be used within an automatic differentiation environment.
See also: [`spectral_moment`](@ref), [`spectral_moments`](@ref)
"""
function spectral_moments_gk(order::Vector{Int}, m::S, r_ps::T, fas::FourierParameters, sdof::Oscillator) where {S<:Real,T<:Real}
int_sumi = zeros(length(order))
for (i, o) in enumerate(order)
moment_integrand(f) = squared_transfer(f, sdof) * squared_fourier_spectral_ordinate(f, m, r_ps, fas) * (2π*f)^o
int_sumi[i] = quadgk(moment_integrand, 0.0, sdof.f_n, Inf)[1]
end
# return 2.0 * int_sumi
return create_spectral_moments(order, 2.0 * int_sumi)
end | StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | code | 109862 | using StochasticGroundMotionSimulation
using Test
using ForwardDiff
using ForwardDiff: Dual
using FastGaussQuadrature
using QuadGK
using LinearAlgebra
using StaticArrays
# using Distributions
# using BenchmarkTools
@testset "StochasticGroundMotionSimulation.jl" begin
@testset "Performance" begin
# @testset "Allocation Testing" begin
# src = SourceParameters(100.0)
# geo = GeometricSpreadingParameters([1.0, Inf], [1.0], :Piecewise)
# sat = NearSourceSaturationParameters(:BT15)
# ane = AnelasticAttenuationParameters(180.0, 0.45, :Rps)
# path = PathParameters(geo, sat, ane)
# site = SiteParameters(0.03)
# fas = FourierParameters(src, path, site)
# rvt = RandomVibrationParameters()
# function run_sims(T, num_sims, fas, rvt)
# md = Uniform(2.0, 8.0)
# rd = Uniform(1.0, 100.0)
# mi = rand(md, num_sims)
# ri = rand(rd, num_sims)
# Sai = zeros(num_sims)
# for i in 1:num_sims
# Sai[i] = rvt_response_spectral_ordinate(T, mi[i], ri[i], fas, rvt)
# end
# return sum(Sai)
# end
# T = 0.123
# num_sims = 100
# @benchmark run_sims(T, num_sims, fas, rvt)
# num_sims = 1_000
# @benchmark run_sims(T, num_sims, fas, rvt)
# end
Ti = [0.01, 0.02, 0.03, 0.04, 0.05, 0.075, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0, 7.5, 10.0]
m = 4.0 + π
r = 500.0 + π
src = SourceParameters(100.0)
geo = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.5])
ane = AnelasticAttenuationParameters(200.0, 0.4)
sat = NearSourceSaturationParameters(:BT15)
path = PathParameters(geo, sat, ane)
site = SiteParameters(0.039)
fas = FourierParameters(src, path, site)
rvt = RandomVibrationParameters(:DK80)
sdof = Oscillator(1.0)
# @code_warntype Oscillator(1.0)
# @code_warntype period(sdof)
# @code_warntype transfer(1.0, sdof)
# @code_warntype rvt_response_spectral_ordinate(Ti[1], m, r, fas, rvt)
# @code_warntype rvt_response_spectrum(Ti, m, r, fas, rvt)
# @time Sai = rvt_response_spectrum(Ti, m, r, fas, rvt)
# @profile Sai = rvt_response_spectrum(Ti, m, r, fas, rvt)
end
@testset "Source" begin
m = 6.0
Δσ = 100.0
β = 3.5
# @code_warntype magnitude_to_moment(m)
#
# @code_warntype corner_frequency_brune(m, Δσ)
# @code_warntype corner_frequency_brune(m, Δσ, β)
# @code_warntype corner_frequency_atkinson_silva_2000(m)
srcf = SourceParameters(Δσ)
srcd = SourceParameters(Dual{Float64}(Δσ))
# @code_warntype corner_frequency(m, srcf)
# @code_warntype corner_frequency(m, srcd)
# @code_warntype corner_frequency(Dual(m), srcf)
# @code_warntype corner_frequency(Dual(m), srcd)
T = StochasticGroundMotionSimulation.get_parametric_type(srcf)
@test T == Float64
T = StochasticGroundMotionSimulation.get_parametric_type(srcd)
@test T <: Dual
faf, fbf, fεf = corner_frequency(m, srcf)
fad, fbd, fεd = corner_frequency(m, srcd)
# @time faf, fbf, fεf = corner_frequency(m, srcf)
# @time fad, fbd, fεd = corner_frequency(m, srcd)
@test faf == fad.value
srcf = SourceParameters(Δσ, :Atkinson_Silva_2000)
srcd = SourceParameters(Dual{Float64}(Δσ), :Atkinson_Silva_2000)
faf, fbf, fεf = corner_frequency(m, srcf)
fad, fbd, fεd = corner_frequency(m, srcd)
# @time faf, fbf, fεf = corner_frequency(m, srcf)
# @time fad, fbd, fεd = corner_frequency(m, srcd)
@test faf == fad.value
@test fbf == fbd.value
@test fεf == fεd.value
srcd = SourceParameters(Dual(100.0), 3.5, 2.75)
srcf = SourceParameters(100.0, 3.5, 2.75)
@test srcd.Δσ.value == srcf.Δσ
@test StochasticGroundMotionSimulation.magnitude_to_moment(6.0) ≈ exp10(25.05)
@testset "Beresnev (2019)" begin
Δσ = 100.0
n = 1.0
srcb = SourceParameters(Δσ, n)
srcω = SourceParameters(Δσ)
f = 25.0
m = 5.0
Afb = fourier_source_shape(f, m, srcb)
Afω = fourier_source_shape(f, m, srcω)
@test Afb ≈ Afω
srcb1p5 = SourceParameters(Δσ, 1.5)
Afb1p5 = fourier_source_shape(f, m, srcb1p5)
@test Afb > Afb1p5
Δσd = Dual{Float64}(Δσ)
nd = Dual{Float64}(n)
srcdd = SourceParameters(Δσd, nd)
srcdf = SourceParameters(Δσd, n)
@test fourier_source_shape(f, m, srcdd) ≈ fourier_source_shape(f, m, srcb)
@test fourier_source_shape(f, m, srcdf) ≈ fourier_source_shape(f, m, srcb)
end
end
@testset "Path" begin
Rrefi = [1.0, 50.0, Inf]
γi = [1.0, 0.5]
@testset "Geometric Spreading Constructors" begin
# test floating point instantiation
@test typeof(GeometricSpreadingParameters(Rrefi, γi)) <: GeometricSpreadingParameters
# test Dual instantiation
@test typeof(GeometricSpreadingParameters(Rrefi, [0.5], [Dual{Float64}(1.0)], BitVector([1, 0]), :Piecewise)) <: GeometricSpreadingParameters
geo = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.5])
geoc = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.5], :CY14)
@test geo.model == :Piecewise
@test geoc.model == :CY14
geod = GeometricSpreadingParameters([1.0, 50.0, Inf], [Dual(1.0), Dual(0.5)])
@test geo.γconi[1] == geod.γvari[1].value
geo_mix = GeometricSpreadingParameters([1.0, Dual{Float64}(50.0), Inf], [1.0, 0.5])
@test geo_mix.model == :Piecewise
end
geof = GeometricSpreadingParameters(Rrefi, γi)
geod = GeometricSpreadingParameters(Rrefi, [0.5], [Dual{Float64}(1.0)], BitVector([1, 0]), :Piecewise)
geom = GeometricSpreadingParameters([1.0, Dual{Float64}(50.0), Inf], [1.0, 0.5])
@testset "Geometric Spreading Types" begin
T = StochasticGroundMotionSimulation.get_parametric_type(geof)
@test T == Float64
T = StochasticGroundMotionSimulation.get_parametric_type(geod)
@test T <: Dual
T = StochasticGroundMotionSimulation.get_parametric_type(geom)
@test T <: Dual
end
@testset "Near Source Saturation Constructors" begin
# test standard instantiation with known models
@test typeof(NearSourceSaturationParameters(:BT15)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters(:YA15)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters(:CY14)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters(:CY14mod)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters(1, :BT15)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters([5.5, 7.0, Inf], [4.0, 6.0], :ConstantConstrained)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters([5.5, 7.0, Inf], [Dual(4.0), Dual(6.0)], :ConstantVariable)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters([5.5, 7.0, Inf], [4.0, 6.0])) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters([5.5, 7.0, Inf], [Dual(4.0), Dual(6.0)])) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters(5.0)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters(Dual(5.0))) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters(5.0, 2)) <: NearSourceSaturationParameters
@test typeof(NearSourceSaturationParameters(Dual(5.0), 2)) <: NearSourceSaturationParameters
end
sat = NearSourceSaturationParameters(:BT15)
satd = NearSourceSaturationParameters(Dual{Float64}(5.0))
@testset "Near Source Saturation Types" begin
T = StochasticGroundMotionSimulation.get_parametric_type(sat)
@test T == Float64
end
@testset "Anelastic Attenuation Constructors" begin
# test floating point instantiation
@test typeof(AnelasticAttenuationParameters(200.0)) <: AnelasticAttenuationParameters
# test Dual instantiation
@test typeof(AnelasticAttenuationParameters(Dual{Float64}(200.0))) <: AnelasticAttenuationParameters
ane = AnelasticAttenuationParameters(200.0, 0.5, 3.5)
@test ane.rmetric == :Rps
ane = AnelasticAttenuationParameters(200.0, 0.5, 3.5, :Rrup)
@test ane.rmetric == :Rrup
# test the segmented versions
# scalar inputs (internally mapped to vectors)
@test typeof(AnelasticAttenuationParameters(200.0, 0.5, :Rrup)) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters(200.0, Dual{Float64}(0.5), :Rrup)) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters(Dual{Float64}(200.0), 0.5, :Rrup)) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters(Dual{Float64}(200.0), Dual{Float64}(0.5), :Rrup)) <: AnelasticAttenuationParameters
# vector inputs
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0, 200.0])) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0, 200.0], :Rrup)) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [Dual{Float64}(200.0), Dual{Float64}(200.0)])) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [Dual{Float64}(200.0), Dual{Float64}(200.0)], :Rrup)) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0, 200.0], [0.5, 0.5])) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0, 200.0], [0.5, 0.5], :Rrup)) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [Dual{Float64}(200.0), Dual{Float64}(200.0)], [Dual{Float64}(0.5), Dual{Float64}(0.5)])) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [Dual{Float64}(200.0), Dual{Float64}(200.0)], [Dual{Float64}(0.5), Dual{Float64}(0.5)], :Rrup)) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0, 200.0], [Dual{Float64}(0.5), Dual{Float64}(0.5)])) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0, 200.0], [Dual{Float64}(0.5), Dual{Float64}(0.5)], :Rrup)) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [Dual{Float64}(200.0), Dual{Float64}(200.0)], [0.5, 0.5])) <: AnelasticAttenuationParameters
@test typeof(AnelasticAttenuationParameters([0.0, 80.0, Inf], [Dual{Float64}(200.0), Dual{Float64}(200.0)], [0.5, 0.5], :Rrup)) <: AnelasticAttenuationParameters
end
Q0 = 200.0
anef = AnelasticAttenuationParameters(Q0)
aned = AnelasticAttenuationParameters(Dual{Float64}(Q0))
@testset "Anelastic Attenuation Types" begin
T = StochasticGroundMotionSimulation.get_parametric_type(anef)
@test T == Float64
T = StochasticGroundMotionSimulation.get_parametric_type(aned)
@test T <: Dual
# artificial test, but for ensuring complete coverage
anet = AnelasticAttenuationParameters([Dual{Float64}(0.0), Dual{Float64}(Inf)], [Dual{Float64}(200.0)], Vector{Dual{Float64,Float64,0}}(), zeros(Dual{Float64,Float64,0}, 1), zeros(Dual{Float64,Float64,0}, 1), [3.5], BitVector(ones(1)), BitVector(ones(1)), :Rps)
T = StochasticGroundMotionSimulation.get_parametric_type(anet)
@test T <: Dual
end
@testset "Path Constructors" begin
# test floating point components
@test typeof(PathParameters(geof, sat, anef)) <: PathParameters
# test Dual components
@test typeof(PathParameters(geod, sat, aned)) <: PathParameters
path = PathParameters(geof, anef)
@test path.saturation.model == :None
path = PathParameters(geof, satd, anef)
@test StochasticGroundMotionSimulation.get_parametric_type(path) <: Dual
end
pathf = PathParameters(geof, sat, anef)
pathd = PathParameters(geod, sat, aned)
@testset "Path Types" begin
T = StochasticGroundMotionSimulation.get_parametric_type(pathf)
@test T == Float64
T = StochasticGroundMotionSimulation.get_parametric_type(pathd)
@test T <: Dual
end
r = 10.0
m = 6.0
@testset "Geometric Spreading Functionality" begin
geo_cy14 = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.5], :CY14)
geo_cy14mod = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.5], :CY14mod)
geo_null = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.5], :Null)
sat = NearSourceSaturationParameters(:BT15)
r_ps = equivalent_point_source_distance(r, m, sat)
gr_cy14 = geometric_spreading(r_ps, m, geo_cy14, sat)
gr_cy14mod = geometric_spreading(r_ps, m, geo_cy14mod, sat)
@test gr_cy14mod < gr_cy14
@test isnan(geometric_spreading(r_ps, m, geo_null, sat))
grp = geometric_spreading(r_ps, pathf)
fasf = FourierParameters(SourceParameters(50.0), pathf)
grf = geometric_spreading(r_ps, fasf)
@test grp == grf
geop = GeometricSpreadingParameters([1.0, Inf], [1.0], Vector{Float64}(), BitVector(undef, 0), :Piecewise)
@test StochasticGroundMotionSimulation.geometric_spreading_piecewise(r_ps, geop) == 1.0
@test StochasticGroundMotionSimulation.geometric_spreading_piecewise(Dual(r_ps), geop) == 1.0
fasp = FourierParameters(SourceParameters(50.0), PathParameters(geop, sat, anef))
@test StochasticGroundMotionSimulation.geometric_spreading_piecewise(r_ps, fasp) == 1.0
@test StochasticGroundMotionSimulation.geometric_spreading_piecewise(Dual(r_ps), fasp) == 1.0
geo_cy14d = GeometricSpreadingParameters([1.0, 50.0, Inf], [Dual(1.0), Dual(1.0)], :CY14)
sat = NearSourceSaturationParameters(:None)
r_ps = equivalent_point_source_distance(1.0, -5.0, sat)
fas_cy14d = FourierParameters(SourceParameters(50.0), PathParameters(geo_cy14d, sat, anef))
@test StochasticGroundMotionSimulation.geometric_spreading_cy14(r_ps, fas_cy14d).value ≈ 1.0
geo_cy14d = GeometricSpreadingParameters([1.0, 50.0, Inf], [Dual(1.0), Dual(1.0)], :CY14mod)
sat = NearSourceSaturationParameters(:None)
r_ps = equivalent_point_source_distance(1.0, -5.0, sat)
fas_cy14d = FourierParameters(SourceParameters(50.0), PathParameters(geo_cy14d, sat, anef))
@test StochasticGroundMotionSimulation.geometric_spreading_cy14mod(r_ps, -5.0, fas_cy14d).value ≈ 1.0
# @code_warntype equivalent_point_source_distance(r, m, pathf)
# @code_warntype equivalent_point_source_distance(r, m, pathd)
r_psf = equivalent_point_source_distance(r, m, pathf)
r_psd = equivalent_point_source_distance(r, m, pathd)
# @code_warntype StochasticGroundMotionSimulation.geometric_spreading_piecewise(r, geof)
# @code_warntype StochasticGroundMotionSimulation.geometric_spreading_piecewise(r, geod)
grf = StochasticGroundMotionSimulation.geometric_spreading_piecewise(r, geof)
grd = StochasticGroundMotionSimulation.geometric_spreading_piecewise(r, geod)
@test grf == grd.value
# @code_warntype StochasticGroundMotionSimulation.geometric_spreading_cy14(r, geof)
# @code_warntype StochasticGroundMotionSimulation.geometric_spreading_cy14(r, geod)
grf = StochasticGroundMotionSimulation.geometric_spreading_cy14(r, geof)
grd = StochasticGroundMotionSimulation.geometric_spreading_cy14(r, geod)
@test grf == grd.value
# @code_warntype geometric_spreading(r, geof)
# @code_warntype geometric_spreading(r, geod)
grf = geometric_spreading(r, m, geof, sat)
grd = geometric_spreading(r, m, geod, sat)
@test grf == grd.value
end
@testset "Near Source Saturation Functionality" begin
# @code_warntype near_source_saturation(m, pathf.saturation)
# @code_warntype near_source_saturation(m, pathd.saturation)
hf = near_source_saturation(m, pathf.saturation)
hd = near_source_saturation(m, pathd.saturation)
if StochasticGroundMotionSimulation.get_parametric_type(pathd.saturation) <: Dual
@test hf == hd.value
else
@test hf == hd
end
src = SourceParameters(100.0)
geo = GeometricSpreadingParameters([1.0, Inf], [1.0])
ane = AnelasticAttenuationParameters(200.0, 0.5)
sat_ya = NearSourceSaturationParameters(:YA15)
sat_cy = NearSourceSaturationParameters(:CY14)
sat_sea = NearSourceSaturationParameters(:SEA21)
sat_none = NearSourceSaturationParameters(:None)
sat_con = NearSourceSaturationParameters(5.0)
sat_var = NearSourceSaturationParameters(Dual(5.0))
sat_null = NearSourceSaturationParameters(:Null)
path_ya = PathParameters(geo, sat_ya, ane)
path_cy = PathParameters(geo, sat_cy, ane)
path_sea = PathParameters(geo, sat_sea, ane)
path_none = PathParameters(geo, sat_none, ane)
path_con = PathParameters(geo, sat_con, ane)
path_var = PathParameters(geo, sat_var, ane)
path_null = PathParameters(geo, sat_null, ane)
h_ya = near_source_saturation(5.0, sat_ya)
h_cy = near_source_saturation(5.0, sat_cy)
h_sea = near_source_saturation(5.0, sat_sea)
h_none = near_source_saturation(5.0, sat_none)
h_con = near_source_saturation(5.0, sat_con)
h_var = near_source_saturation(5.0, sat_var)
h_null = near_source_saturation(5.0, sat_null)
@test h_con == h_var.value
end
f = 1.0
r = 100.0
@testset "Anelastic Attenuation Functionality" begin
# @code_warntype anelastic_attenuation(f, r, anef)
# @code_warntype anelastic_attenuation(f, r, aned)
qrf = anelastic_attenuation(f, r, anef)
qrd = anelastic_attenuation(f, r, aned)
@test qrf ≈ qrd.value
fas = FourierParameters(SourceParameters(100.0), pathf)
q_r = anelastic_attenuation(f, r, fas)
@test qrf ≈ q_r
f = [0.01, 0.1, 1.0, 10.0, 100.0]
nf = length(f)
qrf = anelastic_attenuation(f, r, anef)
qrd = anelastic_attenuation(f, r, aned)
@test qrf ≈ map(q -> q.value, qrd)
fasf = FourierParameters(SourceParameters(100.0), pathf)
fasd = FourierParameters(SourceParameters(100.0), pathd)
q_r = anelastic_attenuation(f, r, fas)
@test qrf ≈ q_r
Aff = ones(eltype(qrf), nf)
Afd = ones(eltype(qrd), nf)
StochasticGroundMotionSimulation.apply_anelastic_attenuation!(Aff, f, r, anef)
StochasticGroundMotionSimulation.apply_anelastic_attenuation!(Afd, f, r, aned)
@test Aff ≈ map(a -> a.value, Afd)
Aff = ones(eltype(qrf), nf)
Afd = ones(eltype(qrd), nf)
StochasticGroundMotionSimulation.apply_anelastic_attenuation!(Aff, f, r, fasf)
StochasticGroundMotionSimulation.apply_anelastic_attenuation!(Afd, f, r, fasd)
@test Aff ≈ map(a -> a.value, Afd)
Qff = ones(nf)
Qfd = ones(eltype(qrd), nf)
StochasticGroundMotionSimulation.anelastic_attenuation!(Qff, f, r, anef)
StochasticGroundMotionSimulation.anelastic_attenuation!(Qfd, f, r, aned)
@test Qff ≈ map(a -> a.value, Qfd)
end
@testset "Anelastic Attenuation Segmentation" begin
# test the vector descriptions of anelastic attenuation
ane_vec = AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0, 200.0], [0.4, 0.4])
ane_con = AnelasticAttenuationParameters(200.0, 0.4)
@test anelastic_attenuation(5.0, 50.0, ane_vec) ≈ anelastic_attenuation(5.0, 50.0, ane_con)
@test anelastic_attenuation(5.0, 150.0, ane_vec) ≈ anelastic_attenuation(5.0, 150.0, ane_con)
ane_vecd = AnelasticAttenuationParameters([0.0, 80.0, Inf], [Dual(200.0), Dual(200.0)], [0.4, 0.4])
ane_cond = AnelasticAttenuationParameters(Dual(200.0), 0.4)
@test anelastic_attenuation(5.0, 50.0, ane_vecd) ≈ anelastic_attenuation(5.0, 50.0, ane_cond)
@test anelastic_attenuation(5.0, 150.0, ane_vecd) ≈ anelastic_attenuation(5.0, 150.0, ane_cond)
ane_vecd = AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0, 200.0], [Dual(0.4), Dual(0.4)])
ane_cond = AnelasticAttenuationParameters(200.0, Dual(0.4))
@test anelastic_attenuation(5.0, 50.0, ane_vecd) ≈ anelastic_attenuation(5.0, 50.0, ane_cond)
@test anelastic_attenuation(5.0, 150.0, ane_vecd) ≈ anelastic_attenuation(5.0, 150.0, ane_cond)
ane_vecd = AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0], [Dual(200.0)], [0.4], [Dual(0.4)], 3.5 * ones(2), BitVector([1, 0]), BitVector([0, 1]), :Rrup)
ane_cond = AnelasticAttenuationParameters(200.0, 0.4)
@test anelastic_attenuation(5.0, 50.0, ane_vecd) ≈ anelastic_attenuation(5.0, 50.0, ane_cond)
@test anelastic_attenuation(5.0, 150.0, ane_vecd) ≈ anelastic_attenuation(5.0, 150.0, ane_cond)
ane_vecd = AnelasticAttenuationParameters([0.0, 80.0, Inf], [200.0], [Dual(200.0)], [0.4], [Dual(0.4)], 3.5 * ones(2), BitVector([0, 1]), BitVector([1, 0]), :Rrup)
ane_cond = AnelasticAttenuationParameters(200.0, 0.4)
@test anelastic_attenuation(5.0, 50.0, ane_vecd) ≈ anelastic_attenuation(5.0, 50.0, ane_cond)
@test anelastic_attenuation(5.0, 150.0, ane_vecd) ≈ anelastic_attenuation(5.0, 150.0, ane_cond)
ane_inf = AnelasticAttenuationParameters([0.0, 80.0, Inf], [Inf], [Dual{Float64}(200.0)], [0.0], [Dual{Float64}(0.5)], 3.5 * ones(2), BitVector([0, 1]), BitVector([0, 1]), :Rrup)
@test anelastic_attenuation(5.0, 50.0, ane_inf) == 1.0
f_vec = [0.1, 1.0, 10.0, 100.0]
nf = length(f_vec)
q_vec = anelastic_attenuation(f_vec, 200.0, ane_vec)
q_con = anelastic_attenuation(f_vec, 200.0, ane_con)
@test q_vec ≈ q_con
Afv = ones(nf)
Afc = ones(nf)
ζ0f = 0.039
ηf = 0.75
site = SiteParameters(ζ0f, ηf)
StochasticGroundMotionSimulation.apply_fourier_path_and_site_attenuation!(Afv, f_vec, 200.0, ane_vec, site)
StochasticGroundMotionSimulation.apply_fourier_path_and_site_attenuation!(Afc, f_vec, 200.0, ane_con, site)
@test Afv ≈ Afc
Afv = ones(nf)
Afc = ones(nf)
StochasticGroundMotionSimulation.apply_anelastic_attenuation!(Afv, f_vec, 200.0, ane_vec)
StochasticGroundMotionSimulation.apply_anelastic_attenuation!(Afc, f_vec, 200.0, ane_con)
@test Afv ≈ Afc
Kfv = ones(nf)
Kfc = ones(nf)
StochasticGroundMotionSimulation.anelastic_attenuation!(Kfv, f_vec, 200.0, ane_vec)
StochasticGroundMotionSimulation.anelastic_attenuation!(Kfc, f_vec, 200.0, ane_con)
@test Kfv ≈ Kfc
@test Kfv ≈ Afv
Kfv = anelastic_attenuation(f_vec, 200.0, ane_vecd)
Kfc = anelastic_attenuation(f_vec, 200.0, ane_cond)
StochasticGroundMotionSimulation.anelastic_attenuation!(Kfv, f_vec, 200.0, ane_vecd)
StochasticGroundMotionSimulation.anelastic_attenuation!(Kfc, f_vec, 200.0, ane_cond)
@test Kfv ≈ Kfc
@test Kfv ≈ Afv
end
end
@testset "Site" begin
κ0f = 0.039
κ0d = Dual{Float64}(κ0f)
ζ0f = 0.039
ζ0d = Dual{Float64}(ζ0f)
ηf = 0.75
ηd = Dual{Float64}(ηf)
@testset "Site Constructors" begin
@test typeof(SiteAmpUnit()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpConstant(2.0)) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpBoore2016_760()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_ask14_620()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_ask14_760()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_ask14_1100()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_bssa14_620()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_bssa14_760()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_bssa14_1100()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_cb14_620()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_cb14_760()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_cb14_1100()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_cy14_620()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_cy14_760()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteAmpAlAtikAbrahamson2021_cy14_1100()) <: StochasticGroundMotionSimulation.SiteAmplification
@test typeof(SiteParameters(κ0f)) <: SiteParameters
@test typeof(SiteParameters(κ0f, SiteAmpAlAtikAbrahamson2021_cy14_760())) <: SiteParameters
@test typeof(SiteParameters(κ0f, SiteAmpBoore2016_760())) <: SiteParameters
@test typeof(SiteParameters(κ0f, SiteAmpUnit())) <: SiteParameters
@test typeof(SiteParameters(κ0f, SiteAmpConstant(2.0))) <: SiteParameters
@test typeof(SiteParameters(κ0d)) <: SiteParameters
@test typeof(SiteParameters(κ0d, SiteAmpAlAtikAbrahamson2021_cy14_760())) <: SiteParameters
@test typeof(SiteParameters(κ0d, SiteAmpBoore2016_760())) <: SiteParameters
@test typeof(SiteParameters(κ0d, SiteAmpUnit())) <: SiteParameters
@test typeof(SiteParameters(ζ0f, ηf)) <: SiteParameters
@test typeof(SiteParameters(ζ0d, ηf)) <: SiteParameters
@test typeof(SiteParameters(ζ0f, ηd)) <: SiteParameters
@test typeof(SiteParameters(ζ0d, ηd)) <: SiteParameters
@test typeof(SiteParameters(ζ0f, ηf, SiteAmpAlAtikAbrahamson2021_cy14_760())) <: SiteParameters
@test typeof(SiteParameters(ζ0d, ηf, SiteAmpAlAtikAbrahamson2021_cy14_760())) <: SiteParameters
@test typeof(SiteParameters(ζ0f, ηd, SiteAmpAlAtikAbrahamson2021_cy14_760())) <: SiteParameters
@test typeof(SiteParameters(ζ0d, ηd, SiteAmpAlAtikAbrahamson2021_cy14_760())) <: SiteParameters
end
site0f = SiteParameters(κ0f)
siteAf = SiteParameters(κ0f, SiteAmpAlAtikAbrahamson2021_cy14_760())
siteBf = SiteParameters(κ0f, SiteAmpBoore2016_760())
siteUf = SiteParameters(κ0f, SiteAmpUnit())
siteCf = SiteParameters(κ0f, SiteAmpConstant(2.0))
site0d = SiteParameters(κ0d)
siteAd = SiteParameters(κ0d, SiteAmpAlAtikAbrahamson2021_cy14_760())
siteBd = SiteParameters(κ0d, SiteAmpBoore2016_760())
siteUd = SiteParameters(κ0d, SiteAmpUnit())
siteCd = SiteParameters(κ0d, SiteAmpConstant(2.0))
f = 0.05
@testset "Site Amplification" begin
# @code_warntype site_amplification(f, site0f)
# @code_warntype site_amplification(f, site0d)
Sff = site_amplification(f, site0f)
Sfd = site_amplification(f, site0d)
@test Sff == Sfd
Af0f = site_amplification(f, site0f)
Af1f = site_amplification(f, siteAf)
Af2f = site_amplification(f, siteBf)
Af3f = site_amplification(f, siteUf)
Af4f = site_amplification(f, siteCf)
@test Af0f == Af1f
@test Af3f == 1.0
@test Af2f < Af1f
@test Af4f == 2.0
Af0d = site_amplification(f, site0d)
Af1d = site_amplification(f, siteAd)
Af2d = site_amplification(f, siteBd)
Af3d = site_amplification(f, siteUd)
Af4d = site_amplification(f, siteCd)
@test Af0d == Af1d
@test Af3d == 1.0
@test Af2d < Af1d
@test Af4d == 2.0
@test Af0f == Af0d
@test Af4f == Af4d
f0 = 80.0
f1 = 100.0
Af0 = site_amplification(f0, siteBf)
Af1 = site_amplification(f1, siteBf)
@test Af0 ≈ Af1 atol=1e-2
ft = 10.0
Af620 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_ask14_620()))
Af760 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_ask14_760()))
Af1100 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_ask14_1100()))
@test Af620 > Af760
@test Af760 > Af1100
Af620 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_bssa14_620()))
Af760 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_bssa14_760()))
Af1100 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_bssa14_1100()))
@test Af620 > Af760
@test Af760 > Af1100
Af620 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_cb14_620()))
Af760 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_cb14_760()))
Af1100 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_cb14_1100()))
@test Af620 > Af760
@test Af760 > Af1100
Af620 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_cy14_620()))
Af760 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_cy14_760()))
Af1100 = site_amplification(ft, SiteParameters(0.039, SiteAmpAlAtikAbrahamson2021_cy14_1100()))
@test Af620 > Af760
@test Af760 > Af1100
end
@testset "Impedance Functions" begin
sa = SiteAmpBoore2016_760()
@test sa.amplification(0.015) ≈ 1.01 rtol = 1e-5
fi = @SVector [0.001, 0.010, 0.015, 0.021, 0.031, 0.045, 0.065, 0.095, 0.138, 0.200, 0.291, 0.423, 0.615, 0.894, 1.301, 1.892, 2.751, 4.000, 5.817, 8.459, 12.301, 17.889, 26.014, 37.830, 55.012, 80.000, 1e3]
Ai = @SVector [1.00, 1.00, 1.01, 1.02, 1.02, 1.04, 1.06, 1.09, 1.13, 1.18, 1.25, 1.32, 1.41, 1.51, 1.64, 1.80, 1.99, 2.18, 2.38, 2.56, 2.75, 2.95, 3.17, 3.42, 3.68, 3.96, 3.96]
numf = length(fi) - 1
for i = 1:numf
f = fi[i]
@test sa.amplification(f) ≈ Ai[i] rtol = 1e-2
end
sa = SiteAmpAlAtikAbrahamson2021_cy14_760()
fi = @SVector [0.001, 0.100000005278119, 0.102329305685959, 0.104712901088038, 0.10715191734136, 0.1096478161355, 0.112201844312325, 0.114815399493054, 0.117489811269133, 0.120226426884127, 0.123026912673429, 0.125892543180806, 0.128824943888933, 0.131825701931171, 0.134896292542321, 0.138038419685919, 0.141253726031804, 0.144543991682274, 0.147910841016824, 0.15135612531762, 0.154881699105396, 0.158489298275321, 0.162180994731809, 0.165958688177051, 0.169824406249264, 0.173780124732544, 0.177827987234069, 0.181970104503309, 0.18620874216892, 0.190546088276735, 0.194984413397179, 0.199526234462532, 0.204173818378493, 0.208929629962364, 0.213796203501538, 0.218776216272469, 0.223872092751581, 0.229086773295876, 0.234422913440041, 0.239883346374602, 0.245470959191782, 0.251188647299664, 0.257039583965111, 0.263026839625322, 0.269153386068061, 0.275422892536035, 0.281838357206786, 0.288403136014915, 0.29512088643951, 0.301995147118928, 0.309029636270837, 0.316227726764557, 0.323593743035287, 0.331131074274485, 0.338844138033324, 0.346736738117816, 0.354813374379999, 0.363078069427477, 0.371535318437207, 0.38018929961147, 0.389044995694541, 0.398107060813636, 0.407380379735427, 0.416869369537323, 0.426579727361764, 0.436515887692042, 0.446683606986212, 0.457088019319652, 0.46773532542682, 0.478629981874554, 0.489778948828998, 0.501187304961605, 0.512861186273828, 0.524807402402299, 0.537031596210482, 0.549541299892976, 0.562341327015613, 0.575439822942147, 0.588843516357273, 0.602559763585899, 0.61659488244124, 0.630957589108888, 0.645654602589703, 0.660693172670039, 0.676083352446191, 0.69183061540227, 0.707945609900711, 0.724435639005472, 0.741310319666438, 0.758577791401586, 0.776247032532349, 0.794327972885161, 0.812829888313304, 0.83176450189098, 0.85113745411528, 0.870963690655165, 0.891251760400126, 0.912010408577856, 0.933255245295474, 0.954991724274509, 0.977236931585538, 0.99999931915226, 1.0232926583713, 1.04712871370939, 1.07151972559382, 1.09647839861261, 1.12201798920987, 1.14815239015486, 1.17489619113164, 1.20226482282661, 1.230270509361, 1.25892568257472, 1.28825221490343, 1.31825970420816, 1.34896234511787, 1.38038569480746, 1.4125355875376, 1.44544035634817, 1.4791067005516, 1.51355991769356, 1.54881419338307, 1.58489135570109, 1.62180741098713, 1.65958724224312, 1.69824098493074, 1.73780538614063, 1.77828384029801, 1.81969768325487, 1.86209132642581, 1.90545951786295, 1.94984000723927, 1.99526323502638, 2.04173666608573, 2.08929373051144, 2.13795720949869, 2.18776679563686, 2.23871864940605, 2.29087274897834, 2.34422665758295, 2.398830455509, 2.45470143491059, 2.51187774934974, 2.57040187591233, 2.63027473614656, 2.69154228983537, 2.75423051595883, 2.81839385215467, 2.88403692114349, 2.95122086420034, 3.01995215562392, 3.09030065678915, 3.16227642295472, 3.23592346631478, 3.31132891490246, 3.3884299172534, 3.46735946910046, 3.54813821074709, 3.63078533725135, 3.71536846377799, 3.80191135853523, 3.89043708383884, 3.98108381905827, 4.07382969500055, 4.16870567544569, 4.26581070164795, 4.36518697265844, 4.46680411703705, 4.57085377834242, 4.67739610111622, 4.78632242414544, 4.89776678860413, 5.0118843229469, 5.12865332406043, 5.24803935339088, 5.37032511094351, 5.49537847413284, 5.62339713074269, 5.75435457691296, 5.88847905118778, 6.02561155450687, 6.16599641750948, 6.30960714497232, 6.45659960120723, 6.60689861529496, 6.76084973072587, 6.91824357308313, 7.07938541613807, 7.24442301919855, 7.41307142632331, 7.58568641738688, 7.76244066564601, 7.94326569146627, 8.12834448596361, 8.31759182767968, 8.51151566867657, 8.70973318814878, 8.91245786665494, 9.12030564789694, 9.33246351716575, 9.54996668260048, 9.77234156401459, 9.99990153906584, 10.2330151684908, 10.4711008559889, 10.7150364469821, 10.964750490257, 11.2201347329491, 11.4816670597186, 11.7492496241653, 12.022742813086, 12.3026981000034, 12.5889920759082, 12.8822769465087, 13.182459265256, 13.489400932834, 13.8038791736706, 14.1258004265005, 14.4539459356652, 14.7913578984967, 15.1357324856635, 15.4880193842308, 15.8493619845298, 16.2183086824161, 16.5960326767835, 16.9823769767776, 17.3787778053556, 17.7834601578259, 18.1979135417807, 18.6200418512582, 19.0554824815177, 19.49807748989, 19.9517012657342, 20.4186610376656, 20.8940733113534, 21.379997361205, 21.8789412825561, 22.387937087537, 22.9096392147486, 23.4439269263859, 23.9870856553391, 24.46058662679, 25.0340588613218, 25.6152039490899, 26.2158596298214, 26.8275446219964, 27.4542925051998, 28.0959151088508, 28.7521309339848, 29.4225501552548, 30.1066616578723, 30.8101318295223, 31.5331607803149, 32.2688473500071, 33.0235676906087, 33.7894041350745, 34.5814827413102, 35.3920282683592, 36.2114034095699, 37.0570384215831, 37.9296731960298, 38.808356830246, 39.7246511532133, 40.6446342457211, 41.5904771517877, 42.5624316552899, 43.5606664842275, 44.58525356566, 45.6203356517073, 46.679926731282, 47.7811828082431, 48.889095202211, 50.0392749799897, 51.1923784631563, 52.3876989427786, 53.6271327545174, 54.8639723203735, 56.1438945185322, 57.4685744162854, 58.8111011775592, 60.1686734628619, 61.6017896398734, 63.0158092367494, 64.5080917430415, 66.010239337733, 67.5570266517399, 69.1074610525002, 70.7437395379651, 72.3800126937281, 74.0584033514694, 75.8305646487854, 77.5949512656221, 79.4004309784528, 81.2461188644527, 83.1308139099541, 85.0529665055861, 87.0822300450569, 89.0763954752011, 91.1807407221922, 93.3202913166248, 95.4916631049442, 97.6908631563263, 100.012267904509, 1e3]
Ai = @SVector [1.0, 1.26474365754693, 1.27187168763244, 1.27901461204394, 1.2861668468288, 1.29332769860997, 1.30049545713136, 1.30766852765824, 1.3148448358383, 1.32202240367609, 1.32920111176275, 1.33638102751286, 1.34356422475535, 1.35075365610266, 1.35795288790118, 1.36516683588672, 1.37240078818257, 1.37965956984633, 1.38694651866824, 1.3942644665929, 1.40161534480099, 1.40900004959024, 1.41641948596057, 1.42387361692424, 1.43136209798135, 1.43888401061133, 1.44643774756037, 1.45402034276764, 1.46162798960857, 1.46925573360015, 1.47689789847254, 1.48454848588452, 1.49220043010574, 1.49984643882526, 1.50747891120157, 1.51509009761108, 1.52267156234887, 1.53021542332592, 1.53771329159611, 1.54515767577195, 1.5525423017734, 1.55986193063354, 1.56711260297083, 1.57429107685139, 1.58139470109949, 1.58842230933339, 1.59537254872675, 1.60224497526539, 1.6090399193016, 1.61575793863017, 1.62240013364471, 1.62896756722738, 1.63546241542315, 1.64188624895108, 1.64824169962538, 1.65453105215902, 1.660757253143, 1.66692298962119, 1.67303139815318, 1.67908545861599, 1.68508877287354, 1.69104474095905, 1.69695691445104, 1.70282847890391, 1.70866337029487, 1.71446466460501, 1.72023619436562, 1.72598137429174, 1.73170412937894, 1.73740741092509, 1.74309547823134, 1.74877153446106, 1.7544392973187, 1.76010278844154, 1.7657654338474, 1.77143153644529, 1.77710410272141, 1.7827876649385, 1.78848607318854, 1.79420347226643, 1.79994358407784, 1.80571108575488, 1.81150988535825, 1.81734412132426, 1.82321904347219, 1.82913817252675, 1.83510670026067, 1.84112756121076, 1.84720347424249, 1.85333562714735, 1.85952470296974, 1.8657708979849, 1.87207351949043, 1.87843213317722, 1.8848436987637, 1.89130781117208, 1.89782159094484, 1.90438189213204, 1.91098741512956, 1.91763345905683, 1.92431870117879, 1.93103904302077, 1.9377917893536, 1.94457361968632, 1.95138121657727, 1.95821137709387, 1.96506101732005, 1.97192719683423, 1.97880718423323, 1.98569844861012, 1.99259770558709, 1.99950182429154, 2.00641002878188, 2.01331868946611, 2.02022543975041, 2.02713050388327, 2.03402982723964, 2.04092437374658, 2.04781056500155, 2.05468885904031, 2.0615574700588, 2.06841626488153, 2.0752640907423, 2.08210150758018, 2.08892649642953, 2.09574183898203, 2.10254459906843, 2.10933506179724, 2.11611724811337, 2.12288728136106, 2.12964821625687, 2.13640189502178, 2.14314680483325, 2.14988534511825, 2.15661842855298, 2.16334930355606, 2.17007541648867, 2.17680275350116, 2.18352920748937, 2.19025940643645, 2.19699395722506, 2.2037360384332, 2.21048929651311, 2.21725267854449, 2.22403035334881, 2.23082429847101, 2.23763960582685, 2.24447608988636, 2.25133959947153, 2.25823040581599, 2.26515517696813, 2.27211465284156, 2.279113030692, 2.28615863788022, 2.29324589179053, 2.30038750095143, 2.30758593730311, 2.31484372550238, 2.32216775190769, 2.32956116012962, 2.33702714372695, 2.34457871599795, 2.35221548594714, 2.35994167884065, 2.36776709937289, 2.37569708603435, 2.38373136578869, 2.39188740715789, 2.4001723655651, 2.40858055742088, 2.41712532444938, 2.42582176653978, 2.43467176969305, 2.44367644631041, 2.45286124704223, 2.46222059889919, 2.47177408512471, 2.48152482557902, 2.49149534670758, 2.50167973724668, 2.5121025424396, 2.52276859362371, 2.53368621015369, 2.54471244064013, 2.55579887509383, 2.56691556730856, 2.57807828112741, 2.58929124755218, 2.60052938345122, 2.61181075197994, 2.6231406506567, 2.63450877844716, 2.64592079024619, 2.65736566297975, 2.66886801235028, 2.68039925680379, 2.6919660621504, 2.70359735310195, 2.71524178942724, 2.72695021810889, 2.73869095536778, 2.75047462230107, 2.76231402600025, 2.77417366427405, 2.78609125336844, 2.79805689620922, 2.81005922472766, 2.82211450958847, 2.83421194016232, 2.84633914825058, 2.85851444304052, 2.87072623771478, 2.88299593842877, 2.89531316315953, 2.90766594630464, 2.92007909343311, 2.93254220452969, 2.94500235859685, 2.95756836203094, 2.97014763145451, 2.98276880579325, 2.99546605253435, 3.00818177435952, 3.02095009321979, 3.03375911466721, 3.04664949155654, 3.05955682058631, 3.07252220143771, 3.08547407825541, 3.09857806889149, 3.11164189991262, 3.1247740454825, 3.13803326445637, 3.15127392356254, 3.16454764394741, 3.17791564782097, 3.19129151012199, 3.20473834661461, 3.21824566667958, 3.23171364822652, 3.24322176393691, 3.25693690766748, 3.27057303493195, 3.28439587776679, 3.2982023981508, 3.3120769920673, 3.32600819520374, 3.33998266349085, 3.35398523152793, 3.36799876948903, 3.38213175244099, 3.39637913151413, 3.41059795760726, 3.42490457070842, 3.43914277447917, 3.45358581167583, 3.46808249458969, 3.4824554766011, 3.49700354471659, 3.51172864029507, 3.52627127838015, 3.54114568729358, 3.55579375948015, 3.57056350893963, 3.58544956703106, 3.60044533617299, 3.61554285093282, 3.63050282206819, 3.64552230305604, 3.66083358332543, 3.67594250063318, 3.69132730927766, 3.70645512356833, 3.72183502705042, 3.73747813266146, 3.75278864636778, 3.76832751756716, 3.78410258957844, 3.79978518957619, 3.81533904720756, 3.83144482482593, 3.84703224899097, 3.86316870335808, 3.87910227339303, 3.89519546271496, 3.91101665356257, 3.92739373576442, 3.94345781904698, 3.95961844868298, 3.97635732852111, 3.99270630339808, 4.00911573850308, 4.02556924273202, 4.04204836767728, 4.05853233081845, 4.07560361892911, 4.09205960420983, 4.10909253284836, 4.12608173443567, 4.14299493817811, 4.15979664012907, 4.17719144318364, 4.17719144318364]
numf = length(fi) - 1
for i = 1:numf
f = fi[i]
@test sa.amplification(f) ≈ Ai[i] rtol = 1e-2
end
f_hi = 500.0
f_max = 999.99
mms = [SiteAmpUnit(),
SiteAmpBoore2016_760(),
SiteAmpAlAtikAbrahamson2021_ask14_620(),
SiteAmpAlAtikAbrahamson2021_ask14_760(),
SiteAmpAlAtikAbrahamson2021_ask14_1100(),
SiteAmpAlAtikAbrahamson2021_bssa14_620(),
SiteAmpAlAtikAbrahamson2021_bssa14_760(),
SiteAmpAlAtikAbrahamson2021_bssa14_1100(),
SiteAmpAlAtikAbrahamson2021_cb14_620(),
SiteAmpAlAtikAbrahamson2021_cb14_760(),
SiteAmpAlAtikAbrahamson2021_cb14_1100(),
SiteAmpAlAtikAbrahamson2021_cy14_620(),
SiteAmpAlAtikAbrahamson2021_cy14_760(),
SiteAmpAlAtikAbrahamson2021_cy14_1100()]
for mm in mms
@test site_amplification(f_hi, mm) ≈ site_amplification(f_max, mm)
end
# @code_warntype site_amplification(f_hi, mms[3])
end
@testset "Kappa Filter" begin
f = 10.0
# @code_warntype kappa_filter(f, siteAf)
# @code_warntype kappa_filter(f, siteAd)
Kff = kappa_filter(f, siteAf)
Kfd = kappa_filter(f, siteAd)
@test Kff == Kfd.value
nf = 100
fi = exp.(range(log(1e-2), stop=log(1e2), length=nf))
Kf0fi = kappa_filter(fi, siteAf)
Kf0di = kappa_filter(fi, siteAd)
for i in 1:nf
@test Kf0fi[i] == Kf0di[i].value
end
Affi = ones(eltype(Kf0fi), nf)
Afdi = ones(eltype(Kf0di), nf)
StochasticGroundMotionSimulation.apply_kappa_filter!(Affi, fi, siteAf)
StochasticGroundMotionSimulation.apply_kappa_filter!(Afdi, fi, siteAd)
for i in 1:nf
@test Affi[i] == Afdi[i].value
end
end
@testset "Zeta Filter" begin
f = 10.0
# @code_warntype kappa_filter(f, siteAf)
# @code_warntype kappa_filter(f, siteAd)
siteAzf = SiteParameters(ζ0f, ηf)
siteAzd = SiteParameters(ζ0d, ηd)
Kff = kappa_filter(f, siteAzf)
Kfd = kappa_filter(f, siteAzd)
@test Kff == Kfd.value
nf = 100
fi = exp.(range(log(1e-2), stop=log(1e2), length=nf))
Kf0fi = kappa_filter(fi, siteAzf)
Kf0di = kappa_filter(fi, siteAzd)
for i in 1:nf
@test Kf0fi[i] == Kf0di[i].value
end
Affi = ones(eltype(Kf0fi), nf)
Afdi = ones(eltype(Kf0di), nf)
StochasticGroundMotionSimulation.apply_kappa_filter!(Affi, fi, siteAzf)
StochasticGroundMotionSimulation.apply_kappa_filter!(Afdi, fi, siteAzd)
for i in 1:nf
@test Affi[i] == Afdi[i].value
end
end
end
@testset "Oscillator" begin
ζ = 0.05
f_n = 1.0
sdof = Oscillator(f_n, ζ)
@test f_n ≈ 1.0 / period(sdof)
@test transfer(0.5, sdof)^2 ≈ StochasticGroundMotionSimulation.squared_transfer(0.5, sdof)
fi = [0.5, 1.0, 2.0]
# @code_warntype transfer(fi, sdof)
Hfi = transfer(fi, sdof)
tfi = 2 * fi
transfer!(Hfi, tfi, sdof)
@test Hfi ≈ transfer(tfi, sdof)
StochasticGroundMotionSimulation.squared_transfer!(Hfi, fi, sdof)
@test Hfi ≈ transfer(fi, sdof) .^ 2
end
@testset "Duration" begin
src = SourceParameters(100.0)
geo = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.5])
ane = AnelasticAttenuationParameters(200.0, 0.4)
sat = NearSourceSaturationParameters(:BT15)
path = PathParameters(geo, sat, ane)
site = SiteParameters(0.039)
fas = FourierParameters(src, path, site)
# Boore & Thompson 2014
m = 6.0
fa, fb, ε = corner_frequency(m, src)
Ds = 1.0 / fa
Δσf = 100.0
Δσd = Dual{Float64}(Δσf)
srcf = SourceParameters(Δσf)
srcd = SourceParameters(Δσd)
fasf = FourierParameters(srcf, path, site)
fasd = FourierParameters(srcd, path, site)
faf, fbf, εf = corner_frequency(m, srcf)
# @code_warntype StochasticGroundMotionSimulation.boore_thompson_2014(m, 0.0, srcf)
Dsf = StochasticGroundMotionSimulation.boore_thompson_2014(m, 0.0, srcf)
@test Dsf ≈ 1.0 / faf
@test isnan(fbf)
@test isnan(εf)
fad, fbd, εd = corner_frequency(m, srcd)
# @code_warntype StochasticGroundMotionSimulation.boore_thompson_2014(m, 0.0, srcd)
Dsd = StochasticGroundMotionSimulation.boore_thompson_2014(m, 0.0, srcd)
@test Dsd ≈ 1.0 / fad
@test isnan(fbd)
@test isnan(εd)
# @code_warntype StochasticGroundMotionSimulation.boore_thompson_2014(m, 0.0, fasf)
@test StochasticGroundMotionSimulation.boore_thompson_2014(m, 0.0, fasf) ≈ Ds
@test StochasticGroundMotionSimulation.boore_thompson_2014(m, 0.0, fasd) ≈ Ds
@test StochasticGroundMotionSimulation.boore_thompson_2015(m, 0.0, fasf, :ACR) ≈ Ds
@test StochasticGroundMotionSimulation.boore_thompson_2015(m, 0.0, fasd, :ACR) ≈ Ds
rti = range(0.1, stop=700.0, step=1.0)
m = -8.0
rvt_acr = RandomVibrationParameters(:DK80, :BT14, :BT15, :ACR)
rvt_scr = RandomVibrationParameters(:DK80, :BT15, :BT15, :SCR)
for i in 1:lastindex(rti)
if (rti[i] < 17.0) | (rti[i] > 281.0)
@test excitation_duration(m, rti[i], src, rvt_scr) .<= excitation_duration(m, rti[i], src, rvt_acr)
else
@test excitation_duration(m, rti[i], src, rvt_scr) .> excitation_duration(m, rti[i], src, rvt_acr)
end
end
@test excitation_duration(m, 10.0, src, rvt_acr) == excitation_duration(m, 10.0, fas, rvt_acr)
m = 6.0
r = 7.0
fa, fb, ε = corner_frequency(m, fasf)
Dur = 1.0 / fa + 2.4
@test StochasticGroundMotionSimulation.boore_thompson_2014(m, r, fasf) ≈ Dur
fa, fb, ε = corner_frequency(m, fasd)
Dur = 1.0 / fa + 2.4
@test StochasticGroundMotionSimulation.boore_thompson_2014(m, r, fasd) ≈ Dur
srcAS = SourceParameters(Δσf, :Atkinson_Silva_2000)
fa, fb, ε = corner_frequency(m, srcAS)
Ds = 0.5 * (1.0 / fa + 1.0 / fb)
@test StochasticGroundMotionSimulation.boore_thompson_2014(m, 0.0, srcAS) ≈ Ds
@test isnan(fb) == false
@test isnan(ε) == false
@test fa < fb
# test gradient of BT14 duration model w.r.t. magnitude
h = 0.05
m1 = 8.0
m2 = m1 + h
r_ps1 = 1.0 + near_source_saturation(m1, fasf)
r_ps2 = 1.0 + near_source_saturation(m2, fasf)
Dex1 = StochasticGroundMotionSimulation.boore_thompson_2014(m1, r_ps1, fasf)
Dex2 = StochasticGroundMotionSimulation.boore_thompson_2014(m2, r_ps2, fasf)
fdg = log(Dex2 / Dex1) / h
d(x) = log(StochasticGroundMotionSimulation.boore_thompson_2014(x[1], 1.0 + near_source_saturation(x[1], fasf), fasf))
gd(x) = ForwardDiff.gradient(d, x)
adg = gd([8.0])[1]
@test fdg ≈ adg atol = 1e-2
rvt = RandomVibrationParameters()
# @code_warntype excitation_duration(m, r, fasf, rvt)
# @code_warntype excitation_duration(m, r, fasd, rvt)
Dexf = excitation_duration(m, r, fasf, rvt)
Dexd = excitation_duration(m, r, fasd, rvt)
@test Dexf == Dexd.value
rvt = RandomVibrationParameters(:DK80, :BT15, :BT15, :SCR)
Dexf = excitation_duration(m, r, fasf, rvt)
Dexd = excitation_duration(m, r, fasd, rvt)
@test Dexf == Dexd.value
c11 = [8.4312e-01, -2.8671e-02, 2.0, 1.7316e+00, 1.1695e+00, 2.1671e+00, 9.6224e-01]
c11f = StochasticGroundMotionSimulation.StochasticGroundMotionSimulation.boore_thompson_2012_coefs(1, 1)
@test c11f[1] == c11[1]
@test all(isapprox.(c11, c11f))
# @code_warntype StochasticGroundMotionSimulation.StochasticGroundMotionSimulation.boore_thompson_2012_coefs(1, 1)
m = 8.0
r = 1.0
Dex = StochasticGroundMotionSimulation.boore_thompson_2014(m, r, srcf)
# get the oscillator period
sdof = Oscillator(100.0)
T_n = period(sdof)
ζ = sdof.ζ_n
# define the η parameter as T_n/Dex
η = T_n / Dex
# @time c = StochasticGroundMotionSimulation.StochasticGroundMotionSimulation.boore_thompson_2012_coefs(1, 1)
# @time StochasticGroundMotionSimulation.boore_thompson_2012_base(η, c, ζ)
#
# @time StochasticGroundMotionSimulation.boore_thompson_2012(m, r, srcf, sdof, rvt)
# @code_warntype StochasticGroundMotionSimulation.boore_thompson_2012(m, r, srcf, sdof, rvt)
#
# @time StochasticGroundMotionSimulation.boore_thompson_2012(m, r, srcd, sdof, rvt)
# @code_warntype StochasticGroundMotionSimulation.boore_thompson_2012(m, r, srcd, sdof, rvt)
sdof = Oscillator(1.0)
Drms, Dex, Dratio = StochasticGroundMotionSimulation.boore_thompson_2012(m, r, fas, sdof, rvt)
Dex0 = StochasticGroundMotionSimulation.boore_thompson_2014(m, r, fas)
@test Dex != Dex0
# test combinations of :pf_method and :dur_rms methods
rvt0 = RandomVibrationParameters()
rvt1 = RandomVibrationParameters(:DK80)
rvt2 = RandomVibrationParameters(:DK80, :SCR)
rvt3 = RandomVibrationParameters(:CL56)
rvt4 = RandomVibrationParameters(:CL56, :SCR)
@test rvt0 == rvt1
@test rvt0 != rvt2
@test rvt0.pf_method == rvt2.pf_method
@test rvt0.dur_ex == :BT15
@test rvt0.dur_rms == :BT15
@test rvt3 != rvt4
@test rvt3.pf_method != rvt0.pf_method
@test rvt3.dur_region == :ACR
@test rvt3.pf_method == rvt4.pf_method
@test rvt3.dur_rms == :BT12
# check that the excitation durations are matching
rvt = RandomVibrationParameters(:CL56, :BT14, :BT12, :ACR)
Drms, Dex, Dratio = StochasticGroundMotionSimulation.boore_thompson_2012(m, r, fas, sdof, rvt)
Dex0 = StochasticGroundMotionSimulation.boore_thompson_2014(m, r, fas)
@test Dex == Dex0
# confirm that incorrect combinations of peak factor and rms duration gives NaN result
rvt = RandomVibrationParameters(:DK80, :BT14, :BT12, :ACR)
Drms, Dex, Dratio = rms_duration(m, r, fas, sdof, rvt)
@test isnan(Dex)
# check that rms and excitation duration wrapper functions work as intended
Dex0 = excitation_duration(m, r, fas, rvt0)
Drms, Dex1, Dratio = rms_duration(m, r, fas, sdof, rvt0)
@test Dex0 == Dex1
Dex0 = excitation_duration(m, r, fas, rvt2)
Drms, Dex1, Dratio = rms_duration(m, r, fas, sdof, rvt0)
@test Dex0 != Dex1
# @code_warntype rms_duration(m, r, srcf, path, sdof, rvt)
# @code_warntype rms_duration(m, r, srcd, path, sdof, rvt)
# @code_warntype rms_duration(m, r, fasf, sdof, rvt)
# @code_warntype rms_duration(m, r, fasd, sdof, rvt)
# @time Drmsf, Dexf, Dratiof = rms_duration(m, r, fasf, sdof, rvt)
# @time Drmsd, Dexd, Dratiod = rms_duration(m, r, fasd, sdof, rvt)
rvt = RandomVibrationParameters()
Drmsf, Dexf, Dratiof = rms_duration(m, r, fasf, sdof, rvt)
Drmsd, Dexd, Dratiod = rms_duration(m, r, fasd, sdof, rvt)
@test Drmsf == Drmsd.value
@test Dexf == Dexd.value
@test Dratiof == Dratiod.value
rvt = RandomVibrationParameters(:CL56, :BT14, :BT12, :ACR)
Drmsf, Dexf, Dratiof = rms_duration(m, r, fasf, sdof, rvt)
Drmsf1, Dexf1, Dratiof1 = StochasticGroundMotionSimulation.boore_thompson_2012(m, r, fasf, sdof, rvt)
@test Drmsf == Drmsf1
@test Dexf == Dexf1
@test Dratiof == Dratiof1
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, srcf, :ACR))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, srcd, :ACR))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, SourceParameters(1), :ACR))
# Boore & Thompson 2014
m = 6.0
fa, fb, ε = corner_frequency(m, src)
Ds = 1.0 / fa
Dex270 = Ds + 34.2
Dex300 = Dex270 + 0.156 * 30.0
@test Dex270 ≈ StochasticGroundMotionSimulation.boore_thompson_2014(m, 270.0, src)
@test Dex300 ≈ StochasticGroundMotionSimulation.boore_thompson_2014(m, 300.0, src)
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2014(m, -1.0, src))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2014(m, -1.0, srcd))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2014(m, Dual(-1.0), src))
@test isnan(excitation_duration(m, -1.0, src, rvt))
@test isnan(excitation_duration(m, -1.0, srcd, rvt))
@test isnan(excitation_duration(m, Dual(-1.0), src, rvt))
c = StochasticGroundMotionSimulation.StochasticGroundMotionSimulation.boore_thompson_2012_coefs(1, 1, region=:SCR)
idx = 1
@test all(isapprox(c, StochasticGroundMotionSimulation.coefs_ena_bt12[idx, 3:9]))
d1a, d2a, d3a = StochasticGroundMotionSimulation.boore_thompson_2012(6.1234, 2.0, src, sdof, rvt)
d1b, d2b, d3b = StochasticGroundMotionSimulation.boore_thompson_2012(6.1234, 2.1234, src, sdof, rvt)
d1c, d2c, d3c = StochasticGroundMotionSimulation.boore_thompson_2012(6.0, 2.1234, src, sdof, rvt)
d1d, d2d, d3d = StochasticGroundMotionSimulation.boore_thompson_2012(6.0, 2.0, src, sdof, rvt)
@test d1a < d1b
@test d2a < d2b
@test d3a > d3b
@test d1a > d1c
@test d1d < d1a
c = StochasticGroundMotionSimulation.boore_thompson_2015_coefs(1, 1, region=:SCR)
idx = 1
@test all(isapprox(c, StochasticGroundMotionSimulation.coefs_ena_bt15[idx, 3:9]))
d1a, d2a, d3a = StochasticGroundMotionSimulation.boore_thompson_2015(6.1234, 2.0, src, sdof, rvt)
d1b, d2b, d3b = StochasticGroundMotionSimulation.boore_thompson_2015(6.1234, 2.1234, src, sdof, rvt)
d1c, d2c, d3c = StochasticGroundMotionSimulation.boore_thompson_2015(6.0, 2.1234, src, sdof, rvt)
d1d, d2d, d3d = StochasticGroundMotionSimulation.boore_thompson_2015(6.0, 2.0, src, sdof, rvt)
@test d1a < d1b
@test d2a < d2b
@test d3a > d3b
@test d1a > d1c
@test d1d < d1a
d1as, d2as, d3as = StochasticGroundMotionSimulation.boore_thompson_2015(6.1234, 2.0, src, sdof, rvt)
d1af, d2af, d3af = StochasticGroundMotionSimulation.boore_thompson_2015(6.1234, 2.0, fas, sdof, rvt)
@test d1as == d1af
@test d2as == d2af
@test d3as == d3af
rvt = RandomVibrationParameters(:PS, :PS, :PS, :PS)
d1, d2, d3 = rms_duration(6.0, 1.0, fas, sdof, rvt)
@test isnan(d1)
@test isnan(d2)
@test isnan(d3)
srcf = SourceParameters(100.0)
srcd = SourceParameters(Dual(100.0))
rvt = RandomVibrationParameters(:PS, :PS, :PS, :PS)
@test isnan(excitation_duration(6.0, 10.0, srcf, rvt))
@test isnan(excitation_duration(6.0, 10.0, srcd, rvt))
@test isnan(excitation_duration(6.0, Dual(10.0), srcf, rvt))
D50 = excitation_duration(6.0, 50.0, srcf, RandomVibrationParameters())
D150 = excitation_duration(6.0, 150.0, srcf, RandomVibrationParameters())
@test D150 > D50
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2014_path_duration(-1.0))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015_path_duration_acr(-1.0))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015_path_duration_scr(-1.0))
rpi = range(0.0, stop=1000.0, step=1.0)
DexAi = zeros(length(rpi))
DexSi = zeros(length(rpi))
DpAi = zeros(length(rpi))
DpSi = zeros(length(rpi))
rvtA = RandomVibrationParameters(:DK80, :ACR)
rvtS = RandomVibrationParameters(:DK80, :SCR)
src = SourceParameters(100.0)
m = 2.0
fc, d1, d2 = corner_frequency(m, src)
Ds = 1.0 / fc
for (i, r) in enumerate(rpi)
DexAi[i] = excitation_duration(m, r, src, rvtA)
DexSi[i] = excitation_duration(m, r, src, rvtS)
DpAi[i] = StochasticGroundMotionSimulation.boore_thompson_2015_path_duration_acr(r)
DpSi[i] = StochasticGroundMotionSimulation.boore_thompson_2015_path_duration_scr(r)
end
@test all(isapprox.(DexAi .- Ds, DpAi))
@test all(isapprox.(DexSi .- Ds, DpSi))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, src, rvtA))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, src, rvtS))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, src, :PJS))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, src, :PJS))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, fas, rvtA))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, fas, rvtS))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, fas, :PJS))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, fas, :PJS))
src = SourceParameters(100.0, :Atkinson_Silva_2000)
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, src, rvtA))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, src, rvtS))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, src, :PJS))
@test isnan(StochasticGroundMotionSimulation.boore_thompson_2015(m, -1.0, src, :PJS))
@testset "Edwards (2023) duration" begin
src = SourceParameters(50.0)
geo = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.7], :Piecewise)
sat = NearSourceSaturationParameters(:BT15)
ane = AnelasticAttenuationParameters(3000.0, 0.0)
path = PathParameters(geo, sat, ane)
site = SiteParameters(0.03, SiteAmpUnit())
fas = FourierParameters(src, path, site)
rvt = RandomVibrationParameters(:CL56, :BE23, :LP99, :ACR)
sdof = Oscillator(1.0)
m = 6.0
r_rup = 10.0
r_ps = equivalent_point_source_distance(r_rup, m, fas)
Dex = excitation_duration(m, r_ps, fas, rvt)
(Drms, Dex0, Drat) = rms_duration(m, r_ps, fas, sdof, rvt)
@test Dex == Dex0
# @code_warntype rms_duration(m, r_ps, fas, sdof, rvt)
src = SourceParameters(50.0, :AtkinsonSilva2000)
fas = FourierParameters(src, path, site)
m = 1.0
r_rup = 40.0
r_ps = equivalent_point_source_distance(r_rup, m, fas)
Dex = excitation_duration(m, r_ps, fas, rvt)
(Drms, Dex0, Drat) = rms_duration(m, r_ps, fas, sdof, rvt)
@test Dex == Dex0
@test StochasticGroundMotionSimulation.edwards_2023_path_duration(-1.0) == 0.0
end
@testset "UK duration models" begin
src = SourceParameters(50.0)
geo = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.7], :Piecewise)
sat = NearSourceSaturationParameters(:BT15)
ane = AnelasticAttenuationParameters(3000.0, 0.0)
path = PathParameters(geo, sat, ane)
site = SiteParameters(0.03, SiteAmpUnit())
fas = FourierParameters(src, path, site)
rvt_free = RandomVibrationParameters(:DK80, :UKfree, :BT15, :ACR)
rvt_fixed = RandomVibrationParameters(:DK80, :UKfixed, :BT15, :ACR)
sdof = Oscillator(1.0)
m = 1.0
r_rup = 40.0
r_ps = equivalent_point_source_distance(r_rup, m, fas)
Dex_free = excitation_duration(m, r_ps, fas, rvt_free)
(Drms_free, Dex0_free, Drat_free) = rms_duration(m, r_ps, fas, sdof, rvt_free)
@test Dex_free == Dex0_free
Dex_fixed = excitation_duration(m, r_ps, fas, rvt_fixed)
(Drms_fixed, Dex0_fixed, Drat_fixed) = rms_duration(m, r_ps, fas, sdof, rvt_fixed)
@test Dex_fixed == Dex0_fixed
# @code_warntype StochasticGroundMotionSimulation.uk_path_duration_free(r_ps)
@test StochasticGroundMotionSimulation.uk_path_duration_free(-1.0) == 0.0
@test StochasticGroundMotionSimulation.uk_path_duration_fixed(-1.0) == 0.0
m = 0.0
for r_rup in range(-4.0, stop=600.0, step=5.0)
r_ps = equivalent_point_source_distance(r_rup, m, fas)
# StochasticGroundMotionSimulation.uk_path_duration_free(r_ps)
# StochasticGroundMotionSimulation.uk_duration_free(m, r_ps, src)
Dex_free = excitation_duration(m, r_ps, fas, rvt_free)
(Drms_free, Dex0_free, Drat_free) = rms_duration(m, r_ps, fas, sdof, rvt_free)
@test Dex_free == Dex0_free
Dex_fixed = excitation_duration(m, r_ps, fas, rvt_fixed)
(Drms_fixed, Dex0_fixed, Drat_fixed) = rms_duration(m, r_ps, fas, sdof, rvt_fixed)
@test Dex_fixed == Dex0_fixed
end
src = SourceParameters(50.0, :AtkinsonSilva2000)
fas = FourierParameters(src, path, site)
m = 1.0
r_rup = 40.0
r_ps = equivalent_point_source_distance(r_rup, m, fas)
Dex_free = excitation_duration(m, r_ps, fas, rvt_free)
(Drms_free, Dex0_free, Drat_free) = rms_duration(m, r_ps, fas, sdof, rvt_free)
@test Dex_free == Dex0_free
Dex_fixed = excitation_duration(m, r_ps, fas, rvt_fixed)
(Drms_fixed, Dex0_fixed, Drat_fixed) = rms_duration(m, r_ps, fas, sdof, rvt_fixed)
@test Dex_fixed == Dex0_fixed
end
end
@testset "Fourier" begin
Δσf = 100.0
γ1f = 1.0
γ2f = 0.5
Q0f = 200.0
ηf = 0.4
κ0f = 0.039
Δσd = Dual{Float64}(Δσf)
γ1d = Dual{Float64}(γ1f)
γ2d = Dual{Float64}(γ2f)
Q0d = Dual{Float64}(Q0f)
ηd = Dual{Float64}(ηf)
κ0d = Dual{Float64}(κ0f)
srcf = SourceParameters(Δσf)
srcd = SourceParameters(Δσd)
Rrefi = [1.0, 50.0, Inf]
geof = GeometricSpreadingParameters(Rrefi, [γ1f, γ2f])
geod = GeometricSpreadingParameters(Rrefi, [γ1d, γ2d])
geom = GeometricSpreadingParameters(Rrefi, [γ1f], [γ2d], BitVector([0, 1]), :Piecewise)
anef = AnelasticAttenuationParameters(Q0f, ηf)
aned = AnelasticAttenuationParameters(Q0d, ηd)
anem = AnelasticAttenuationParameters(Q0f, ηd)
sat = NearSourceSaturationParameters(:BT15)
pathf = PathParameters(geof, sat, anef)
pathd = PathParameters(geod, sat, aned)
pathm = PathParameters(geom, sat, anem)
sitef = SiteParameters(κ0f)
sited = SiteParameters(κ0d)
fasf = FourierParameters(srcf, pathf, sitef)
fasd = FourierParameters(srcd, pathd, sited)
fasm = FourierParameters(srcf, pathm, sited)
Tf = StochasticGroundMotionSimulation.get_parametric_type(fasf)
Td = StochasticGroundMotionSimulation.get_parametric_type(fasd)
Tm = StochasticGroundMotionSimulation.get_parametric_type(fasm)
@test Tf == Float64
@test Td <: Dual
@test Tm <: Dual
@test Td == Tm
# @code_warntype fourier_constant(srcf)
Cfs = fourier_constant(srcf)
Cff = fourier_constant(fasf)
@test Cfs == Cff
# @code_warntype fourier_constant(srcd)
Cfsd = fourier_constant(srcd)
Cffd = fourier_constant(fasd)
@test Cfsd == Cffd
@testset "Fourier Source Shape" begin
f = 0.001
m = 6.0
# @code_warntype fourier_source_shape(f, m, srcf)
# @code_warntype fourier_source_shape(f, m, srcd)
Affs = fourier_source_shape(f, m, srcf)
Afff = fourier_source_shape(f, m, fasf)
Afds = fourier_source_shape(f, m, srcd)
Afdf = fourier_source_shape(f, m, fasd)
@test Affs == Afds.value
@test Afff == Afdf.value
@test Affs == Afff
@test Afds == Afdf
@test Afff ≈ 1.0 atol = 1e-3
fa, fb, ε = corner_frequency(m, srcf)
# @code_warntype fourier_source_shape(f, fa, fb, ε, srcf.model)
Afc = fourier_source_shape(f, fa, fb, ε, srcf)
@test Afc ≈ 1.0 atol = 1e-3
fa, fb, ε = corner_frequency(m, srcd)
# @code_warntype fourier_source_shape(f, fa, fb, ε, srcd.model)
Afcd = fourier_source_shape(f, fa, fb, ε, srcd)
@test Afcd ≈ 1.0 atol = 1e-3
src_a = SourceParameters(100.0, :Atkinson_Silva_2000)
Af_a = fourier_source_shape(f, m, src_a)
@test Af_a ≈ 1.0 atol = 1e-3
src_n = SourceParameters(100.0, :Null)
Af_n = fourier_source_shape(f, m, src_n)
src_b = SourceParameters(100.0)
Af_b = fourier_source_shape(f, m, src_b)
@test Af_n == Af_b
fa, fb, ε = corner_frequency(m, src_a)
Af_a = fourier_source_shape(f, fa, fb, ε, src_a)
@test Af_a ≈ 1.0 atol = 1e-3
fa, fb, ε = corner_frequency(m, src_b)
Af_n = fourier_source_shape(f, fa, fb, ε, src_n)
@test Af_n ≈ Af_b
f = [0.001, 0.01, 0.1, 1.0, 10.0, 100.0]
nf = length(f)
# @code_warntype fourier_source_shape(f, m, srcf)
# @code_warntype fourier_source_shape(f, m, srcd)
Affs = fourier_source_shape(f, m, srcf)
Afff = fourier_source_shape(f, m, fasf)
Afds = fourier_source_shape(f, m, srcd)
Afdf = fourier_source_shape(f, m, fasd)
for i in 1:nf
@test Affs[i] == Afds[i].value
@test Afff[i] == Afdf[i].value
@test Affs[i] == Afff[i]
@test Afds[i] == Afdf[i]
end
fa, fb, ε = corner_frequency(m, srcf)
# @code_warntype fourier_source_shape(f, fa, fb, ε, srcf.model)
Afc = fourier_source_shape(f, fa, fb, ε, srcf)
@test Afc[1] ≈ 1.0 atol = 1e-3
fa, fb, ε = corner_frequency(m, srcd)
# @code_warntype fourier_source_shape(f, fa, fb, ε, srcd.model)
Afcd = fourier_source_shape(f, fa, fb, ε, srcd)
@test Afcd[1] ≈ 1.0 atol = 1e-3
src_a = SourceParameters(100.0, :Atkinson_Silva_2000)
Af_a = fourier_source_shape(f, m, src_a)
@test Af_a[1] ≈ 1.0 atol = 1e-3
src_n = SourceParameters(100.0, :Null)
Af_n = fourier_source_shape(f, m, src_n)
src_b = SourceParameters(100.0)
Af_b = fourier_source_shape(f, m, src_b)
@test Af_n == Af_b
fa, fb, ε = corner_frequency(m, src_a)
Af_a = fourier_source_shape(f, fa, fb, ε, src_a)
@test Af_a[1] ≈ 1.0 atol = 1e-3
fa, fb, ε = corner_frequency(m, src_b)
Af_n = fourier_source_shape(f, fa, fb, ε, src_n)
@test Af_n ≈ Af_b
src = SourceParameters(100.0, :Beresnev_2019)
fa, fb, ε = corner_frequency(m, src)
Af = fourier_source_shape(f, fa, fb, ε, src)
@test Af[1] ≈ 1.0 atol = 1e-3
fasbf = FourierParameters(src, pathf, sitef)
fa, fb, ε = corner_frequency(m, fasbf)
Af = fourier_source_shape(f, fa, fb, ε, fasbf)
@test Af[1] ≈ 1.0 atol = 1e-3
end
@testset "Fourier Source" begin
f = 0.001
m = 6.0
# @code_warntype fourier_source(f, m, srcf)
# @code_warntype fourier_source(f, m, srcd)
Afs = fourier_source(f, m, srcf)
Aff = fourier_source(f, m, fasf)
@test Afs == Aff
# @time fourier_source(f, m, srcd)
# @time fourier_source(f, m, fasd)
end
@testset "Fourier Path" begin
f = 10.0
r = 100.0
m = 6.0
ane = AnelasticAttenuationParameters(200.0, 0.5, :Rrup)
Pfr = fourier_path(f, r, m, geof, sat, ane)
path = PathParameters(geof, sat, ane)
Pfp = fourier_path(f, r, m, path)
fas = FourierParameters(SourceParameters(100.0), path)
Pff = fourier_path(f, r, m, fas)
@test Pfr == Pfp
@test Pfr == Pff
# @code_warntype fourier_path(f, r, geof, anef)
# @code_warntype fourier_path(f, r, geod, aned)
# @code_warntype fourier_path(f, r, geom, anef)
# @code_warntype fourier_path(f, r, pathf)
# @code_warntype fourier_path(f, r, pathd)
# @code_warntype fourier_path(f, r, pathm)
# @code_warntype fourier_path(f, r, fasf)
# @code_warntype fourier_path(f, r, fasd)
# @code_warntype fourier_path(f, r, fasm)
Pf = fourier_path(f, r, fasf)
Pd = fourier_path(f, r, fasd)
Pm = fourier_path(f, r, fasm)
@test Pf == Pd.value
@test Pd == Pm
end
@testset "Fourier attenuation" begin
f = 10.0
r = 200.0
# @code_warntype fourier_attenuation(f, r, anef, sitef)
# @code_warntype fourier_attenuation(f, r, aned, sited)
# @code_warntype fourier_attenuation(f, r, anef, sited)
# @code_warntype fourier_attenuation(f, r, pathf, sitef)
# @code_warntype fourier_attenuation(f, r, pathd, sited)
# @code_warntype fourier_attenuation(f, r, pathm, sited)
# @code_warntype fourier_attenuation(f, r, fasf)
# @code_warntype fourier_attenuation(f, r, fasd)
# @code_warntype fourier_attenuation(f, r, fasm)
Qf = fourier_attenuation(f, r, fasf)
Qd = fourier_attenuation(f, r, fasd)
Qm = fourier_attenuation(f, r, fasm)
@test Qf == Qd.value
@test Qd == Qm
@test fourier_attenuation(-1.0, r, fasf) == 1.0
f = [0.01, 0.1, 1.0, 10.0, 100.0]
nf = length(f)
Qf = fourier_attenuation(f, r, fasf)
Qd = fourier_attenuation(f, r, fasd)
Qm = fourier_attenuation(f, r, fasm)
@test Qf == map(q -> q.value, Qd)
@test Qd == Qm
Aff = ones(eltype(Qf), nf)
Afd = ones(eltype(Qd), nf)
Afm = ones(eltype(Qm), nf)
StochasticGroundMotionSimulation.apply_fourier_attenuation!(Aff, f, r, fasf)
StochasticGroundMotionSimulation.apply_fourier_attenuation!(Afd, f, r, fasd)
StochasticGroundMotionSimulation.apply_fourier_attenuation!(Afm, f, r, fasm)
@test Aff == map(a -> a.value, Afd)
@test Aff == map(a -> a.value, Afm)
end
@testset "Fourier site" begin
# @code_warntype fourier_site(f, sitef)
# @code_warntype fourier_site(f, sited)
# @time fourier_site(f, sitef)
# @time fourier_site(f, sited)
f = 0.5
Sf = fourier_site(f, fasf)
Sd = fourier_site(f, fasd)
Sm = fourier_site(f, fasm)
@test Sf == Sd.value
@test Sd == Sm
end
@testset "Point source distance" begin
f = 1.0
m = 6.0
r = 10.0
r_psf = equivalent_point_source_distance(r, m, fasf)
r_psd = equivalent_point_source_distance(r, m, fasd)
r_psm = equivalent_point_source_distance(r, m, fasm)
@test r_psf ≈ r_psd
@test r_psf ≈ r_psm
end
# @code_warntype fourier_spectral_ordinate(f, m, r_psf, fasf)
# @code_warntype fourier_spectral_ordinate(f, m, r_psd, fasd)
# @code_warntype fourier_spectral_ordinate(f, m, r_psm, fasm)
f = 1.0
m = 6.0
r = 10.0
r_psf = equivalent_point_source_distance(r, m, fasf)
r_psd = equivalent_point_source_distance(r, m, fasd)
r_psm = equivalent_point_source_distance(r, m, fasm)
Af = fourier_spectral_ordinate(f, m, r_psf, fasf)
Ad = fourier_spectral_ordinate(f, m, r_psd, fasd)
Am = fourier_spectral_ordinate(f, m, r_psm, fasm)
@test Af == Ad.value
@test Ad == Am
# test Beresnev source spectrum
srcb1p0 = SourceParameters(100.0, 1.0)
srcb1p5 = SourceParameters(100.0, 1.5)
fasb1p0 = FourierParameters(srcb1p0, pathf, sitef)
fasb1p5 = FourierParameters(srcb1p5, pathf, sitef)
f = 10.0
m = 6.0
r = 10.0
r_ps = equivalent_point_source_distance(r, m, fasb1p0)
Afb1p0 = fourier_spectral_ordinate(f, m, r_ps, fasb1p0)
Afb1p5 = fourier_spectral_ordinate(f, m, r_ps, fasb1p5)
@test Afb1p0 > Afb1p5
f = 1e-3
Afb1p0 = fourier_spectral_ordinate(f, m, r_ps, fasb1p0)
Afb1p5 = fourier_spectral_ordinate(f, m, r_ps, fasb1p5)
@test Afb1p0 ≈ Afb1p5 rtol = 1e-3
fi = [0.01, 0.1, 1.0, 10.0, 100.0]
# @code_warntype fourier_spectrum(fi, m, r_psf, fasf)
# @code_warntype fourier_spectrum(fi, m, r_psf, fasd)
# @code_warntype fourier_spectrum(fi, m, r_psd, fasd)
# @code_warntype fourier_spectrum(fi, m, r_psd, fasm)
Afif = fourier_spectrum(fi, m, r_psf, fasf)
Afid = fourier_spectrum(fi, m, r_psf, fasd)
Afim = fourier_spectrum(fi, m, r_psd, fasm)
for i = 1:length(fi)
@test Afif[i] == Afid[i].value
end
@test all(isapprox.(Afid, Afim))
fourier_spectrum!(Afif, fi, m, r_psf, fasf)
fourier_spectrum!(Afid, fi, m, r_psf, fasd)
fourier_spectrum!(Afim, fi, m, r_psd, fasm)
for i = 1:length(fi)
@test Afif[i] == Afid[i].value
end
@test all(isapprox.(Afid, Afim))
StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afif, fi, m, r_psf, fasf)
StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afid, fi, m, r_psf, fasd)
StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afim, fi, m, r_psd, fasm)
for i = 1:length(fi)
@test Afif[i] == Afid[i].value
end
@test all(isapprox.(Afid, Afim))
anef = AnelasticAttenuationParameters(Q0f, ηf, :Rrup)
aned = AnelasticAttenuationParameters(Q0d, ηd, :Rrup)
anem = AnelasticAttenuationParameters(Q0f, ηd, :Rrup)
pathf = PathParameters(geof, sat, anef)
pathd = PathParameters(geod, sat, aned)
pathm = PathParameters(geom, sat, anem)
fasf = FourierParameters(srcf, pathf, sitef)
fasd = FourierParameters(srcd, pathd, sited)
fasm = FourierParameters(srcf, pathm, sited)
r_psf = equivalent_point_source_distance(r, m, fasf)
r_psd = equivalent_point_source_distance(r, m, fasd)
r_psm = equivalent_point_source_distance(r, m, fasm)
Afif = fourier_spectrum(fi, m, r_psf, fasf)
Afid = fourier_spectrum(fi, m, r_psf, fasd)
Afim = fourier_spectrum(fi, m, r_psd, fasm)
StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afif, fi, m, r_psf, fasf)
StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afid, fi, m, r_psf, fasd)
StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afim, fi, m, r_psd, fasm)
for i = 1:length(fi)
@test Afif[i] == Afid[i].value
end
@test all(isapprox.(Afid, Afim))
# test parallel threading of fourier spectrum computation
# fi = exp10.(range(-2.0, stop=2.0, length=31))
# Afif = fourier_spectrum(fi, m, r_psf, fasf)
# @benchmark StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afif, fi, m, r_psf, fasf)
# @benchmark StochasticGroundMotionSimulation.squared_fourier_spectrum_par!(Afif, fi, m, r_psf, fasf)
ane = AnelasticAttenuationParameters(200.0, 0.0, :Rrup)
path = PathParameters(geof, sat, ane)
fas = FourierParameters(SourceParameters(100.0), path)
m = Dual(6.0)
r_rup = 10.0
r_ps = equivalent_point_source_distance(r_rup, m, fas)
Afid = fourier_spectrum(Vector{Float64}(), m, r_ps, fas)
@test eltype(Afid) <: Dual
Afid = fourier_spectrum(fi, m, r_ps, fas)
sqAfid = StochasticGroundMotionSimulation.squared_fourier_spectrum(fi, m, r_ps, fas)
@test any(isapprox.(sqAfid, Afid .^ 2))
# @code_warntype fourier_spectrum!(Afif, fi, m, r_psf, fasf)
# @code_warntype fourier_spectrum!(Afid, fi, m, r_psf, fasd)
# @code_warntype fourier_spectrum!(Afim, fi, m, r_psd, fasm)
Afid = fourier_spectrum(Vector{Float64}(), m, r_ps, fas)
fourier_spectrum!(Afid, Vector{Float64}(), m, r_ps, fas)
StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afid, Vector{Float64}(), m, r_ps, fas)
Afid = fourier_spectrum(fi, m, r_ps, fas)
fourier_spectrum!(Afid, fi, m, r_ps, fas)
StochasticGroundMotionSimulation.get_parametric_type(fas)
StochasticGroundMotionSimulation.get_parametric_type(fas.path.anelastic)
fi = exp.(range(log(1e-2), stop=log(1e2), length=1000))
Afid = fourier_spectrum(fi, m, r_ps, fas)
# @benchmark StochasticGroundMotionSimulation.fourier_spectrum!(Afid, fi, m, r_ps, fas)
# @benchmark StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afid, fi, m, r_ps, fas)
# @ballocated StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afid, fi, m, r_ps, fas)
# @profview @benchmark StochasticGroundMotionSimulation.fourier_spectrum!(Afid, fi, m, r_ps, fas)
# @profview @benchmark StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afid, fi, m, r_ps, fas)
# @benchmark Afsqid = StochasticGroundMotionSimulation.squared_fourier_spectrum(fi, m, r_ps, fas)
# @code_warntype StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afif, fi, m, r_psf, fasf)
# @code_warntype StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afid, fi, m, r_psf, fasd)
# @code_warntype StochasticGroundMotionSimulation.squared_fourier_spectrum!(Afim, fi, m, r_psd, fasm)
# @code_warntype combined_kappa_frequency(r_psf, fasf)
# @code_warntype combined_kappa_frequency(r_psd, fasd)
fkf = combined_kappa_frequency(r_psf, 0.5, fasf)
fkd = combined_kappa_frequency(r_psd, 0.5, fasd)
@test fkf == fkd.value
fkf = combined_kappa_frequency(r_psf, 0.5, fasf)
fkfd = combined_kappa_frequency(Dual(r_psf), 0.5, fasf)
@test fkf == fkfd.value
fkf0 = combined_kappa_frequency(r_psf, 0.5, fas)
fkf1 = combined_kappa_frequency(r_psf, 0.5, fasf)
@test fkf0 > fkf1
end
@testset "RVT" begin
@testset "Integration" begin
Δσf = 100.0
γ1f = 1.158
γ2f = 0.5
Q0f = 212.5
ηf = 0.65
κ0f = 0.038
Δσd = Dual{Float64}(Δσf)
γ1d = Dual{Float64}(γ1f)
γ2d = Dual{Float64}(γ2f)
Q0d = Dual{Float64}(Q0f)
ηd = Dual{Float64}(ηf)
κ0d = Dual{Float64}(κ0f)
srcf = SourceParameters(Δσf)
srcd = SourceParameters(Δσd)
Rrefi = [1.0, 50.0, Inf]
geof = GeometricSpreadingParameters(Rrefi, [γ1f, γ2f])
geod = GeometricSpreadingParameters(Rrefi, [γ1d, γ2d])
geom = GeometricSpreadingParameters(Rrefi, [γ1f], [γ2d], BitVector([0, 1]), :Piecewise)
anef = AnelasticAttenuationParameters(Q0f, ηf)
aned = AnelasticAttenuationParameters(Q0d, ηd)
anem = AnelasticAttenuationParameters(Q0f, ηd)
sat = NearSourceSaturationParameters(:BT15)
pathf = PathParameters(geof, sat, anef)
pathd = PathParameters(geod, sat, aned)
pathm = PathParameters(geom, sat, anem)
sitef = SiteParameters(κ0f, SiteAmpBoore2016_760())
sited = SiteParameters(κ0d, SiteAmpBoore2016_760())
fasf = FourierParameters(srcf, pathf, sitef)
fasd = FourierParameters(srcd, pathd, sited)
fasm = FourierParameters(srcf, pathm, sited)
m = 5.5
r = 10.88
r_psf = equivalent_point_source_distance(r, m, fasf)
r_psd = equivalent_point_source_distance(r, m, fasd)
r_psm = equivalent_point_source_distance(r, m, fasm)
sdof = Oscillator(100.0)
# Boore comparison (assume his are cgs units)
ps2db(f) = (1.0 / (2π * sdof.f_n))^2 * 1e4
dbm0_integrand(f) = StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(f, m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(f, sdof) * ps2db(f)
dbm0ln_integrand(lnf) = exp(lnf) * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(exp(lnf), m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(exp(lnf), sdof) * ps2db(exp(lnf))
dbm1_integrand(f) = (2π * f) * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(f, m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(f, sdof) * ps2db(f)
dbm1ln_integrand(lnf) = exp(lnf) * (2π * exp(lnf)) * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(exp(lnf), m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(exp(lnf), sdof) * ps2db(exp(lnf))
dbm2_integrand(f) = (2π * f)^2 * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(f, m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(f, sdof) * ps2db(f)
dbm2ln_integrand(lnf) = exp(lnf) * (2π * exp(lnf))^2 * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(exp(lnf), m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(exp(lnf), sdof) * ps2db(exp(lnf))
dbm4_integrand(f) = (2π * f)^4 * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(f, m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(f, sdof) * ps2db(f)
dbm4ln_integrand(lnf) = exp(lnf) * (2π * exp(lnf))^4 * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(exp(lnf), m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(exp(lnf), sdof) * ps2db(exp(lnf))
@time igk = 2 * quadgk(dbm0_integrand, 0.0, Inf)[1]
@time igk = 2 * quadgk(dbm0_integrand, exp(-7.0), exp(7.0))[1]
@time iglelnm = 2 * StochasticGroundMotionSimulation.gauss_intervals(dbm0ln_integrand, 250, -7.0, log(sdof.f_n), 7.0)
@test igk ≈ iglelnm rtol = 1e-4
@time igk = 2 * quadgk(dbm1_integrand, exp(-7.0), exp(7.0))[1]
@time iglelnm = 2 * StochasticGroundMotionSimulation.gauss_intervals(dbm1ln_integrand, 250, -7.0, log(sdof.f_n), 7.0)
@test igk ≈ iglelnm rtol = 1e-4
@time igk = 2 * quadgk(dbm2_integrand, exp(-7.0), exp(7.0))[1]
@time iglelnm = 2 * StochasticGroundMotionSimulation.gauss_intervals(dbm2ln_integrand, 250, -7.0, log(sdof.f_n), 7.0)
@test igk ≈ iglelnm rtol = 1e-3
@time igk = 2 * quadgk(dbm4_integrand, exp(-7.0), exp(7.0))[1]
@time iglelnm = 2 * StochasticGroundMotionSimulation.gauss_intervals(dbm4ln_integrand, 250, -7.0, log(sdof.f_n), 7.0)
@test igk ≈ iglelnm rtol = 1e-3
m0_integrand(f) = StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(f, m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(f, sdof)
m0ln_integrand(lnf) = exp(lnf) * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(exp(lnf), m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(exp(lnf), sdof)
m1_integrand(f) = (2π * f) * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(f, m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(f, sdof)
m1ln_integrand(lnf) = exp(lnf) * (2π * exp(lnf)) * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(exp(lnf), m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(exp(lnf), sdof)
m2_integrand(f) = (2π * f)^2 * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(f, m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(f, sdof)
m2ln_integrand(lnf) = exp(lnf) * (2π * exp(lnf))^2 * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(exp(lnf), m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(exp(lnf), sdof)
m4_integrand(f) = (2π * f)^4 * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(f, m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(f, sdof)
m4ln_integrand(lnf) = exp(lnf) * (2π * exp(lnf))^4 * StochasticGroundMotionSimulation.squared_fourier_spectral_ordinate(exp(lnf), m, r_psf, fasf) * StochasticGroundMotionSimulation.squared_transfer(exp(lnf), sdof)
@time igk = quadgk(m0_integrand, exp(-7.0), exp(7.0))[1]
@time igle = StochasticGroundMotionSimulation.gauss_interval(m0_integrand, 2000, 0.0, 300.0)
@time igleln = StochasticGroundMotionSimulation.gauss_interval(m0ln_integrand, 750, -7.0, 7.0)
@time iglelnm = StochasticGroundMotionSimulation.gauss_intervals(m0ln_integrand, 250, -7.0, log(sdof.f_n), 7.0)
# @test igk ≈ igle rtol=1e-2
@test igk ≈ igleln rtol = 1e-4
@test igk ≈ iglelnm rtol = 1e-4
lnfi = log.([1e-3, 1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3, sdof.f_n])
sort!(lnfi)
@time igk = quadgk(m1_integrand, exp(-7.0), exp(7.0))[1]
@time igle = StochasticGroundMotionSimulation.gauss_interval(m1_integrand, 1500, 0.0, 300.0)
@time igleln = StochasticGroundMotionSimulation.gauss_interval(m1ln_integrand, 750, -7.0, 7.0)
@time iglelnm = StochasticGroundMotionSimulation.gauss_intervals(m1ln_integrand, 250, -7.0, log(sdof.f_n), 7.0)
@time iglelnm = StochasticGroundMotionSimulation.gauss_intervals(m1ln_integrand, 30, lnfi...)
@time itr = StochasticGroundMotionSimulation.trapezoidal(m1ln_integrand, 60, lnfi...)
# @test igk ≈ igle rtol=1e-2
@test igk ≈ iglelnm rtol = 1e-4
@test igk ≈ itr rtol = 1e-3
@time igk = quadgk(m2_integrand, exp(-7.0), exp(7.0))[1]
@time iglelnm = StochasticGroundMotionSimulation.gauss_intervals(m2ln_integrand, 30, lnfi...)
@time itr = StochasticGroundMotionSimulation.trapezoidal(m2ln_integrand, 60, lnfi...)
@test igk ≈ iglelnm rtol = 1e-4
@test igk ≈ itr rtol = 1e-3
@time igk = quadgk(m4_integrand, exp(-7.0), exp(7.0))[1]
@time iglelnm = StochasticGroundMotionSimulation.gauss_intervals(m4ln_integrand, 30, lnfi...)
@time itr = StochasticGroundMotionSimulation.trapezoidal(m4ln_integrand, 60, lnfi...)
@test igk ≈ iglelnm rtol = 1e-4
@test igk ≈ itr rtol = 1e-3
integrand(x) = sin(x)
intervals = 101
x_min = 0.0
x_max = 2π
xx = collect(range(x_min, stop=x_max, length=intervals))
yy = integrand.(xx)
isr = StochasticGroundMotionSimulation.simpsons_rule(xx, yy)
ist = StochasticGroundMotionSimulation.trapezoidal_rule(xx, yy)
igk = quadgk(integrand, x_min, x_max)[1]
@test isr ≈ igk atol = 10 * eps()
@test ist ≈ igk atol = 10 * eps()
m = 6.0
r = 100.0
src = SourceParameters(100.0)
geo = GeometricSpreadingParameters([1.0, 50.0, Inf], [1.0, 0.5])
sat = NearSourceSaturationParameters(:BT15)
ane = AnelasticAttenuationParameters(200.0, 0.4, :Rrup)
path = PathParameters(geo, sat, ane)
site = SiteParameters(0.039)
fas = FourierParameters(src, path, site)
sdof = Oscillator(1.0)
integrand1(f) = StochasticGroundMotionSimulation.squared_transfer(f, sdof) * fourier_spectral_ordinate(f, m, r, fas)^2
intervals = 101
x_min = sdof.f_n / 1.1
x_max = sdof.f_n * 1.1
xx = collect(range(x_min, stop=x_max, length=intervals))
yy = integrand1.(xx)
isr = StochasticGroundMotionSimulation.simpsons_rule(xx, yy)
igk = quadgk(integrand1, x_min, x_max)[1]
@test isr ≈ igk rtol = 1e-6
@test isr ≈ igk atol = 1e-6
integrand2(f) = StochasticGroundMotionSimulation.squared_transfer(f, sdof) * fourier_spectral_ordinate(f, m, r, fas)^2
intervals = 101
x_min = 100.0
x_max = 200.0
xx = collect(range(x_min, stop=x_max, length=intervals))
yy = integrand2.(xx)
isr = StochasticGroundMotionSimulation.simpsons_rule(xx, yy)
igk = quadgk(integrand2, x_min, x_max)[1]
@test isr ≈ igk rtol = 1e-3
@test isr ≈ igk atol = 1e-6
integrand3(f) = (2π * f)^4 * StochasticGroundMotionSimulation.squared_transfer(f, sdof) * fourier_spectral_ordinate(f, m, r, fas)^2
intervals = 101
x_min = 100.0
x_max = 200.0
xx = collect(range(x_min, stop=x_max, length=intervals))
yy = integrand3.(xx)
isr = StochasticGroundMotionSimulation.simpsons_rule(xx, yy)
igk = quadgk(integrand3, x_min, x_max)[1]
@test isr ≈ igk rtol = 1e-3
@test isr ≈ igk atol = 1e-6
x_min = 300.0
x_max = 500.0
xx = collect(range(x_min, stop=x_max, length=intervals))
yy = integrand3.(xx)
isr = StochasticGroundMotionSimulation.simpsons_rule(xx, yy)
igk = quadgk(integrand3, x_min, x_max)[1]
@test isr ≈ igk rtol = 1e-3
@test isr ≈ igk atol = 1e-6
end
@testset "Spectral Moments" begin
Δσf = 100.0
γ1f = 1.0
γ2f = 0.5
Q0f = 200.0
ηf = 0.4
κ0f = 0.039
Δσd = Dual{Float64}(Δσf)
γ1d = Dual{Float64}(γ1f)
γ2d = Dual{Float64}(γ2f)
Q0d = Dual{Float64}(Q0f)
ηd = Dual{Float64}(ηf)
κ0d = Dual{Float64}(κ0f)
srcf = SourceParameters(Δσf)
srcd = SourceParameters(Δσd)
Rrefi = [1.0, 50.0, Inf]
geof = GeometricSpreadingParameters(Rrefi, [γ1f, γ2f])
geod = GeometricSpreadingParameters(Rrefi, [γ1d, γ2d])
geom = GeometricSpreadingParameters(Rrefi, [γ1f], [γ2d], BitVector([0, 1]), :Piecewise)
anef = AnelasticAttenuationParameters(Q0f, ηf)
aned = AnelasticAttenuationParameters(Q0d, ηd)
anem = AnelasticAttenuationParameters(Q0f, ηd)
sat = NearSourceSaturationParameters(:BT15)
pathf = PathParameters(geof, sat, anef)
pathd = PathParameters(geod, sat, aned)
pathm = PathParameters(geom, sat, anem)
sitef = SiteParameters(κ0f)
sited = SiteParameters(κ0d)
fasf = FourierParameters(srcf, pathf, sitef)
fasd = FourierParameters(srcd, pathd, sited)
fasm = FourierParameters(srcf, pathm, sited)
m = 6.0
r = 10.0
r_psf = equivalent_point_source_distance(r, m, fasf)
r_psd = equivalent_point_source_distance(r, m, fasd)
r_psm = equivalent_point_source_distance(r, m, fasm)
sdof = Oscillator(0.1)
order = 0
m0f = spectral_moment(order, m, r_psf, fasf, sdof)
m0d = spectral_moment(order, m, r_psd, fasd, sdof)
m0m = spectral_moment(order, m, r_psm, fasm, sdof)
@test m0f.m0 ≈ m0d.m0.value
@test m0d.m0 ≈ m0m.m0
order = 0
m0f = spectral_moment(order, m, r_psf, fasf, sdof, nodes=50)
m0d = spectral_moment(order, m, r_psd, fasd, sdof, nodes=50)
m0m = spectral_moment(order, m, r_psm, fasm, sdof, nodes=50)
@test m0f.m0 ≈ m0d.m0.value
@test m0d.m0 ≈ m0m.m0
# @code_warntype spectral_moment(order, m, r_psf, fasf, sdof)
# @code_warntype spectral_moment(order, m, r_psd, fasd, sdof)
# @code_warntype spectral_moment(order, m, r_psm, fasm, sdof)
# @time spectral_moments([0, 1, 2, 4], m, r_psf, fasf, sdof)
# @time spectral_moments([0, 1, 2, 4], m, r_psd, fasd, sdof)
# @time spectral_moments([0, 1, 2, 4], m, r_psm, fasm, sdof)
# @code_warntype spectral_moments([0, 1, 2, 4], m, r_psf, fasf, sdof)
# @code_warntype spectral_moments([0, 1, 2, 4], m, r_psd, fasd, sdof)
# @code_warntype spectral_moments([0, 1, 2, 4], m, r_psm, fasm, sdof)
smi = spectral_moments([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
smigk = StochasticGroundMotionSimulation.spectral_moments_gk([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
@test smi.m0 ≈ smigk.m0 rtol=1e-3
@test smi.m1 ≈ smigk.m1 rtol=1e-3
@test smi.m2 ≈ smigk.m2 rtol=1e-3
@test smi.m3 ≈ smigk.m3 rtol=1e-3
@test smi.m4 ≈ smigk.m4 rtol=1e-3
smi = spectral_moments([0, 1, 2, 3, 4], m, r_psf, fasf, sdof, nodes=50)
smigk = StochasticGroundMotionSimulation.spectral_moments_gk([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
@test smi.m0 ≈ smigk.m0 rtol = 1e-5
@test smi.m1 ≈ smigk.m1 rtol = 1e-5
@test smi.m2 ≈ smigk.m2 rtol = 1e-5
@test smi.m3 ≈ smigk.m3 rtol = 1e-5
@test smi.m4 ≈ smigk.m4 rtol = 1e-5
sdof = Oscillator(1 / 3)
smi = spectral_moments([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
# smai = spectral_moments_alt([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
smigk = StochasticGroundMotionSimulation.spectral_moments_gk([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
# @code_warntype spectral_moments([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
# @code_warntype spectral_moments_alt([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
# @benchmark spectral_moments([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
# @benchmark spectral_moments_alt([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
# @benchmark spectral_moments([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
# @profview @benchmark spectral_moments_alt([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
@test smi.m0 ≈ smigk.m0 rtol = 1e-3
@test smi.m1 ≈ smigk.m1 rtol = 1e-3
@test smi.m2 ≈ smigk.m2 rtol = 1e-3
@test smi.m3 ≈ smigk.m3 rtol = 1e-3
@test smi.m4 ≈ smigk.m4 rtol = 1e-3
m = Dual(6.0)
smdi = spectral_moments([0, 1, 2, 3, 4], m, r_psf, fasf, sdof)
smfi = spectral_moments([0, 1, 2, 3, 4], m.value, r_psf, fasf, sdof)
@test smdi.m0 ≈ smfi.m0 rtol = 1e-3
@test smdi.m1 ≈ smfi.m1 rtol = 1e-3
@test smdi.m2 ≈ smfi.m2 rtol = 1e-3
@test smdi.m3 ≈ smfi.m3 rtol = 1e-3
@test smdi.m4 ≈ smfi.m4 rtol = 1e-3
m = Dual(6.0)
smdi = spectral_moment(0, m, r_psf, fasf, sdof)
smfi = spectral_moment(0, m.value, r_psf, fasf, sdof)
@test smdi.m0 ≈ smfi.m0
rvt = RandomVibrationParameters()
Ti = [0.01, 0.1, 1.0]
m = Dual(6.0)
Sadi = rvt_response_spectrum(Ti, m, 10.0, fasf, rvt)
Safi = rvt_response_spectrum(Ti, m.value, 10.0, fasf, rvt)
for i = 1:length(Ti)
@test Sadi[i].value ≈ Safi[i]
end
rvt_response_spectrum!(Sadi, Ti, m, 10.0, fasf, rvt)
rvt_response_spectrum!(Safi, Ti, m.value, 10.0, fasf, rvt)
for i = 1:length(Ti)
@test Sadi[i].value ≈ Safi[i]
end
end
@testset "Peak Factor" begin
Δσf = 100.0
γ1f = 1.0
γ2f = 0.5
Q0f = 200.0
ηf = 0.4
κ0f = 0.039
Δσd = Dual{Float64}(Δσf)
γ1d = Dual{Float64}(γ1f)
γ2d = Dual{Float64}(γ2f)
Q0d = Dual{Float64}(Q0f)
ηd = Dual{Float64}(ηf)
κ0d = Dual{Float64}(κ0f)
srcf = SourceParameters(Δσf)
srcd = SourceParameters(Δσd)
Rrefi = [1.0, 50.0, Inf]
geof = GeometricSpreadingParameters(Rrefi, [γ1f, γ2f])
geod = GeometricSpreadingParameters(Rrefi, [γ1d, γ2d])
geom = GeometricSpreadingParameters(Rrefi, [γ1f], [γ2d], BitVector([0, 1]), :Piecewise)
anef = AnelasticAttenuationParameters(Q0f, ηf)
aned = AnelasticAttenuationParameters(Q0d, ηd)
anem = AnelasticAttenuationParameters(Q0f, ηd)
sat = NearSourceSaturationParameters(:BT15)
pathf = PathParameters(geof, sat, anef)
pathd = PathParameters(geod, sat, aned)
pathm = PathParameters(geom, sat, anem)
sitef = SiteParameters(κ0f)
sited = SiteParameters(κ0d)
fasf = FourierParameters(srcf, pathf, sitef)
fasd = FourierParameters(srcd, pathd, sited)
fasm = FourierParameters(srcf, pathm, sited)
m = 7.0
r = 1.0
r_psf = equivalent_point_source_distance(r, m, fasf)
r_psd = equivalent_point_source_distance(r, m, fasd)
r_psm = equivalent_point_source_distance(r, m, fasm)
sdof = Oscillator(1.0)
@time pfps = StochasticGroundMotionSimulation.peak_factor_dk80(m, r_psf, fasf, sdof)
@time pfpsn = StochasticGroundMotionSimulation.peak_factor_dk80(m, r_psf, fasf, sdof, nodes=30)
@time pfgk = StochasticGroundMotionSimulation.peak_factor_dk80_gk(m, r_psf, fasf, sdof)
# @code_warntype StochasticGroundMotionSimulation.peak_factor_dk80(m, r_psf, fasf, sdof)
@test pfps ≈ pfgk rtol = 1e-6
@test pfpsn ≈ pfgk rtol = 1e-6
@time pfps = StochasticGroundMotionSimulation.peak_factor_cl56(m, r_psf, fasf, sdof)
@time pfpsn = StochasticGroundMotionSimulation.peak_factor_cl56(m, r_psf, fasf, sdof, nodes=40)
@time pfgk = StochasticGroundMotionSimulation.peak_factor_cl56_gk(m, r_psf, fasf, sdof)
@test pfps ≈ pfgk rtol = 1e-5
@test pfpsn ≈ pfgk rtol = 1e-5
@test StochasticGroundMotionSimulation.vanmarcke_cdf(-1.0, 10.0, 0.5) == 0.0
rvt = RandomVibrationParameters(:CL56)
pf = peak_factor(6.0, 10.0, fasf, sdof, rvt)
rvt = RandomVibrationParameters(:DK80)
pf = peak_factor(6.0, 10.0, fasf, sdof, rvt)
rvt = RandomVibrationParameters(:PS)
pf = peak_factor(6.0, 10.0, fasf, sdof, rvt)
@test isnan(pf)
m = 6.0
r_rup = 10.0
r_ps = equivalent_point_source_distance(r_rup, m, fasf)
Dexf = excitation_duration(m, r_ps, fasf, rvt)
Dexd = excitation_duration(Dual(m), r_ps, fasf, rvt)
m0f = spectral_moment(0, m, r_ps, fasf, sdof)
m0d = spectral_moment(0, Dual(m), r_ps, fasf, sdof)
rvt = RandomVibrationParameters(:PS)
pf = peak_factor(Dexf, m0f, rvt)
@test isnan(pf)
pf = peak_factor(Dexd, m0d, rvt)
@test isnan(pf)
pf = peak_factor(Dexf, m0d, rvt)
@test isnan(pf)
rvt = RandomVibrationParameters(:CL56)
pf = peak_factor(Dexf, m0f, rvt)
@test isnan(pf)
# @test pf ≈ peak_factor(m, r_ps, fasf, sdof, RandomVibrationParameters(:CL56))
m0f = spectral_moments([0, 1, 2, 3, 4], m, r_ps, fasf, sdof)
m0d = spectral_moments([0, 1, 2, 3, 4], Dual(m), r_ps, fasf, sdof)
pff = peak_factor(Dexf, m0f, rvt)
pfd = peak_factor(Dexd, m0d, rvt)
pfm = peak_factor(Dexf, m0d, rvt)
@test pff ≈ pfd.value
@test pff ≈ pfm.value
pfi = StochasticGroundMotionSimulation.peak_factor_integrand_cl56(0.0, 10.0, 10.0)
@test pfi ≈ 1.0
pfi = StochasticGroundMotionSimulation.peak_factor_integrand_cl56(Inf, 10.0, 10.0)
@test pfi ≈ 0.0
pfi = StochasticGroundMotionSimulation.peak_factor_integrand_cl56(0.0, 10.0, 10.0)
@test pfi ≈ 1.0
pfi = StochasticGroundMotionSimulation.peak_factor_integrand_cl56(Inf, 10.0, 10.0)
@test pfi ≈ 0.0
pf0 = StochasticGroundMotionSimulation.peak_factor_cl56(10.0, 10.0)
pf1 = StochasticGroundMotionSimulation.peak_factor_cl56(10.0, 10.0, nodes=50)
@test pf0 ≈ pf1 rtol=1e-7
pf2 = StochasticGroundMotionSimulation.peak_factor_cl56(10.0, m0f)
pf3 = StochasticGroundMotionSimulation.peak_factor_cl56(10.0, m0f, nodes=50)
@test pf2 ≈ pf3 rtol=1e-6
pf4 = StochasticGroundMotionSimulation.peak_factor_dk80(10.0, m0f)
pf5 = StochasticGroundMotionSimulation.peak_factor_dk80(10.0, m0f, nodes=50)
@test pf4 ≈ pf5 rtol = 1e-7
rvt = RandomVibrationParameters(:DK80)
@test rvt.dur_rms == :BT15
end
@testset "Response Spectra" begin
Δσf = 100.0
γ1f = 1.0
γ2f = 0.5
Q0f = 200.0
ηf = 0.4
κ0f = 0.039
Δσd = Dual{Float64}(Δσf)
γ1d = Dual{Float64}(γ1f)
γ2d = Dual{Float64}(γ2f)
Q0d = Dual{Float64}(Q0f)
ηd = Dual{Float64}(ηf)
κ0d = Dual{Float64}(κ0f)
srcf = SourceParameters(Δσf)
srcd = SourceParameters(Δσd)
Rrefi = [1.0, 50.0, Inf]
geof = GeometricSpreadingParameters(Rrefi, [γ1f, γ2f])
geod = GeometricSpreadingParameters(Rrefi, [γ1d, γ2d])
geom = GeometricSpreadingParameters(Rrefi, [γ1f], [γ2d], BitVector([0, 1]), :Piecewise)
anef = AnelasticAttenuationParameters(Q0f, ηf)
aned = AnelasticAttenuationParameters(Q0d, ηd)
anem = AnelasticAttenuationParameters(Q0f, ηd)
sat = NearSourceSaturationParameters(:BT15)
pathf = PathParameters(geof, sat, anef)
pathd = PathParameters(geod, sat, aned)
pathm = PathParameters(geom, sat, anem)
sitef = SiteParameters(κ0f)
sited = SiteParameters(κ0d)
fasf = FourierParameters(srcf, pathf, sitef)
fasd = FourierParameters(srcd, pathd, sited)
fasm = FourierParameters(srcf, pathm, sited)
m = 7.0
r = 1.0
r_psf = equivalent_point_source_distance(r, m, fasf)
r_psd = equivalent_point_source_distance(r, m, fasd)
r_psm = equivalent_point_source_distance(r, m, fasm)
Ti = [0.01, 0.02, 0.03, 0.04, 0.05, 0.075, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0, 7.5, 10.0]
rvt = RandomVibrationParameters()
Saif = rvt_response_spectrum(Ti, m, r_psf, fasf, rvt)
Said = rvt_response_spectrum(Ti, m, r_psd, fasd, rvt)
Saim = rvt_response_spectrum(Ti, m, r_psm, fasm, rvt)
for i = 1:length(Ti)
@test Saif[i] ≈ Said[i].value
end
@test all(isapprox.(Said, Saim))
# test Beresnev source spectrum
srcb1p0 = SourceParameters(100.0, 1.0)
srcb1p5 = SourceParameters(100.0, 1.5)
fasb1p0 = FourierParameters(srcb1p0, pathf, sitef)
fasb1p5 = FourierParameters(srcb1p5, pathf, sitef)
T = 0.05
m = 6.0
r = 10.0
r_ps = equivalent_point_source_distance(r, m, fasb1p0)
Sab1p0 = rvt_response_spectral_ordinate(T, m, r_ps, fasb1p0, rvt)
Sab1p5 = rvt_response_spectral_ordinate(T, m, r_ps, fasb1p5, rvt)
@test Sab1p0 > Sab1p5
@test Sab1p5 < Sab1p0
rvt = RandomVibrationParameters(:CL56)
Sab1p0 = rvt_response_spectral_ordinate(T, m, r_ps, fasb1p0, rvt)
Sab1p5 = rvt_response_spectral_ordinate(T, m, r_ps, fasb1p5, rvt)
@test Sab1p0 > Sab1p5
@test Sab1p5 < Sab1p0
# @code_warntype rvt_response_spectrum(Ti, m, r_psf, fasf, rvt)
# @code_warntype rvt_response_spectrum(Ti, m, r_psd, fasd, rvt)
# @code_warntype rvt_response_spectrum(Ti, m, r_psm, fasm, rvt)
end
end
end
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 3625 | # StochasticGroundMotionSimulation
[](https://pstafford.github.io/StochasticGroundMotionSimulation.jl/stable)
[](https://pstafford.github.io/StochasticGroundMotionSimulation.jl/dev)
[](https://github.com/pstafford/StochasticGroundMotionSimulation.jl/actions)
[](https://codecov.io/gh/pstafford/StochasticGroundMotionSimulation.jl)
[](https://doi.org/10.5281/zenodo.4667333)
[Julia](http://www.julialang.org) package to simulate response spectral ordinates via random vibration theory.
The package also provides general functionality for working with Fourier amplitude spectra and duration models.
Package defines new custom types:
- `FourierParameters`: representing the parameters of the Fourier amplitude spectrum
- `Oscillator`: representing a single degree-of-freedom oscillator, and
- `RandomVibrationParameters`: defining methods/models used for random vibration calculations
The `FourierParameters` type is constructed from three components:
- `SourceParameters`: representing source properties, such as stress parameter, source velocity and density, _etc_
- `PathParameters`: representing the path scaling. This component is itself comprised of three components:
- `GeometricSpreadingParameters`: defines the geometric spreading model
- `NearSourceSaturationParameters`: defines the near-source saturation model, and
- `AnelasticAttenuationParameters`: defines the anelastic attenuation
- `SiteParameters`: defines both the site amplification/impedance function and the site damping (via a kappa filter)
The package is developed in a manner to enable automatic differentiation operations to be performed via `ForwardDiff.jl`.
This makes the package suitable for gradient-based inversions of ground-motion data, as well as inversions of published ground-motion models.
## Installation
First, a working version of [Julia](http://www.julialang.org) needs to be installed.
The relevant binary (or source code) can be downloaded from the [Julia Downloads Page](https://julialang.org/downloads/).
`StochasticGroundMotionSimulation.jl` is a registered package and can be installed directly from the package manager.
Within a Julia REPL session, access the package manager via `]`, and then at the `pkg>` prompt type (below the `pkg>` component is part of the prompt, so only the `add ...` portion is necessary).
```julia
pkg> add StochasticGroundMotionSimulation
```
## Usage
Within a Julia session, bring the functionality of `StochasticGroundMotionSimulation.jl` into scope by typing (here the `julia>` component represents the prompt within a REPL session, within a text editor, simply type `using StochasticGroundMotionSimulation`):
```julia
julia> using StochasticGroundMotionSimulation
```
## Accessing Help
Aside from the [documentation](https://pstafford.github.io/StochasticGroundMotionSimulation.jl/stable) accessible from the links at the top of this page, descriptions of methods and types within the package can be accessed within REPL sessions (or within Juno).
Within, a REPL session, enter `?` to access the help prompt.
Then, type the relevant item.
For example:
```julia
help?> FourierParameters
```
## Citing
See [`CITATION.bib`](CITATION.bib) for the relevant reference(s).
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 3726 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
# Fourier Parameters
Definition of the various custom types within the `StochasticGroundMotionSimulation` module.
Types to store properties related to source, path, and site components of the Fourier spectral model are provided.
```@docs
FourierParameters
```
## Source Parameters
The type `SourceParameters` holds the properties required to define the source spectrum of the Fourier Amplitude Spectrum.
```@docs
SourceParameters
```
## Path Parameters
The type `PathParameters` holds the properties required to define the path scaling of the Fourier Amplitude Spectrum.
```@docs
PathParameters
```
This type also hold instances of three other custom types that define aspects of the path scaling:
- `GeometricSpreadingParameters` defined in [Geometric Spreading Parameters](@ref)
- `NearSourceSaturationParameters` defined in [Near Source Saturation Parameters](@ref)
- `AnelasticAttenuationParameters` defined in [Anelastic Attenuation Parameters](@ref)
### Geometric Spreading Parameters
```@docs
GeometricSpreadingParameters
```
### Near-Source Saturation Parameters
Near source saturation models are represented within the `NearSourceSaturationParameters` type.
This type can simply identify existing models that are implemented, such as:
- Yenier & Atkinson (2015)
- Boore & Thompson (2015)
- Chiou & Youngs (2014) (the average of their ``h(\bm{M})`` term over all periods)
But, specific fixed values can also be provided as well as parameters that are subsequently operated upon:
```@docs
NearSourceSaturationParameters
```
Consider defining a new saturation model that was a simply bilinear model in ``\ln h(\bm{M})-\bm{M}`` space.
We simply pass in the various parameters that would be required for our saturation model into the available fields of `NearSourceSaturationParameters`, and then define a custom function that operates upon these fields.
```@setup ex1
using StochasticGroundMotionSimulation
```
```@example ex1
m_min = 3.0
h_min = 0.5
m_hinge = 6.0
h_hinge = 5.0
m_max = 8.0
h_max = 30.0
sat = NearSourceSaturationParameters([m_min, m_hinge, m_max], [h_min, h_hinge, h_max])
function bilinear_saturation(m, sat)
if m <= sat.mRefi[1]
return sat.hconi[1]
elseif m <= sat.mRefi[2]
return sat.hconi[1] + (m - sat.mRefi[1])/(sat.mRefi[2]-sat.mRefi[1])*(sat.hconi[2] - sat.hconi[1])
elseif m <= sat.mRefi[3]
return sat.hconi[2] + (m - sat.mRefi[2])/(sat.mRefi[3]-sat.mRefi[2])*(sat.hconi[3] - sat.hconi[2])
else
return sat.hconi[3]
end
end
```
Any subsequent calculation for a particular magnitude could then make use of this function along with a new `NearSourceSaturationParameters` instance that just contains a fixed saturation length.
```@setup ex2
using StochasticGroundMotionSimulation
m_min = 3.0
h_min = 0.5
m_hinge = 6.0
h_hinge = 5.0
m_max = 8.0
h_max = 30.0
sat = NearSourceSaturationParameters([m_min, m_hinge, m_max], [h_min, h_hinge, h_max])
function bilinear_saturation(m, sat)
if m <= sat.mRefi[1]
return sat.hconi[1]
elseif m <= sat.mRefi[2]
return sat.hconi[1] + (m - sat.mRefi[1])/(sat.mRefi[2]-sat.mRefi[1])*(sat.hconi[2] - sat.hconi[1])
elseif m <= sat.mRefi[3]
return sat.hconi[2] + (m - sat.mRefi[2])/(sat.mRefi[3]-sat.mRefi[2])*(sat.hconi[3] - sat.hconi[2])
else
return sat.hconi[3]
end
end
```
```@example ex2
m = 5.0
h_m = bilinear_saturation(m, sat)
new_sat = NearSourceSaturationParameters(h_m)
```
### Anelastic Attenuation Parameters
```@docs
AnelasticAttenuationParameters
```
## Site Parameters
The type `SiteParameters` holds information related to the site response -- both impedance effects and damping.
```@docs
SiteParameters
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 1249 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
# Fourier Amplitude Spectrum
The Fourier amplitude spectrum (FAS) can be represented as the product of source, path and site contributions.
Specifically, the Fourier amplitude spectrum ``|A(f)|`` of acceleration (in units of m/s) is defined as:
```math
|A(f; \bm{\theta})| = E(f; \bm{\theta}_E)\times P(f; \bm{\theta}_P) \times S(f; \bm{\theta}_S)
```
where ``f`` is a frequency in Hz, and ``\bm{\theta}`` holds all of the relevant model parameters and predictor variables.
The [Fourier Source Spectrum](@ref), ``E(f; \bm{\theta}_E)`` is a function of the earthquake magnitude ``m``, as well as other properties of the source.
The [Path Scaling](@ref), ``P(f; \bm{\theta}_P)`` accounts for the effects of both geometric spreading and anelastic attenuation.
The [Site Scaling](@ref), ``S(f; \bm{\theta}_S)`` includes the effects of near-surface impedance as well as damping (``\kappa_0``) effects.
Fourier spectral ordinates, or complete Fourier spectra are obtained via the functions:
```@docs
fourier_spectrum
fourier_spectrum!
fourier_spectral_ordinate
```
Individual contributions to the Fourier spectrum are also available, for example:
```@docs
fourier_path
fourier_site
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 3367 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
# StochasticGroundMotionSimulation
Documentation for the Julia package `StochasticGroundMotionSimulation.jl`.
The main module `StochasticGroundMotionSimulation` provides an interface to the stochastic method for the simulation of response spectral ordinates via Random Vibration Theory.
The package makes use of three main components:
- `FourierParameters`: defining the properties of the Fourier amplitude spectrum
- `RandomVibrationParameters`: defining the properties of the random vibration theory calculations. Specifically, defining the duration model(s) to be used along with the peak factor method
- `Oscillator`: defines the properties of the single degree-of-freedom oscillator for which response spectral ordinates are computed.
To compute a response spectrum, or a response spectral ordinate, the above components along with a definition of a magnitude-distance scenario are required.
The package is written to enable automatic differentiation operations to be applied to the principle parameters defining the Fourier amplitude spectrum.
This is done in order to facilitate the use of this package for gradient-based inversions of observed ground-motions, or inversions of published empirical ground-motion models.
## Contents
```@contents
Pages = ["fourier_parameters.md","random_vibration_parameters.md","sdof_parameters.md]
Depth = 4
```
## Example
A number of default parameters are already set within the package.
```@example
using StochasticGroundMotionSimulation
# specify some parameters defining the Fourier amplitude spectrum
Δσ = 100.0 # the stress parameter (in bar)
Rrefi = [ 1.0, 50.0, Inf ] # reference distances for the geometric spreading
γi = [ 1.0, 0.5 ] # geometric spreading rates for distances between the references distances
Q0 = 200.0 # quality factor ``Q_0 \in Q(f) = Q_0 f^\eta``
η = 0.5 # quality exponent ``\eta \in Q(f) = Q_0 f^\eta``
κ0 = 0.039 # site kappa value
# construct a `SourceParameters` instance
src = SourceParameters(Δσ)
# construct a `GeometricSpreadingParameters` instance using the reference distances, spreading rates, and spreading model
geo = GeometricSpreadingParameters(Rrefi, γi, :CY14)
# define the near-source saturation model
sat = NearSourceSaturationParameters(:BT15)
# define the anelastic attenuation properties
ane = AnelasticAttenuationParameters(Q0, η)
# use the `geo`, `sat` and `ane` instances to construct a `PathParameters` instance
path = PathParameters(geo, sat, ane)
# define the `SiteParameters`
site = SiteParameters(κ0, SiteAmpBoore2016_760())
# combine `src`, `path` and `site` instances to define the overall `FourierParameters`
fas = FourierParameters(src, path, site)
# use default properties for the `RandomVibrationParameters`
rvt = RandomVibrationParameters()
# define the response period, and magnitude-distance scenario of interest
T = 1.0
m = 6.0
r_rup = 10.0
# compute the equivalent point-source distance for this scenario
r_ps = equivalent_point_source_distance(r_rup, m, fas)
# compute the response spectral ordinate
Sa = rvt_response_spectral_ordinate(T, m, r_ps, fas, rvt)
# write out the results
println("Sa = $(round(Sa, sigdigits=4)) g, for m = $m, r_rup = $r_rup km, and a period of T = $(T) s")
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 77 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
```@index
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 3086 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
# Path Scaling
The path scaling can be broken into geometric spreading -- including the effects of near-source saturation -- and anelastic attenuation.
Within `StochasticGroundMotionSimulation` the `PathParameters` type holds custom structs that relate to each of these three components:
- `GeometricSpreadingParameters` defines the geometric spreading model (spreading rates, transition distances, and functional scaling)
- `NearSourceSaturationParameters` defines the near-source saturation model, or the finite fault factors
- `AnelasticAttenuationParameters` defines the properties of the anelastic attenuation model.
## Geometric Spreading
Parameters for representing geometric spreading are contained within a `GeometricSpreadingParameters` instance.
To compute the actual geometric spreading for a given distance we make use of the `geometric_spreading` function:
```@docs
geometric_spreading
```
This function takes different options that define different spreading functions.
For example, the `:CY14` option uses the functional form of Chiou & Youngs (2014), but uses an equivalent point-source distance throughout.
```math
\ln g(r_{ps}) = -\gamma_1 \ln(r_{ps}) + \frac{\left(\gamma_1 -\gamma_f\right)}{2} \ln\left( \frac{ r_{ps}^2 + r_t^2 }{r_{0}^2 + r_t^2} \right)
```
The alternative `:CY14mod` option combines a point-source distance in the near field, with `r_rup` scaling in the far field.
```math
\ln g(r_{ps},r_{rup}) = -\gamma_1 \ln(r_{ps}) + \frac{\left(\gamma_1 -\gamma_f\right)}{2} \ln\left( \frac{ r_{rup}^2 + r_t^2 }{r_{0}^2 + r_t^2} \right)
```
In both of the above cases, the ``r_{0}`` term is the reference distance that is used to define the source spectral amplitude.
The ``r_{ps}`` is the equivalent point-source distance that can be defined using:
```@docs
equivalent_point_source_distance
```
## Near Source Saturation
The `NearSourceSaturationParameters` are crucial for computing the equivalent point-source distance metric.
Generally, the equivalent point-source distance can be computed via:
```math
r_{ps} = \left( r_{rup}^n + h(\bm{M})^n \right)^{1/n}
```
and it is most common to follow Boore & Thompson (2015) and to use ``n=2`` so that:
```math
r_{ps} = \sqrt{ r_{rup}^2 + h(\bm{M})^2 }
```
### Functionality
```@docs
near_source_saturation
```
## Anelastic Attenuation
The anelastic attenuation filter has the general form:
```math
\exp\left[ -\frac{\pi f r}{Q(f) c_Q} \right]
```
where, normally, ``Q(f)=Q_0 f^\eta`` such that:
```math
\exp\left[ -\frac{\pi f^{1-\eta} r}{Q_0 c_Q} \right]
```
The `AnelasticAttenuationParameters` type therefore holds the values of ``Q0``, ``\eta``, and ``c_Q``.
In addition, it holds a field `rmetric` that can take values of `:Rrup` and `:Rps` depending upon whether one wishes to interpret the distance within the exponential function as the rupture distance, `:Rrup`, or the equivalent point-source distance, `:Rps`.
### Functionality
```@docs
anelastic_attenuation
fourier_attenuation
combined_kappa_frequency
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 2479 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
# Random Vibration Theory Parameters
Definition of the custom type `RandomVibrationParameters` to represent the model components/approaches used for the random vibration theory calculations.
In particular, the type stores symbols to define the:
- `pf_method` the peak factor model/method to use.
- `dur_ex` specifies the excitation duration model to use,
- `dur_rms` specifies the model to use for converting excitation to RMS duration, and
- `dur_region`: the region or tectonic setting for excitation duration predictions, _i.e._ `:ACR` or `:SCR` for active and stable crustal regions
```@docs
RandomVibrationParameters
```
Note that the default specification is:
```@example
RandomVibrationParameters() = RandomVibrationParameters(:DK80, :BT14, :BT15, :ACR)
```
However, an alternative constructor exists that takes a `pf_method` as a single argument, or that take a `pf_method` and `dur_region` specification.
For these constructors, the `dur_rms` model is linked to the `pf_method` peak factor method:
- `DK80` is paired with `:BT15`, and is the default
- `CL56` is paired with `:BT12`
As these are currently the only two `dur_rms` models implemented, the constructor is specified as:
```@example
RandomVibrationParameters(pf) = RandomVibrationParameters(pf, :BT14, ((pf == :DK80) ? :BT15 : :BT12), :ACR)
```
In all cases, the Boore & Thompson (2014, 2015) excitation duration model is employed as that is the only model currently implemented.
This model uses a standard source duration definition, related to the source corner frequencies, and then applies a path duration model that is purely a function of the equivalent point-source distance.
The path duration model depends upon the region, as in active crustal regions or stable crustal regions.
## Functionality
The overall goal of these random vibration methods is to compute:
```math
S_a = \psi \sqrt{ \frac{m_0}{D_{rms}}}
```
where ``\psi`` is the peak factor computed from `peak_factor`, ``m_0`` is the zeroth order spectral moment computed from `spectral_moment`, and ``D_{rms}`` is the root-mean-square duration computed from `dur_rms`.
The main methods used to interact with `RandomVibrationParameters` are:
```@docs
SpectralMoments
create_spectral_moments
spectral_moment
spectral_moments
spectral_moments_gk
excitation_duration
rms_duration
peak_factor
rvt_response_spectral_ordinate
rvt_response_spectrum
rvt_response_spectrum!
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 485 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
# Single Degree of Freedom Oscillator Parameters
Definition of the custom type, `Oscillator` to represent a single degree of freedom (SDOF) oscillator.
Type simply stores the oscillator frequency and damping ratio.
```@docs
Oscillator
```
## Functionality
The main methods that are used to interact with `Oscillator` instances are:
```@docs
period
transfer
transfer!
squared_transfer
squared_transfer!
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 4261 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
# Site Scaling
Site response is defined in terms of site amplification, or impedance effects, as well as damping -- via a _kappa_ filter.
The overall site model is therefore written as:
`` S(f; \bm{\theta}_S) = S_I(f) \times S_K(f) ``
with ``S_I(f)`` representing the impedance effects, and ``S_K(f)`` being the kappa filter.
## Impedance functions
Impedance effects are represented using custom types that define an `amplification` function.
These functions take a frequency as an argument and return the corresponding amplification level.
Each of these custom types is a subtype of the abstract type `SiteAmplification`
Currently, the following impedance functions (custom types) are implemented:
- `SiteAmpBoore2016_760`: is the Boore (2016) impedance function for a Western US generic rock profile with ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_ask14_620`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Abrahamson _et al._ (2014) GMM. The reference profile has a ``V_{S,30}=620`` m/s
- `SiteAmpAlAtikAbrahamson2021_ask14_760`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Abrahamson _et al._ (2014) GMM. The reference profile has a ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_ask14_1100`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Abrahamson _et al._ (2014) GMM. The reference profile has a ``V_{S,30}=1100`` m/s
- `SiteAmpAlAtikAbrahamson2021_bssa14_620`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Boore _et al._ (2014) GMM. The reference profile has a ``V_{S,30}=620`` m/s
- `SiteAmpAlAtikAbrahamson2021_bssa14_760`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Boore _et al._ (2014) GMM. The reference profile has a ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_bssa14_1100`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Boore _et al._ (2014) GMM. The reference profile has a ``V_{S,30}=1100`` m/s
- `SiteAmpAlAtikAbrahamson2021_cb14_620`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Campbell & Bozorgnia (2014) GMM. The reference profile has a ``V_{S,30}=620`` m/s
- `SiteAmpAlAtikAbrahamson2021_cb14_760`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Campbell & Bozorgnia (2014) GMM. The reference profile has a ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_cb14_1100`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Campbell & Bozorgnia (2014) GMM. The reference profile has a ``V_{S,30}=1100`` m/s
- `SiteAmpAlAtikAbrahamson2021_cy14_620`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Chiou & Youngs (2014) GMM. The reference profile has a ``V_{S,30}=620`` m/s
- `SiteAmpAlAtikAbrahamson2021_cy14_760`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Chiou & Youngs (2014) GMM. The reference profile has a ``V_{S,30}=760`` m/s
- `SiteAmpAlAtikAbrahamson2021_cy14_1100`: is the Al Atik & Abrahamson (2021) impedance function obtained by inverting the Chiou & Youngs (2014) GMM. The reference profile has a ``V_{S,30}=1100`` m/s
- `SiteAmpUnit`: simply provides a unit impedance for all frequencies, _i.e._, ``S_I(f)=1.0``
- `SiteAmpConstant`: provides a constant, `c`, impedance for all frequencies, _i.e._, ``S_I(f)=c``
```@docs
site_amplification
SiteAmpUnit
SiteAmpConstant
SiteAmpBoore2016_760
SiteAmpAlAtikAbrahamson2021_ask14_620
SiteAmpAlAtikAbrahamson2021_ask14_760
SiteAmpAlAtikAbrahamson2021_ask14_1100
SiteAmpAlAtikAbrahamson2021_bssa14_620
SiteAmpAlAtikAbrahamson2021_bssa14_760
SiteAmpAlAtikAbrahamson2021_bssa14_1100
SiteAmpAlAtikAbrahamson2021_cb14_620
SiteAmpAlAtikAbrahamson2021_cb14_760
SiteAmpAlAtikAbrahamson2021_cb14_1100
SiteAmpAlAtikAbrahamson2021_cy14_620
SiteAmpAlAtikAbrahamson2021_cy14_760
SiteAmpAlAtikAbrahamson2021_cy14_1100
```
## Kappa filter
In addition to the impedance effects, the near surface damping is represented by a generic kappa filter:
```math
S_K(f) = \exp\left( -\pi \kappa_0 f \right)
```
```@docs
kappa_filter
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.2.6 | b88d988a6a59a7ac37d73f8517a7022613997c68 | docs | 874 | ```@meta
CurrentModule = StochasticGroundMotionSimulation
```
# Fourier Source Spectrum
The source spectrum can be computed through interaction with the `SourceParameters` type, or the higher level `FourierParameters` type that holds a `SourceParameters` instance as a property.
The source spectrum ``E(f; \bm{\theta}E)`` is most commonly written in terms of:
```math
E(f; \bm{\theta}_E) = \mathcal{C} M_0 E_s(f; \bm{\theta}_E)
```
where ``\mathcal{C}`` is a constant term, to be defined shortly, ``M_0`` is the seismic moment, and ``E_s(f; \bm{\theta}_E)`` is the source spectral shape.
The most commonly adopted source spectral shape is the ``\omega^2`` model that has the form:
```math
E_s(f) = \frac{1}{1 + \left(\frac{f}{f_c}\right)^2}
```
## Functionality
```@docs
fourier_constant
fourier_source_shape
fourier_source
corner_frequency
magnitude_to_moment
```
| StochasticGroundMotionSimulation | https://github.com/pstafford/StochasticGroundMotionSimulation.jl.git |
|
[
"MIT"
] | 0.4.2 | 2dab0221fe2b0f2cb6754eaa743cc266339f527e | code | 9405 | module MappedArrays
using Base: @propagate_inbounds
export AbstractMappedArray, MappedArray, ReadonlyMappedArray, mappedarray, of_eltype
abstract type AbstractMappedArray{T,N} <: AbstractArray{T,N} end
abstract type AbstractMultiMappedArray{T,N} <: AbstractMappedArray{T,N} end
struct ReadonlyMappedArray{T,N,A<:AbstractArray,F} <: AbstractMappedArray{T,N}
f::F
data::A
end
struct MappedArray{T,N,A<:AbstractArray,F,Finv} <: AbstractMappedArray{T,N}
f::F
finv::Finv
data::A
end
struct ReadonlyMultiMappedArray{T,N,AAs<:Tuple{Vararg{AbstractArray}},F} <: AbstractMultiMappedArray{T,N}
f::F
data::AAs
function ReadonlyMultiMappedArray{T,N,AAs,F}(f, data) where {T,N,AAs,F}
inds = axes(first(data))
checkinds(inds, Base.tail(data)...)
new(f, data)
end
end
struct MultiMappedArray{T,N,AAs<:Tuple{Vararg{AbstractArray}},F,Finv} <: AbstractMultiMappedArray{T,N}
f::F
finv::Finv
data::AAs
function MultiMappedArray{T,N,AAs,F,Finv}(f::F, finv::Finv, data) where {T,N,AAs,F,Finv}
inds = axes(first(data))
checkinds(inds, Base.tail(data)...)
new(f, finv, data)
end
end
@inline function checkinds(inds, A, As...)
@noinline throw1(i, j) = throw(DimensionMismatch("arrays do not all have the same axes (got $i and $j)"))
iA = axes(A)
iA == inds || throw1(inds, iA)
checkinds(inds, As...)
end
checkinds(inds) = nothing
"""
M = mappedarray(f, A)
M = mappedarray(f, A, B, C...)
Create a view `M` of the array `A` that applies `f` to every element
of `A`; `M == map(f, A)`, with the difference that no storage
is allocated for `M`. The view is read-only (you can get values but
not set them).
When multiple input arrays are supplied, `M[i] = f(A[i], B[i], C[i]...)`.
"""
function mappedarray(f, data::AbstractArray)
infer_eltype() = Base._return_type(f, eltypes(data))
T = infer_eltype()
ReadonlyMappedArray{T,ndims(data),typeof(data),typeof(f)}(f, data)
end
function mappedarray(::Type{T}, data::AbstractArray) where T
ReadonlyMappedArray{T,ndims(data),typeof(data),Type{T}}(T, data)
end
function mappedarray(f, data::AbstractArray...)
infer_eltype() = Base._return_type(f, eltypes(data))
T = infer_eltype()
ReadonlyMultiMappedArray{T,ndims(first(data)),typeof(data),typeof(f)}(f, data)
end
function mappedarray(::Type{T}, data::AbstractArray...) where T
ReadonlyMultiMappedArray{T,ndims(first(data)),typeof(data),Type{T}}(T, data)
end
"""
M = mappedarray(f, finv, A)
M = mappedarray(f, finv, A, B, C...)
creates a view of the array `A` that applies `f` to every element of
`A`. The inverse function, `finv`, allows one to also set values of
the view and, correspondingly, the values in `A`.
When multiple input arrays are supplied, `M[i] = f(A[i], B[i], C[i]...)`.
"""
function mappedarray(f, finv, data::AbstractArray)
infer_eltype() = Base._return_type(f, eltypes(data))
T = infer_eltype()
MappedArray{T,ndims(data),typeof(data),typeof(f),typeof(finv)}(f, finv, data)
end
function mappedarray(f, finv, data::AbstractArray...)
infer_eltype() = Base._return_type(f, eltypes(data))
T = infer_eltype()
MultiMappedArray{T,ndims(first(data)),typeof(data),typeof(f),typeof(finv)}(f, finv, data)
end
function mappedarray(::Type{T}, finv, data::AbstractArray...) where T
MultiMappedArray{T,ndims(first(data)),typeof(data),Type{T},typeof(finv)}(T, finv, data)
end
function mappedarray(f, ::Type{Finv}, data::AbstractArray...) where Finv
infer_eltype() = Base._return_type(f, eltypes(data))
T = infer_eltype()
MultiMappedArray{T,ndims(first(data)),typeof(data),typeof(f),Type{Finv}}(f, Finv, data)
end
function mappedarray(::Type{T}, ::Type{Finv}, data::AbstractArray...) where {T,Finv}
MultiMappedArray{T,ndims(first(data)),typeof(data),Type{T},Type{Finv}}(T, Finv, data)
end
"""
M = of_eltype(T, A)
M = of_eltype(val::T, A)
creates a view of `A` that lazily-converts the element type to `T`.
"""
of_eltype(::Type{T}, data::AbstractArray{S}) where {S,T} = mappedarray(x->convert(T,x)::T, y->convert(S,y)::S, data)
of_eltype(::Type{T}, data::AbstractArray{T}) where {T} = data
of_eltype(::T, data::AbstractArray{S}) where {S,T} = of_eltype(T, data)
Base.parent(A::AbstractMappedArray) = A.data
Base.size(A::AbstractMappedArray) = size(A.data)
Base.size(A::AbstractMultiMappedArray) = size(first(A.data))
Base.axes(A::AbstractMappedArray) = axes(A.data)
Base.axes(A::AbstractMultiMappedArray) = axes(first(A.data))
parenttype(::Type{ReadonlyMappedArray{T,N,A,F}}) where {T,N,A,F} = A
parenttype(::Type{MappedArray{T,N,A,F,Finv}}) where {T,N,A,F,Finv} = A
parenttype(::Type{ReadonlyMultiMappedArray{T,N,A,F}}) where {T,N,A,F} = A
parenttype(::Type{MultiMappedArray{T,N,A,F,Finv}}) where {T,N,A,F,Finv} = A
Base.IndexStyle(::Type{MA}) where {MA<:AbstractMappedArray} = IndexStyle(parenttype(MA))
@inline Base.IndexStyle(M::AbstractMultiMappedArray) = IndexStyle(M.data...)
Base.IndexStyle(::Type{MA}) where {MA<:AbstractMultiMappedArray} = _indexstyle(MA)
Base.@pure _indexstyle(::Type{MA}) where {MA<:AbstractMultiMappedArray} =
_indexstyle(map(IndexStyle, parenttype(MA).parameters)...)
_indexstyle(a, b, c...) = _indexstyle(IndexStyle(a, b), c...)
_indexstyle(a, b) = IndexStyle(a, b)
# IndexLinear implementations
@propagate_inbounds Base.getindex(A::AbstractMappedArray, i::Int) =
A.f(A.data[i])
@propagate_inbounds Base.getindex(M::AbstractMultiMappedArray, i::Int) =
M.f(_getindex(i, M.data...)...)
@propagate_inbounds function Base.setindex!(A::MappedArray{T},
val,
i::Int) where {T}
A.data[i] = A.finv(convert(T, val)::T)
end
@propagate_inbounds function Base.setindex!(A::MultiMappedArray{T},
val,
i::Int) where {T}
vals = A.finv(convert(T, val)::T)
_setindex!(A.data, vals, i)
return vals
end
# IndexCartesian implementations
@propagate_inbounds function Base.getindex(A::AbstractMappedArray{T,N},
i::Vararg{Int,N}) where {T,N}
A.f(A.data[i...])
end
@propagate_inbounds function Base.getindex(A::AbstractMultiMappedArray{T,N},
i::Vararg{Int,N}) where {T,N}
A.f(_getindex(CartesianIndex(i), A.data...)...)
end
@propagate_inbounds function Base.setindex!(A::MappedArray{T,N},
val,
i::Vararg{Int,N}) where {T,N}
A.data[i...] = A.finv(convert(T, val)::T)
end
@propagate_inbounds function Base.setindex!(A::MultiMappedArray{T,N},
val,
i::Vararg{Int,N}) where {T,N}
vals = A.finv(convert(T, val)::T)
_setindex!(A.data, vals, i...)
return vals
end
@propagate_inbounds _getindex(i, A, As...) = (A[i], _getindex(i, As...)...)
_getindex(i) = ()
@propagate_inbounds function _setindex!(as::As, vals::Vs, inds::Vararg{Int,N}) where {As,Vs,N}
a1, atail = as[1], Base.tail(as)
v1, vtail = vals[1], Base.tail(vals)
a1[inds...] = v1
return _setindex!(atail, vtail, inds...)
end
_setindex!(as::Tuple{}, vals::Tuple{}, inds::Vararg{Int,N}) where N = nothing
function testvalue(data)
if !isempty(data)
first(data)
else
zero(eltype(data))
end::eltype(data)
end
## Display
function Base.showarg(io::IO, A::AbstractMappedArray{T,N}, toplevel=false) where {T,N}
print(io, "mappedarray(")
func_print(io, A.f, eltypes(A.data))
if isa(A, Union{MappedArray,MultiMappedArray})
print(io, ", ")
func_print(io, A.finv, Tuple{T})
end
if isa(A, AbstractMultiMappedArray)
for a in A.data
print(io, ", ")
Base.showarg(io, a, false)
end
else
print(io, ", ")
Base.showarg(io, A.data, false)
end
print(io, ')')
toplevel && print(io, " with eltype ", T)
end
function func_print(io, f, types)
ft = typeof(f)
mt = ft.name.mt
name = string(mt.name)
if startswith(name, '#')
# This is an anonymous function. See if it can be printed nicely
lwrds = code_lowered(f, types)
if length(lwrds) != 1
show(io, f)
return nothing
end
lwrd = lwrds[1]
c = lwrd.code
if length(c) == 2 && ((isa(c[2], Expr) && c[2].head === :return) || (isdefined(Core, :ReturnNode) && isa(c[2], Core.ReturnNode)))
# This is a single-line anonymous function, we should handle it
s = lwrd.slotnames[2:end]
if length(s) == 1
print(io, s[1], "->")
else
print(io, tuple(s...), "->")
end
c1 = string(c[1])
for i = 1:length(s)
c1 = replace(c1, "_"*string(i+1)=>string(s[i]))
end
print(io, c1)
else
show(io, f)
end
else
show(io, f)
end
end
eltypes(A::AbstractArray) = Tuple{eltype(A)}
@Base.pure eltypes(A::Tuple{Vararg{AbstractArray}}) = Tuple{(eltype.(A))...}
## Deprecations
@deprecate mappedarray(f_finv::Tuple{Any,Any}, args::AbstractArray...) mappedarray(f_finv[1], f_finv[2], args...)
end # module
| MappedArrays | https://github.com/JuliaArrays/MappedArrays.jl.git |
|
[
"MIT"
] | 0.4.2 | 2dab0221fe2b0f2cb6754eaa743cc266339f527e | code | 8078 | using MappedArrays
using Test
@test isempty(detect_ambiguities(MappedArrays, Base, Core))
using FixedPointNumbers, OffsetArrays, Colors
@testset "ReadonlyMappedArray" begin
a = [1,4,9,16]
s = view(a', 1:1, [1,2,4])
b = @inferred(mappedarray(sqrt, a))
@test parent(b) === a
@test eltype(b) == Float64
@test @inferred(getindex(b, 1)) == 1
@test b[2] == 2
@test b[3] == 3
@test b[4] == 4
if isdefined(Base, :CanonicalIndexError)
@test_throws CanonicalIndexError b[3] = 0
else
@test_throws ErrorException b[3] = 0
end
@test isa(eachindex(b), AbstractUnitRange)
b = mappedarray(sqrt, a')
@test isa(eachindex(b), AbstractUnitRange)
b = mappedarray(sqrt, s)
@test isa(eachindex(b), CartesianIndices)
end
@testset "MappedArray" begin
intsym = Int == Int64 ? :Int64 : :Int32
a = [1,4,9,16]
s = view(a', 1:1, [1,2,4])
c = @inferred(mappedarray(sqrt, x->x*x, a))
@test parent(c) === a
@test @inferred(getindex(c, 1)) == 1
@test c[2] == 2
@test c[3] == 3
@test c[4] == 4
c[3] = 2
@test a[3] == 4
@test_throws InexactError(intsym, Int, 2.2^2) c[3] = 2.2 # because the backing array is Array{Int}
@test isa(eachindex(c), AbstractUnitRange)
b = @inferred(mappedarray(sqrt, a'))
@test isa(eachindex(b), AbstractUnitRange)
c = @inferred(mappedarray(sqrt, x->x*x, s))
@test isa(eachindex(c), CartesianIndices)
sb = similar(b)
@test isa(sb, Array{Float64})
@test size(sb) == size(b)
a = [0x01 0x03; 0x02 0x04]
b = @inferred(mappedarray(y->N0f8(y,0), x->x.i, a))
for i = 1:4
@test b[i] == N0f8(i/255)
end
b[2,1] = 10/255
@test a[2,1] == 0x0a
end
@testset "of_eltype" begin
a = [0.1 0.3; 0.2 0.4]
b = @inferred(of_eltype(N0f8, a))
@test b[1,1] === N0f8(0.1)
b = @inferred(of_eltype(zero(N0f8), a))
@test b[1,1] === N0f8(0.1)
b[2,1] = N0f8(0.5)
@test a[2,1] == N0f8(0.5)
@test !(b === a)
b = @inferred(of_eltype(Float64, a))
@test b === a
b = @inferred(of_eltype(0.0, a))
@test b === a
end
@testset "OffsetArrays" begin
a = OffsetArray(randn(5), -2:2)
aabs = mappedarray(abs, a)
@test axes(aabs) == (-2:2,)
for i = -2:2
@test aabs[i] == abs(a[i])
end
end
@testset "No zero(::T)" begin
astr = @inferred(mappedarray(length, ["abc", "onetwothree"]))
@test eltype(astr) == Int
@test astr == [3, 11]
a = @inferred(mappedarray(x->x+0.5, Int[]))
@test eltype(a) == Float64
# typestable string
astr = @inferred(mappedarray(uppercase, ["abc", "def"]))
@test eltype(astr) == String
@test astr == ["ABC","DEF"]
end
@testset "ReadOnlyMultiMappedArray" begin
a = reshape(1:6, 2, 3)
# @test @inferred(axes(a)) == (Base.OneTo(2), Base.OneTo(3))
b = fill(10.0f0, 2, 3)
M = @inferred(mappedarray(+, a, b))
@test @inferred(eltype(M)) == Float32
@test @inferred(IndexStyle(M)) == IndexLinear()
@test @inferred(IndexStyle(typeof(M))) == IndexLinear()
@test @inferred(size(M)) === size(a)
@test @inferred(axes(M)) === axes(a)
@test M == a + b
@test @inferred(M[1]) === 11.0f0
@test @inferred(M[CartesianIndex(1, 1)]) === 11.0f0
c = view(reshape(1:9, 3, 3), 1:2, :)
M = @inferred(mappedarray(+, c, b))
@test @inferred(eltype(M)) == Float32
@test @inferred(IndexStyle(M)) == IndexCartesian()
@test @inferred(IndexStyle(typeof(M))) == IndexCartesian()
@test @inferred(axes(M)) === axes(c)
@test M == c + b
@test @inferred(M[1]) === 11.0f0
@test @inferred(M[CartesianIndex(1, 1)]) === 11.0f0
end
@testset "MultiMappedArray" begin
intsym = Int == Int64 ? :Int64 : :Int32
a = [0.1 0.2; 0.3 0.4]
b = N0f8[0.6 0.5; 0.4 0.3]
c = [0 1; 0 1]
f = RGB{N0f8}
finv = c->(red(c), green(c), blue(c))
M = @inferred(mappedarray(f, finv, a, b, c))
@test @inferred(eltype(M)) == RGB{N0f8}
@test @inferred(IndexStyle(M)) == IndexLinear()
@test @inferred(IndexStyle(typeof(M))) == IndexLinear()
@test @inferred(size(M)) === size(a)
@test @inferred(axes(M)) === axes(a)
@test M[1,1] === RGB{N0f8}(0.1, 0.6, 0)
@test M[2,1] === RGB{N0f8}(0.3, 0.4, 0)
@test M[1,2] === RGB{N0f8}(0.2, 0.5, 1)
@test M[2,2] === RGB{N0f8}(0.4, 0.3, 1)
M[1,2] = RGB(0.25, 0.35, 0)
@test M[1,2] === RGB{N0f8}(0.25, 0.35, 0)
@test a[1,2] == N0f8(0.25)
@test b[1,2] == N0f8(0.35)
@test c[1,2] == 0
try
M[1,2] = RGB(0.25, 0.35, 0.45)
catch err
# Can't use `@test_throws` because is differs by FPN version, and we support multiple versions
@test err == InexactError(intsym, Int, N0f8(0.45)) || err == InexactError(:Integer, N0f8, N0f8(0.45))
end
R = reinterpret(N0f8, M)
@test R == N0f8[0.1 0.25; 0.6 0.35; 0 0; 0.3 0.4; 0.4 0.3; 0 1]
R[2,1] = 0.8
@test b[1,1] === N0f8(0.8)
a = view(reshape(0.1:0.1:0.6, 3, 2), 1:2, 1:2)
M = @inferred(mappedarray(f, finv, a, b, c))
@test @inferred(eltype(M)) == RGB{N0f8}
@test @inferred(IndexStyle(M)) == IndexCartesian()
@test @inferred(IndexStyle(typeof(M))) == IndexCartesian()
@test @inferred(axes(M)) === axes(a)
@test M[1,1] === RGB{N0f8}(0.1, 0.8, 0)
@test_throws ErrorException("indexed assignment fails for a reshaped range; consider calling collect") M[1,2] = RGB(0.25, 0.35, 0)
a = reshape(0.1:0.1:0.6, 3, 2)
@test_throws DimensionMismatch mappedarray(f, finv, a, b, c)
end
@testset "Display" begin
a = [1,2,3,4]
b = mappedarray(sqrt, a)
@test summary(b) == "4-element mappedarray(sqrt, ::$(Vector{Int})) with eltype Float64"
c = mappedarray(sqrt, x->x*x, a)
@test summary(c) == "4-element mappedarray(sqrt, x->x * x, ::$(Vector{Int})) with eltype Float64"
# issue #26
M = @inferred mappedarray((x1,x2)->x1+x2, a, a)
io = IOBuffer()
show(io, MIME("text/plain"), M)
str = String(take!(io))
@test occursin("x1 + x2", str)
end
@testset "eltype (issue #32)" begin
# Tests fix for
# https://github.com/JuliaArrays/MappedArrays.jl/issues/32#issuecomment-682985419
T = Union{Missing, Float32}
@test eltype(of_eltype(T, [missing, 3])) == T
@test eltype(of_eltype(T, [3, missing])) == T
@test eltype(of_eltype(Union{Missing, Float64}, [1, 2])) == Float64
@test eltype(mappedarray(identity, [1, missing])) == Union{Missing, Int}
@test eltype(mappedarray(identity, [missing, 1])) == Union{Missing, Int}
# ReadonlyMappedArray and MappedArray
_zero(x) = x === missing ? missing :
x > 0 ? x : 0
@test eltype(mappedarray(_zero, [1, 1.0])) == Union{Float64,Int}
@test eltype(mappedarray(_zero, [1.0, 1])) == Union{Float64,Int}
@test eltype(mappedarray(_zero, [1, 1])) == Int
@test eltype(mappedarray(_zero, identity, [1, 1.0])) == Union{Float64,Int}
@test eltype(mappedarray(_zero, identity, [1.0, 1])) == Union{Float64,Int}
@test eltype(mappedarray(_zero, identity, [1, 1])) == Int
# MultiMappedArray and ReadonlyMultiMappedArray
_sum(x, y) = _zero(x) + _zero(y)
inferred_type = Union{Missing, Float64, Int64}
@test eltype(mappedarray(_sum, [1, 1.0], [1.0, missing])) == inferred_type
@test eltype(mappedarray(_sum, [1, 1], [2, 2])) == Int
@test eltype(mappedarray(_sum, identity, [1, 1.0], [1.0, missing])) == inferred_type
@test eltype(mappedarray(_sum, identity, [1, 1], [2, 2])) == Int
_maybe_int(x) = x > 0 ? x : Int(x)
@test eltype(mappedarray(_maybe_int, Float64, [1.0, 1, -1, -1.0])) == Union{Float64, Int64}
@test eltype(mappedarray(_maybe_int, Float64, [1.0, -1.0])) == Union{Float64, Int64}
@test eltype(mappedarray(_maybe_int, Float64, [1, -1])) == Int64
@test eltype(mappedarray(Float64, _maybe_int, [1.0, 1, -1, -1.0])) == Float64
@test eltype(mappedarray(Float64, _maybe_int, [1, -1])) == Float64
X = rand(Lab{Float32}, 4, 4)
@test eltype(of_eltype(RGB{Float32}, X)) == RGB{Float32}
X = Any[1, 2, 3]
@test eltype(of_eltype(Int, X)) == Int
end
| MappedArrays | https://github.com/JuliaArrays/MappedArrays.jl.git |
|
[
"MIT"
] | 0.4.2 | 2dab0221fe2b0f2cb6754eaa743cc266339f527e | docs | 5784 | # MappedArrays
[](https://github.com/JuliaArrays/MappedArrays.jl/actions?query=workflow%3ACI)
[](http://codecov.io/github/JuliaArrays/MappedArrays.jl?branch=master)
This package implements "lazy" in-place elementwise transformations of
arrays for the Julia programming language. Explicitly, it provides a
"view" `M` of an array `A` so that `M[i] = f(A[i])` for a specified
(but arbitrary) function `f`, without ever having to compute `M`
explicitly (in the sense of allocating storage for `M`). The name of
the package comes from the fact that `M == map(f, A)`.
## Usage
### Single source arrays
```jl
julia> using MappedArrays
julia> a = [1,4,9,16]
4-element Array{Int64,1}:
1
4
9
16
julia> b = mappedarray(sqrt, a)
4-element mappedarray(sqrt, ::Array{Int64,1}) with eltype Float64:
1.0
2.0
3.0
4.0
julia> b[3]
3.0
```
Note that you can't set values in the array:
```jl
julia> b[3] = 2
ERROR: setindex! not defined for ReadonlyMappedArray{Float64,1,Array{Int64,1},typeof(sqrt)}
Stacktrace:
[1] error(::String, ::Type) at ./error.jl:42
[2] error_if_canonical_setindex at ./abstractarray.jl:1005 [inlined]
[3] setindex!(::ReadonlyMappedArray{Float64,1,Array{Int64,1},typeof(sqrt)}, ::Int64, ::Int64) at ./abstractarray.jl:996
[4] top-level scope at none:0
```
**unless** you also supply the inverse function, using `mappedarray(f, finv, A)`:
```
julia> c = mappedarray(sqrt, x->x*x, a)
4-element mappedarray(sqrt, x->x * x, ::Array{Int64,1}) with eltype Float64:
1.0
2.0
3.0
4.0
julia> c[3]
3.0
julia> c[3] = 2
2
julia> a
4-element Array{Int64,1}:
1
4
4
16
```
Naturally, the "backing" array `a` has to be able to represent any value that you set:
```jl
julia> c[3] = 2.2
ERROR: InexactError: Int64(Int64, 4.840000000000001)
Stacktrace:
[1] Type at ./float.jl:692 [inlined]
[2] convert at ./number.jl:7 [inlined]
[3] setindex! at ./array.jl:743 [inlined]
[4] setindex!(::MappedArray{Float64,1,Array{Int64,1},typeof(sqrt),getfield(Main, Symbol("##5#6"))}, ::Float64, ::Int64) at /home/tim/.julia/dev/MappedArrays/src/MappedArrays.jl:173
[5] top-level scope at none:0
```
because `2.2^2 = 4.84` is not representable as an `Int`. In contrast,
```jl
julia> a = [1.0, 4.0, 9.0, 16.0]
4-element Array{Float64,1}:
1.0
4.0
9.0
16.0
julia> c = mappedarray(sqrt, x->x*x, a)
4-element mappedarray(sqrt, x->x * x, ::Array{Float64,1}) with eltype Float64:
1.0
2.0
3.0
4.0
julia> c[3] = 2.2
2.2
julia> a
4-element Array{Float64,1}:
1.0
4.0
4.840000000000001
16.0
```
works without trouble.
So far our examples have all been one-dimensional, but this package
also supports arbitrary-dimensional arrays:
```jl
julia> a = randn(3,5,2)
3×5×2 Array{Float64,3}:
[:, :, 1] =
1.47716 0.323915 0.448389 -0.56426 2.67922
-0.255123 -0.752548 -0.41303 0.306604 1.5196
0.154179 0.425001 -1.95575 -0.982299 0.145111
[:, :, 2] =
-0.799232 -0.301813 -0.457817 -0.115742 -1.22948
-0.486558 -1.27959 -1.59661 1.05867 2.06828
-0.315976 -0.188828 -0.567672 0.405086 1.06983
julia> b = mappedarray(abs, a)
3×5×2 mappedarray(abs, ::Array{Float64,3}) with eltype Float64:
[:, :, 1] =
1.47716 0.323915 0.448389 0.56426 2.67922
0.255123 0.752548 0.41303 0.306604 1.5196
0.154179 0.425001 1.95575 0.982299 0.145111
[:, :, 2] =
0.799232 0.301813 0.457817 0.115742 1.22948
0.486558 1.27959 1.59661 1.05867 2.06828
0.315976 0.188828 0.567672 0.405086 1.06983
```
### Multiple source arrays
Just as `map(f, a, b)` can take multiple containers `a` and `b`, `mappedarray` can too:
```julia
julia> a = [0.1 0.2; 0.3 0.4]
2×2 Array{Float64,2}:
0.1 0.2
0.3 0.4
julia> b = [1 2; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> c = mappedarray(+, a, b)
2×2 mappedarray(+, ::Array{Float64,2}, ::Array{Int64,2}) with eltype Float64:
1.1 2.2
3.3 4.4
```
In some cases you can also supply an inverse function, which should return a tuple (one value for each input array):
```julia
julia> using ColorTypes
julia> redchan = [0.1 0.2; 0.3 0.4];
julia> greenchan = [0.8 0.75; 0.7 0.65];
julia> bluechan = [0 1; 0 1];
julia> m = mappedarray(RGB{Float64}, c->(red(c), green(c), blue(c)), redchan, greenchan, bluechan)
2×2 mappedarray(RGB{Float64}, getfield(Main, Symbol("##11#12"))(), ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Int64,2}) with eltype RGB{Float64}:
RGB{Float64}(0.1,0.8,0.0) RGB{Float64}(0.2,0.75,1.0)
RGB{Float64}(0.3,0.7,0.0) RGB{Float64}(0.4,0.65,1.0)
julia> m[1,2] = RGB(0,0,0)
RGB{N0f8}(0.0,0.0,0.0)
julia> redchan
2×2 Array{Float64,2}:
0.1 0.0
0.3 0.4
```
Note that in some cases the function or inverse-function is too
complicated to print nicely in the summary line.
### of_eltype
This package defines a convenience method, `of_eltype`, which
"lazily-converts" arrays to a specific `eltype`. (It works simply by
defining `convert` functions for both `f` and `finv`.)
Using `of_eltype` you can "convert" a series of arrays to a chosen element type:
```julia
julia> arrays = (rand(2,2), rand(Int,2,2), [0x01 0x03; 0x02 0x04])
([0.984799 0.871579; 0.106783 0.0619827], [-6481735407318330164 5092084295348224098; -6063116549749853620 -8721118838052351006], UInt8[0x01 0x03; 0x02 0x04])
julia> arraysT = map(A->of_eltype(Float64, A), arrays)
([0.984799 0.871579; 0.106783 0.0619827], [-6.48174e18 5.09208e18; -6.06312e18 -8.72112e18], [1.0 3.0; 2.0 4.0])
```
This construct is inferrable (type-stable), so it can be a useful
means to "coerce" arrays to a common type. This can sometimes solve
type-stability problems without requiring that one copy the data.
| MappedArrays | https://github.com/JuliaArrays/MappedArrays.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | code | 336 | push!(LOAD_PATH, "../src/", "../test/src/")
DOCUMENTER_DEBUG=true
using Documenter, PartialSvdStoch
makedocs(
format = Documenter.HTML(prettyurls = false),
sitename = "PartialSvdStoch",
pages = Any[
"Introduction" => "INTRO.md",
"PartialSvdStoch.jl " => "index.md",
"Tests" => "Test.md"
]
)
| PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | code | 522 | module PartialSvdStoch
using Match
using Logging
using Base.CoreLogging
using Printf
using LinearAlgebra
using LowRankApprox
using Base.CoreLogging
using Statistics
debug_log = stdout
logger = ConsoleLogger(stdout, CoreLogging.Info)
global_logger(logger)
export VrPCA,
SvdMode,
LowRankApproxMc,
reduceToRank,
reduceToEpsil,
iterateVrPCA,
getindex,
getResidualError,
SvdApprox,
isConverged
include("vrpca.jl")
include("lowRankApproxMc.jl")
end | PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | code | 14828 | using LinearAlgebra
"""
# enum SvdMode
. leftsv means that alogrithm operates on columns of data
passed in LowRankApproxMc and thus giving
a orthonormal basis of left singular vector.
. rightsv means that algorithm stores the transpose of data passed
in LowRankApproxMc and thus runs on row of original data , thus giving
a orthonormal basis of right singular vector.
"""
@enum SvdMode begin
leftsv
rightsv
end
"""
# LowRankApproxMc structure
as described in:
1. Vempala Spectral Book (2009)
paragraph on Iterative Fast Svd P 85 and Th 7.2 7.3
2. Lectures in Randomized Linear Algebra. Mahoney 2016 P121 and seq.
Cf also Deshpande Rademacher Vempala Wang
Matrix Approximation and Projective Clustering via Volume Sampling 2006
For a data matrix X(d,n) compute a orthogonal set of left singular vectors in a matrix W(rank, n)
Right singular vector are computed as W'*X.
FIELDS
------
- X : the (d,n) matrix we want to reduce.
- targetRank : the rank of the data matrix we want to extract
- currentRank : the rank reached at current iteration
- U : Union{ Some{Matrix{Float64}}, Nothing} the matrix of left singular vectors if any
- S : Union{ Some{Vector{Float64}}, Nothing} the vecor of singular values if any
- Vt: Union{ Some{Matrix{Float64}}, Nothing} the transposed matrix of right singular vectors if any
CONSTRUCTORS
-----------
1. `function LowRankApproxMc(data::Matrix{Float64}, targetRank::Int64)`
initialize structure and rank of the approximation
"""
mutable struct LowRankApproxMc
X::Matrix{Float64}
#
leftOrRight::SvdMode
# rank we want in output
targetRank::Int64
targetEpsil::Float64
# number of column sampling in a pass
samplingSize::Int64
#
currentRank::Int64
# store relative error
residualErr::Float64
#
currentIter::Int64
U::Union{ Some{Matrix{Float64}}, Nothing}
S::Union{ Some{Vector{Float64}}, Nothing}
Vt::Union{ Some{Matrix{Float64}}, Nothing}
#
function LowRankApproxMc(data::Matrix{Float64}; mode = leftsv)
if mode == leftsv
@info "LowRankApproxMc in left singular vector mode"
new(data, mode, 0, 1. , 0, 0, 1. , 0,
nothing, nothing, nothing)
else
@info "LowRankApproxMc in right singular vector mode, transposing data"
new(transpose(data), mode, 0, 1. , 0, 0, 1. , 0,
nothing, nothing, nothing)
end
end
end
#
# The data matrix are supposed to be stored in columns of length data dimension.
# We operate on columns so we ouptut Left singular vectors.
# So our implementation conforms to Mahoney "Lecture Notes on Randomized Algebra"
# paragraph 15.4 Th 21 as opposed to Kannan-Vempala "Spectral Algorithms"
# which operates on rows and output right singular vectors.
#
function reduceIfast(datapb::LowRankApproxMc, stop::Function)
@debug "in LowRankApproxMc reduceIfast v2"
epsil = 1.E-5
d,n = size(datapb.X)
datapb.currentIter = 1
datapb.currentRank = 0
E = Matrix(datapb.X)
acceptanceRatio = 1.
normX = norm(E,2)
residualAtIter= Vector{Float64}()
meanL2NormC = sqrt(normX * normX / n)
@debug "meanL2NormC" meanL2NormC
# We could use c as in Deshpande Vempala and let c decrease with iterations
# to accelerate ?
probaC = Vector{Float64}(undef,n)
normC = Vector{Float64}(undef,n)
A = Matrix{Float64}(undef, d, 0)
more = true
while more
@debug "\n\n iteration " datapb.currentIter
# sampled columns at this iter
tSet = Set{Int64}()
keptIdxNonZero = Vector{Int64}()
# sample columns according to L2-norm of each columns
normE = 0
Threads.@threads for i = 1:n
normC[i] = norm(E[:,i]) * norm(E[:,i])
end
for i = 1:n
probaC[i] = i > 1 ? probaC[i-1] + normC[i] : normC[i]
normE += normC[i]
end
if probaC[end] <= 0
@debug "\n non positive proba for last slot= : " probaC[end]
error("cannot sample column")
end
map!(x -> x/probaC[end], probaC, probaC)
# get minimum non null column norm at iter t
meanL2NormIter = mean(sqrt.(normC))
@debug "\n c meanL2Norm at Iter : " meanL2NormIter
for j = 1:datapb.samplingSize
xsi = rand(Float64)
s = searchsortedfirst(probaC, xsi)
if s > length(probaC)
@warn "\n sampling column failed xsi = : " xsi
exit(1)
end
# avoid selecting some already sampled column or already a
if !(s in tSet)
push!(tSet, s)
end
end
acceptanceRatio = length(tSet)/datapb.samplingSize
@debug "acceptanceRatio" acceptanceRatio
# get index of selected columns
idxc = collect(tSet)
At = datapb.X[:, idxc]
# orthogonalize ... with preceding columns in A. Compute transpose(At)*A
AttA = BLAS.gemm('T', 'N', At, A)
Threads.@threads for i = 1:length(idxc)
# with preceding columns in A. At[:,i] not normalized, A[:,j] is
@simd for j = 1:size(A)[2]
At[:,i] = At[:,i] - A[:,j] * AttA[i,j]
end
end
@debug "QR orthogonalizing new block size At" size(At)
At,tau = LAPACK.geqrf!(At)
Q=LAPACK.orgqr!(At, tau, length(tau))
for i = 1:size(Q)[2]
# within this block of columns in A.
normi = norm(Q[:,i])
# how much remains of At[:,i]. Should check with initial norm of column i
if abs(normi - 1.) < 1.E-5
push!(keptIdxNonZero, i)
# @debug "adding a column vector of norm" normi idxc[i]
A = hcat(A, Q[:,i])
if size(A)[2] >= min(d,n)
@debug "max dim reached"
more = false
break
end
else
@debug "column not normalized" normi
end
end
@info "A size" size(A)
#
datapb.currentRank = size(A)[2]
# stopping criteria
if stop(datapb)
more = false
else
@debug "updating E"
if length(keptIdxNonZero) < length(idxc)
E = E - At[:, keptIdxNonZero] * BLAS.gemm('T', 'N', At[:, keptIdxNonZero], datapb.X)
else
E = E - At * BLAS.gemm('T', 'N', At, datapb.X)
end
datapb.residualErr = norm(E,2)/normX
push!(residualAtIter, datapb.residualErr)
# protection against stationarity
if datapb.currentIter > 3 && residualAtIter[end] > 0.95 * residualAtIter[end-1]
@warn "stationary iterations , stopping. perhaps increase rank"
more = false
end
@info " iteration , ||E|| set size " datapb.currentIter datapb.residualErr datapb.currentRank
# if in reduceToEpsil mode we have to test now that we have datapb.residualErr
if stop(datapb)
more = false
else
datapb.currentIter += 1
end
end
end
# go from left singular to right singular vectors
#
@debug "computing right vectors"
Vt = Matrix{Float64}(undef, size(A)[2], n)
BLAS.gemm!('T', 'N', 1., A, datapb.X, 0., Vt)
eigenValues = zeros(size(A)[2])
Threads.@threads for i in 1:size(A)[2]
eigenValues[i] = norm(Vt[i,:])
Vt[i,:] = Vt[i,:] / eigenValues[i]
end
@debug "exiting LowRankApproxMc reduceIfast"
datapb.U = Some(A)
datapb.S = Some(eigenValues)
datapb.Vt = Some(Vt)
end
"""
# function getResidualError(lrmc::LowRankApproxMc)
if X is the data matrix and U computation succeeded
return the 2-uple (error, relerr) with :
```math
error = norm(X - U * transpose(U) * X)
```
and :
```math
relerr = Error/norm(X)
```
else throws an error
"""
function getResidualError(lrmc::LowRankApproxMc)
U = something(lrmc.U)
resErr = norm(lrmc.X - U* BLAS.gemm('T', 'N', U, lrmc.X))
return resErr , resErr/norm(lrmc.X)
end
"""
# function getindex(LowRankApproxMc, Symbol)
returns U,S,Vt,V or rank according to Symbol :S , :U, :Vt , V or :k
"""
function getindex(datapb::LowRankApproxMc, d::Symbol)
@match d begin
:S => datapb.S
:U => datapb.U
:V => datapb.Vt'
:Vt => datapb.Vt
:k => length(datapb.S)
_ => throw(KeyError(d))
end
end
"""
# function reduceToRank(datapb::LowRankApproxMc, expectedRank::Int64; nbiter = 2)
Implements incremental range approximation as described in
1: Vempala Spectral Book (2009)
paragraph on Iterative Fast Svd P 85 and Th 7.2 7.3.
## Args
- expectedRank asked for.
It must be noted that the returned rank can be different
from expectedRank, especially if some columns are dominant in the data matrix. In this case
The sampling size used to select colmuns is set to ``\\frac{expectedRank}{nbiter}``
- number of iterations. Default to 2. Can be set to 1 ito get get
a faster result at the expense of precision.
## Output
The function does not return any output, instead it fills the fields U, S, Vt of the structure LowRankApproxMc.
The fields can be retrieved by the function getIndex.
If the rank extracted from the algorithm extractedRank we get as output :
- U: a (d,extractedRank) matrix of orthonormalized left singular vector
- S : a vector of singular values up to extractedRank
- Vt : a (extractedRank , n) matrix , transposed of right singular vector.
Nota the vector are not orthonormal.
The svd approximation of data is:
`` B = U * S * transpose(V) ``
and verifies:
`` E(|| data - B||^{2}) <= 1/(1-\\epsilon) * E(|| data - A_{k}|| ^{2}) + \\epsilon^{t} E(|| data ||^{2}) ``
where ``A_{k}`` is the L2 best rank k approximation of data.
B is of the form U * transpose(U) * data with U orthogonal made of left singular vectors.
To get the corresponding result with right singular vector use a transpose Matrix as input.
## NOTA:
**The Singular values are NOT sorted**
"""
function reduceToRank(datapb::LowRankApproxMc, rank::Int64; nbiter = 2)
if rank > size(datapb.X)[1]
error("reduceToRank reduction to rank greater than dimension")
end
maxdim = size(datapb.X)[2]
datapb.currentIter = 1
datapb.targetRank = rank
# reset Epsil target in case of successive calls
datapb.targetEpsil = 1.
# we have rank target, 2 iterations should do
if nbiter > 1
datapb.samplingSize = floor(Int64,(1.05 * rank /nbiter))
datapb.samplingSize = min(size(datapb.X)[2], datapb.samplingSize)
@debug "LowRankApproxMc.reduceToRank setting samplingSize: " datapb.samplingSize
maxiter = min(nbiter, 5)
@warn "LowRankApproxMc.reduceToRank using maxiter " maxiter
fstop2(datapb) = datapb.currentIter >= maxiter || datapb.currentRank >= datapb.targetRank ? true : false
reduceIfast(datapb, fstop2)
else
# only one iter
maxiter = 1
datapb.samplingSize = floor(Int64,(1.10 * rank /nbiter))
datapb.samplingSize = min(size(datapb.X)[2], datapb.samplingSize)
@debug "LowRankApproxMc.reduceToRank setting samplingSize: " datapb.samplingSize
fstop1(datapb) = datapb.currentIter >= maxiter ? true : false
reduceIfast(datapb, fstop1)
end
# check we got rank
if isnothing(datapb.U)
@warn "reduceToRank got not get left singular vectors"
elseif size(datapb.U.value)[2] < rank
@warn "reduceToRank got only up to rank" size(datapb.U.value)[2]
end
# return rank approx
end
"""
# function reduceToEpsil(datapb::LowRankApproxMc, samplingSize::Int64, epsil::Float64;maxiter = 5)
This function computes an approximate svd up to a precision epsil.
It computes U, S and Vt so that the matrix B = U*S*Vt verifies :
`` E(|| data - B||_{2}) / E(|| data ||_{2}) <= epsil ``
It iterates until either the precision asked for is reached or *maxiter* iterations are done
or rank reached is maximal.
## Args
------
- samplingSize: the number of columns tentatively sampled by iteration.
- epsil : precision asked for. It is clear that a very small epsil will cause a full to be done
with the corresponding costs. In this case possibly, a call to LAPACK.svd will be better.
- maxiter : the maximum number of iterations. default to 5
## Output:
The function does not return any output, instead it fills the fields U, S, Vt of the structure LowRankApproxMc.
The fields can be retrieved by the function getIndex.
If the rank extracted from the algorithm extractedRank we get as output :
- U: a (d,extractedRank) matrix of orthonormalized left singular vector
- S : a vector of singular values up to extractedRank
- Vt : a (extractedRank , n) matrix , transposed of right singular vector.
Nota the vector are not orthonormal.
The svd approximation of data is: `` B = U * S * transpose(V) ``
and verifies:
`` E(|| data - B||^{2}) <= 1/(1-\\epsilon) * E(|| data - A_{k}|| ^{2}) + \\epsilon^{t} E(|| data ||^{2}) ``
where ``A_{k}`` is the L2 rank k approximation of data.
B is of the form U * transpose(U) * data with U orthogonal made of left singular vectors.
## NOTA:
**The Singular values are NOT sorted**
"""
function reduceToEpsil(datapb::LowRankApproxMc, samplingSize::Int64, epsil::Float64; maxiter = 5)
datapb.targetEpsil = epsil
# reset targetRank in case of successive calls
# rank is set to full dimension
datapb.targetRank = min(size(datapb.X)[1], size(datapb.X)[2])
if samplingSize <= 0
throw("non strict positive samplingSize")
end
samplingSize = min(size(datapb.X)[2], samplingSize)
datapb.samplingSize = samplingSize
# epsil target
# avoid doing one more iteration just for 1% of epsil
fstop(datapb) = datapb.currentIter >= maxiter || datapb.residualErr <= epsil*(1.01) ||
datapb.currentRank >= datapb.targetRank ? true : false
reduceIfast(datapb, fstop)
end
# the following is faster as we do not ask for Vt
function getRangeApprox(data::Matrix{Float64}, rank::Int64)
@debug " in getRangeApprox"
svdpb = LowRankApproxMc(data)
reduceToRank(svdpb, rank)
U = something(svdpb.U)
@debug "reduceToRank returned size" size(U)
# compute all U columns and 0 columns of Vt
U,S,Vt = LAPACK.gesvd!('A', 'O', U)
@debug "lapack returned size U,S,Vt" size(U) size(S) size(Vt)
# return first k columns of U and first k values of diagonal of S
U[:, (1:rank)],S[1:rank]
end
| PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | code | 11214 |
export VrPCA,
reduceToRank,
getindex,
SvdApprox,
isConverged
"""
# enum SvdApprox
. Lrapprox encodes for the initialization of vrpca with the LowRankApprox package
. Ifsvd encodes for the initialization of vrpca with incremental svd of Vempala-Kunnan
"""
@enum SvdApprox begin
lrapprox
ifsvd
end
"""
# VrPCA
returns an orthonormal matrix W with columns vectors the first
k left singular vectors spanning the range of X.
**k is supposed to be small compared to d**.
If X = U S Vt, the methode computes in W the matrix U[:, 1:k]
This structure gathers data to do stochastic svd as described in :
***Fast Stochastic Algorithms for SVD and PCA : convergences Properties and Convexity
Ohad Shamir 2015***
FIELDS
------
- X the (d,n) matrix we want to reduce.
- k the dimension into which we want to reducte the data Matrix
***Note : If the obtained rank is less than asked for value of k is reset!***
- W orthogonal (d,k) matrix
- eta step size
- m epoch length
- U : Union{ Some{Matrix{Float64}}, Nothing} the matrix of left singular vectors if any
- S : Union{ Some{Vector{Float64}}, Nothing} the vecor of singular values if any
- Vt: Union{ Some{Matrix{Float64}}, Nothing} the transposed matrix of right singular vectors if any
"""
mutable struct VrPCA
X::Matrix{Float64}
k::Int64
# orthogonal matrix (d,k)
W::Matrix{Float64}
converged::Bool
relerr::Float64
#
U::Union{ Some{Matrix{Float64}}, Nothing}
S::Union{ Some{Vector{Float64}}, Nothing}
Vt::Union{ Some{Matrix{Float64}}, Nothing}
end
"""
# function VrPCA(data::Matrix{Float64}, k::Int64)
This function initialize a VrPCA problem with the LowRankApprox package
## Args
. data : the data matrix with data vectors in column
. k : the rank we want as output
"""
function VrPCA(data::Matrix{Float64}, k::Int64)
@debug "VrPCA initialized by LowRankApprox and rank target"
# get an initial W0, we do not need very good precision
opts = LowRankApprox.LRAOptions(rank=k, rtol = 0.001)
# get W such that Mdata ~ W*W'*Mdata in Froebenius norm
W = prange(data, opts)
if size(W)[2] < k
@warn "VrPCA initialization got less than asked rank, got : " size(W)[2]
end
@debug "got rank " size(W)[2]
VrPCA(data, size(W)[2] , W, false, 1., nothing,nothing,nothing)
end
"""
# function VrPCA(data::Matrix{Float64}, epsil::Float64)
This function initialize a VrPCA problem with the LowRankApprox package
## Args
- data : the data matrix with data vectors in column
- epsil: the precision we ask at initialisation, the VrPCA iteration will further reduce error
when iterating with the rank obtained at initialization
"""
function VrPCA(data::Matrix{Float64}, epsil::Float64)
@debug "VrPCA initialized by Vempala's LowRankApproxMc and epsil target"
lrmc = LowRankApproxMc(data)
samplingSize = 100
reduceToEpsil(lrmc, samplingSize, epsil)
U = PartialSvdStoch.getindex(lrmc, :U)
if U === nothing
throw("initialization of VrPCA with epsil failed")
end
W = something(U)
@debug "initialization got rank " size(W)[2]
VrPCA(data, size(W)[2], W, false, 1. , nothing, nothing, nothing)
end
"""
# function iterateVrPCA(pcaPb::VrPCA, eta::Float64, m::Int64)
## Args
- eta : the gradient step. Should be sufficiently small to ensure inversibility of the (k,k) matrix
W*transpose(W) obtained during iterations on W(d,k)
- m : the batch size. Roughly inversely proportional to eta.
eta = 0.01 and m = 20 is a good compromises. m does not need to be large
as sampling is weighted by L2-norm of data column.
Output : The function does not return any output.
It fills the fields U, S, Vt of the structure VrPCA.
The fields can be retrieved by the function getIndex.
"""
function iterateVrPCA(pcaPb::VrPCA, eta::Float64, m::Int64)
@debug "entering VrPCA reduce eta m block version" eta m
small = 1.E-5
d,n = size(pcaPb.X)
k = pcaPb.k
# allocates once and for all 3 temproray matrices
Us = zeros(Float64, d, k) # is (d,k)
B_t = zeros(Float64, k, k) # Bt_1 is Wt*W so it is a (k,k) matrix
W_tmp = zeros(Float64, d, k)
pcaPb.converged = false
s = 1
W_s = pcaPb.W
W_t = pcaPb.W
deltaWIter = Vector{Float64}()
# get L2 proba per column
probaC = Vector{Float64}(undef,n)
normC = Vector{Float64}(undef,n)
normX = 0
Threads.@threads for i = 1:n
normC[i] = norm(pcaPb.X[:,i]) * norm(pcaPb.X[:,i])
end
for i = 1:n
probaC[i] = i > 1 ? probaC[i-1] + normC[i] : normC[i]
normX += normC[i]
end
if probaC[end] <= 0
@debug "\n non positive proba for last slot= : " probaC[end]
error("cannot sample column")
end
map!(x -> x/probaC[end], probaC, probaC)
#
@debug " W_s dim" size(W_s)
more = true
while more
fill!(Us,0.)
# split in block the update of Us to get speed from BLAS.gemm
blockSize = 1000
y = zeros(k, blockSize)
nbblocs = floor(Int64, n / blockSize)
for numbloc = 1:nbblocs
blocfirst = 1 + (numbloc -1) * blockSize
bloclast = min(blockSize * numbloc, n)
# get W_s' * pcaPb.X[:,i] in y
BLAS.gemm!('T', 'N', 1., W_s , pcaPb.X[:,blocfirst:bloclast], 0., y)
# Us = Us + pcaPb.X[:,i] * y' (= transpose(pcaPb.X[:,i]) * W_s)
for i in 1:blockSize
j = (numbloc - 1) * blockSize + i
BLAS.ger!(1.,pcaPb.X[:,j], y[:,i], Us)
end
# Us = Us + pcaPb.X[:,i] * (transpose(pcaPb.X[:,i]) * W_s)
end
# do not forget the residual part of block splitting!!
if n % blockSize > 0
y = zeros(k)
for i in 1 + nbblocs * blockSize:n
BLAS.gemm!('T', 'N', 1., W_s , pcaPb.X[:,i], 0., y)
BLAS.ger!(1.,pcaPb.X[:,i], y, Us)
end
end
Us = Us / n
# stochastic update pass
# we need to store Wt W_{s-1} (Ws1 in the code) W_{t-1} (Wt in the code)
for t = 1:m
# compute in place to avoid allocator transpose(W_{t_1}) * W_{s-1}, B_t is (k,k)
BLAS.gemm!('T', 'N', 1., W_t, W_s, 0., B_t)
# compute svd of transpose(W_{t_1}) * W_{s-1} i.e do a svd of a (k,k) matrix
U,S,Vt = LAPACK.gesvd!('A', 'A', B_t)
# compute B_t as V*Ut
BLAS.gemm!('T', 'T', 1., Vt, U, 0., B_t)
#
# biased sampling instead of it = rand(1:n)
xsi = rand(Float64)
it = searchsortedfirst(probaC, xsi)
s_weight = 1. / (n * probaC[it])
# update Wt, vaux1 is (1,k)
vaux1 = transpose(pcaPb.X[:,it]) * W_t - (transpose(pcaPb.X[:,it]) * W_s) * B_t
# vaux2 is (d,k)
vaux2 = s_weight * pcaPb.X[:,it] * vaux1 + BLAS.gemm('N', 'N', Us, B_t)
# @debug "norm vaux2" norm(vaux2)
# W_s1 * B_t1 is (d,k), so W_t1 and W_s1. W_tmp _s (d,k)
W_tmp = W_t + eta * vaux2
#
# final update of W_t, compute sqrt(transpose(W_t1)*W_{t}), (k,k)
# in fact we want to orthonormalize U and Vt are (k,k)
U,S,Vt = LAPACK.gesvd!('A', 'A', transpose(W_tmp) * W_tmp)
# @debug "\n size U , Vt" size(U), size(Vt)
# check for null values of S
nbsmall = count( x -> x < small, S)
if nbsmall > 0
@debug "too small values " S
@warn "could not do W update, ||W|| " norm(W_tmp, 2)
end
map!(x -> 1/sqrt(x) , S, S)
# compute the inverse, BLAS.gemm does not seem to spped up things here
Wnorminv = transpose(Vt) * diagm(0 => S) * transpose(U)
# orthonormalize W. compute: W_t / sqrt(transpose(W_t)*W_t)
# @debug "\n size W_tmp Wnorminv" size(W_tmp) size(Wnorminv)
W_t = BLAS.gemm('N', 'N', W_tmp, Wnorminv)
# Cshould check W_t orthogonality : OK!
# @debug "\n W orthogonality check " norm(transpose(W_t) * W_t - Matrix{Float64}(I,k,k))
end
#
# convergence detection
normWt = norm(W_t) * norm(W_t)
deltaW = norm(W_t - W_s) * norm(W_t - W_s)
lastDeltaW = 0
if length(deltaWIter) > 0
lastDeltaW = deltaWIter[end]
end
push!(deltaWIter, deltaW)
@debug " iter , ||W_t - W_s||_2 , ||W_t||_2" s deltaW normWt
W_s = W_t
#
# do a convergence test
if normWt > 0 && deltaW/normWt < 1.E-3
pcaPb.W = W_t
pcaPb.relerr = deltaW/normWt
more = false
pcaPb.converged = true
else
if s >= 3
if deltaW >= 0.8 * lastDeltaW || deltaW <= 0.05 * deltaWIter[1]
@warn "\n reached stationarity s deltaW ||W|| , exiting : " s deltaW normWt
pcaPb.relerr = deltaW/normWt
pcaPb.W = W_t
pcaPb.converged = true
more = false
elseif s > 5
# we stop without setting pcaPb.converged...
@warn "\n stopping iteration" s deltaW normWt
pcaPb.relerr = deltaW/normWt
pcaPb.W = W_t
more = false
end
end
s = s+1
end
end # end of while
# now we have a converged matrix W (d,k) consisting in k left singular vectors
# compute singular values and right singular vectors
# = (k,d) * (d,n)
# Vt = transpose(W_t) * pcaPb.X
Vt = Matrix{Float64}(undef, k, n)
BLAS.gemm!('T', 'N', 1., W_t, pcaPb.X, 0., Vt)
S = map(i -> norm(Vt[i,:]), (1:size(Vt)[1]))
for i in 1:length(S)
Vt[i,:] /= S[i]
end
pcaPb.U = Some(W_t)
pcaPb.S = Some(S)
pcaPb.Vt = Some(Vt)
end
"""
# function getindex(VrPCA, Symbol)
returns U,S,Vt,V or rank according to Symbol :S , :U, :Vt , V or :k
"""
function getindex(pcaPb::VrPCA, d::Symbol)
@match d begin
:S => pcaPb.S
:U => pcaPb.U
:V => pcaPb.Vt'
:Vt => pcaPb.Vt
:k => length(pcaPb.S)
_ => throw(KeyError(d))
end
end
"""
# function getResidualError(vrpca::VrPCA)
if X is the data matrix and U computation succeeded
return the 2-uple (error, relerr) with:
```math
error = norm(X - U * transpose(U) * X)
```
and
```math
relerror = norm(X - U * transpose(U) * X)/norm(X)
```
else throws an error
"""
function getResidualError(vrpca::VrPCA)
U = something(vrpca.U)
resErr = norm(vrpca.X - U* BLAS.gemm('T', 'N', U, vrpca.X))
return resErr,resErr/norm(vrpca.X)
end
"""
# function isConverged(pcaPb::VrPCA)
return true if stationarity criteria were satisfied during iterations.
"""
function isConverged(pcaPb::VrPCA)
return pcaPb.converged
end | PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | code | 3195 | using Test, PartialSvdStoch, Serialization, Distributions
using Logging
using Base.CoreLogging
logger = ConsoleLogger(stdout, CoreLogging.Debug)
global_logger(logger)
include("testvrpca.jl")
include("testifsvd.jl")
# a data file for a matrix(11520, 22499) can be found in ./data/plimat.serialized
# mass spectrometry image
plimat = Some(Matrix{Float64})
dataf = "data/plimat.serialized"
if isfile(dataf)
plimat = Some(Serialization.deserialize(open(dataf, "r")))
end
# This test compares singular values from exact svd with those extracted from
# incremental svd from LowRankApproxMc
@testset "ifsvd_versus_svd" begin
@info "========================================================="
@info "\n\n in test ifsvd_versus_svd"
d = 500
n = 5000
k = 50
mat = rand(d,n)
for j in 1:k
mat[:,j] = mat[:,j] * 20.
end
for j in 1:5
mat[:,j+k] = mat[:,j+k] * 100.
end
@test testifastsvd_S(mat, 200)
end
# This test shows how in presence high variability of data
# it is possible to get a competitive approximation with incremental svd.
@testset "ifsvd_lowRankApproxEpsil" begin
@info "========================================================="
@info "\n\n in test ifsvd_lowRankApproxEpsil"
d = 10000
n = 20000
mat = zeros(d,n)
#
Xlaw = Normal(0, 1000.)
# multiply some columns
blocsize = 100
for bloc in 1:round(Int,n/blocsize)
val = abs(rand(Xlaw))
for i in 1:d
if rand() < 0.01
for j in 1:blocsize
mat[i,(bloc-1)*blocsize+j] = val * (1. - rand()/10.)
end
end
end
end
@test testifastsvd_epsil(mat, 100, 0.05)
end
#
# test vrpca_epsil
# This tests asks for an approx at 0.01
# It extracts a rank 100 matrix at 0.005 precision within 3s (after first compilation).
# With LowRankApprox.prange alone we need to go up to rank=500 (initialized with
# opts = LowRankApprox.LRAOptions(rank=500, rtol = 0.0001) to achieve a relative
# Froebonius error of 0.005. It then runs in 1.15s.
# So we see that LowRankApprox is really fast but needs many more singular vectors
# and that VrPCA gives a clear reduction of relative error.
# Of course VrPCA initialized with LowRankApprox would give an analogous reduction
# in relative error. Cf testset "vrpca_withLoxwRankApprox"
#
@testset "vrpca_epsil" begin
@info "========================================================="
@info "\n\n in test vrpca_epsil"
d = 5000
n = 10000
k = 100
maxval = 1000
mat = rand(d,n)
# multiply some columns
for i in 1:k
mat[:,i] = mat[:,i] * maxval
end
@test testvrpca_withepsil(mat, 0.01)
end
@testset "vrpca_withLowRankApprox" begin
@info "========================================================="
@info "\n\n in test vrpca_withLowRankApprox"
d = 5000
n = 10000
k = 100
maxval = 1000
mat = rand(d,n)
# multiply some columns. but do not sample them( some will be sampled twice and will affect sketching)
for i in 1:k
mat[:,i] = mat[:,i] * maxval
end
@test testvrpca_withLowRankApprox(mat, 100)
end | PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | code | 3081 | using PartialSvdStoch, LinearAlgebra, Test
# reduceToRank comparison with exact svd
# we check that the reconstructed matrix has nearly the same singular values
function testifastsvd_S(mat, rank)
@info "doing exact svd ..."
@time Uexact,Sexact,Vtexact = svd(mat)
#
#
svdpb = LowRankApproxMc(mat)
@time reduceToRank(svdpb, rank, nbiter = 2)
U = PartialSvdStoch.getindex(svdpb,:U)
S = PartialSvdStoch.getindex(svdpb,:S)
Vt = PartialSvdStoch.getindex(svdpb,:Vt)
rankReached = svdpb.currentRank
matApprox = U.value * diagm(S.value) * Vt.value
@info "relative residual error LowRankApproxMc " norm(matApprox - mat)/norm(mat)
# doing exact svd of matApprox
@time Urecons,Srecons,Vtrecons = svd(matApprox)
deltaRecons = norm(Srecons[1:rankReached]-Sexact[1:rankReached])
relerr = deltaRecons/norm(Sexact[1:rankReached])
@info "relative error on eigen values after reconstruction : " relerr
relerr < 0.1 ? true : false
end
# reduceToEpsil comparison with exact svd
function testifastsvd_epsil(mat)
@debug "doing exact svd ..."
@time Uexact,Sexact,Vtexact = svd(mat)
#
@info "reducing to epsil " 0.1
svdpb = LowRankApproxMc(mat)
@time reduceToEpsil(svdpb, 50, 0.01)
U = PartialSvdStoch.getindex(svdpb,:U)
S = PartialSvdStoch.getindex(svdpb,:S)
Vt = PartialSvdStoch.getindex(svdpb,:Vt)
rankReached = svdpb.currentRank
deltaS = norm(S.value[1:rankReached]-Sexact[1:rankReached])/norm(Sexact[1:rankReached])
matApprox = U.value * diagm(S.value) * Vt.value
relerrMat = norm(matApprox - mat)/norm(mat)
@info "delta mat after LowRankApproxMc reduce" deltaS relerrMat
relerrMat < 0.05 ? true : false
end
# ifsvd and epsil iterations
function testifastsvd_epsil(mat, samplingSize, epsil)
#
@debug "doing LowRankApproxMc reduceToRank"
svdpb = LowRankApproxMc(mat)
@time reduceToEpsil(svdpb, samplingSize , epsil)
U = PartialSvdStoch.getindex(svdpb,:U)
S = PartialSvdStoch.getindex(svdpb,:S)
Vt = PartialSvdStoch.getindex(svdpb,:Vt)
rankReached = svdpb.currentRank
matApprox = U.value * BLAS.gemm('T','N', U.value, mat)
relerrMat = norm(matApprox - mat)/norm(mat)
@info "delta mat after LowRankApproxMc reduce" norm(matApprox - mat) norm(mat)
@info "relative residual error" norm(matApprox - mat)/norm(mat)
relerrMat < 0.05 ? true : false
end
# ifsvd and rank control
function testifastsvd_rank(mat, k)
#
@info "\n doing LowRankApproxMc reduceToRank"
svdpb = LowRankApproxMc(mat)
@time reduceToRank(svdpb, k)
U = PartialSvdStoch.getindex(svdpb,:U)
S = PartialSvdStoch.getindex(svdpb,:S)
Vt = PartialSvdStoch.getindex(svdpb,:Vt)
rankReached = svdpb.currentRank
matApprox = U.value * BLAS.gemm('T','N', U.value, mat)
relerrMat = norm(matApprox - mat)/norm(mat)
@info "delta mat after LowRankApproxMc reduce" norm(matApprox - mat) norm(mat)
@info "relative residual error" norm(matApprox - mat)/norm(mat)
relerrMat < 0.05 ? true : false
end | PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | code | 2126 | using PartialSvdStoch, Test
using LowRankApprox
function testvrpca_withLowRankApprox(mat, k)
#
normMat = norm(mat)
# get initial spectrum from psvd
opts = LRAOptions(rank=k, rtol=0.001)
@info "testvrpca_withLowRankApprox : initialization"
@time Uguess, Sguess, Vguess = psvd(mat,opts)
matGuess = Uguess * diagm(Sguess) * transpose(Vguess)
deltaMatGuess = norm(matGuess - mat)
@info "rank obtained : " size(Uguess)[2]
@info " residual Error , initial L2 norm " deltaMatGuess normMat
@info " relative error at initialization " deltaMatGuess/normMat
#
eta = 0.01
batchSize = 20
@info "doing vrpca svd with rank initialization..." eta batchSize
pcaPb = VrPCA(mat, k)
@time iterateVrPCA(pcaPb, eta, batchSize)
U = PartialSvdStoch.getindex(pcaPb,:U)
S = PartialSvdStoch.getindex(pcaPb,:S)
Vt = PartialSvdStoch.getindex(pcaPb,:Vt)
# it happens that the obtained rank is less than asked for
obtainedRank = pcaPb.k
matVrpca = U.value * diagm(S.value) * Vt.value
deltaMatIter = norm(matVrpca - mat)
normMat = norm(mat)
@info "deltaS after vr" norm(matVrpca - mat) normMat
relErr = deltaMatIter/normMat
@info " relative error after vrpca iterations : " deltaMatIter/normMat
relErr < 0.05 ? true : false
end
"""
# function testvrpca_withepsil(mat, epsil)
This test extracts the rank to get approximation at given precision epsil
see test : vrpca_epsil
"""
function testvrpca_withepsil(mat, epsil)
#
normMat = norm(mat)
@info "testvrpca_withepsil : doing vrpca initialization with epsil" epsil
pcaPb = VrPCA(mat, epsil)
#
eta = 0.01
batchSize = 20
@info "doing vrpca svd iteration" eta batchSize
@time iterateVrPCA(pcaPb, eta, batchSize)
#
U = PartialSvdStoch.getindex(pcaPb,:U)
S = PartialSvdStoch.getindex(pcaPb,:S)
Vt = PartialSvdStoch.getindex(pcaPb,:Vt)
matVrpca = U.value * diagm(S.value) * Vt.value
relErr = norm(matVrpca - mat)/normMat
@info "residual error after vr" norm(matVrpca - mat) normMat relErr
relErr < 0.05 ? true : false
end | PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | docs | 2998 |
# PartialSvdStoch
This package provides approximate partial SVD using stochastic methods.
It implements two SVD related algorithms, the real purpose of the package being in fact the Shamir algorithm described in the first item.
The algorithms are the following:
1. The paper by **Ohad Shamir: Fast Stochastic Algorithms for SVD and PCA : convergences Properties and Convexity(2015)**.
The algorithm combines a stochastic gradient approach and iterative techniques.
It requires a correct initialization of the left singular vectors obtained here using the **impressive LowRankApprox** package
if the rank is imposed or the algorithm descrided below in the second item if we search the rank for a target precision.
It then provides in a few iterations a further 25%-50% diminution of the relative error in the Froebonius norm.
This can correspond to a reduction by up to a factor of 4 of the rank necessary to obtain the same accuracy by any of the 2 initializations possible.
(Cf by example the test *vrpca_epsil*)
The combination of the Shamir algorithm with the initializing algorithms mentionned above
provide accurate truncated SVD or range approximation for a good performance compromise and can thus save computation in further processing.
2. The chapter on fast incremental Monte-Carlo Svd from **Spectral Algorithms. S. Vempala and R. Kannan(2009)**
(chapter 7 P 85 and Th 7.2 7.3).
The algorithm relies on an iterative decomposition of the range of the data matrix.
Each iteration does successive sampling of columns data vectors proportionally to their L2-norm, construct a range approximation, and substract the current range approximation before next iteration.
Due to its incremental construction it is also possible to ask for an approximation at a given precision without asking for a given rank and let the computation give the rank as an output.
It is not as fast as the *LowRankApprox* package but can provide an alternative depending on the data structure.
Run times are about 4s for a (10000, 20000) matrix and a rank=100 approximation with 2 iterations
on a 2 core laptop and 8 threads (See test *ifsvd_lowRankApproxEpsil*).
On the same matrix, it runs in 14s if we search the rank giving a 0.05 approximation.
## Testing
In the directory test are some tests providing examples of the different uses including timing and precision
comparisons with matrix sizes up to (10000, 20000).
Tests can be run going in the test directory and just execute *include("runtest.jl")*
in the Julia REPL.
The Html documentation is generated by executing *julia make.jl* in the doc directory
from a shell.
## License
Licensed under either of
* Apache License, Version 2.0, [LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>
* MIT license [LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>
at your option.
This software was written on my own while working at [CEA](http://www.cea.fr/), [CEA-LIST](http://www-list.cea.fr/en/)
| PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | docs | 3383 |
# PartialSvdStoch
This package provides approximate partial SVD using stochastic methods.
It implements algorithms descrided in :
1. The paper by Ohad Shamir: **Fast Stochastic Algorithms for SVD and PCA : convergences Properties and Convexity(2015)**.
The algorithm combines a stochastic gradient approach and iterative techniques. It requires
a correct (see the paper) initialization of the rank k matrix of first left singular vectors, then exponential convergence to the exact rank-k approximation is proven in the paper.
The first left singular vectors can be initialized using the *impressive* LowRankApprox package if the rank of approximation required is known, or by the algorithm of Vempala-Kannan (Cf below) if the requirement is a given precision.
The structure related to the implementation of the algorithm is **VrPCA**.
**The implementation deviates from the original article on one point**: \
We sample column vectors from the data matrix in the iteration pass proportionally to their L2-norm (as in the Vempala book see below) and do a weight correction to keep an unbiaised estimator. Tests shows a faster numerical convergence.
The test *vrpca_epsil* shows a case where we can get the same relative error with a rank
5 times less than without the VrPCA iterations.
2. The chapter on fast incremental Monte-Carlo Svd from **Spectral Algorithms. S. Vempala and R. Kannan(2009)**
(chapter 7 P 85 and Th 7.2 7.3).
The algorithm consists in sampling columns a fixed number *samplingSize* of data vectors proportionally
to their L2-norm without replacement.
Vectors sampled are orthogonalised thus constructing a first pass of the range approximation.
To get a more precise estimation another iteration can be done. Then the first approximation is substracted from the range of the data and another set of columns vectors are sampled from the residual to get smaller components of the range. The process can be iterated providing exponential convergence to the rank-k approximation as proved in Vempala. \
Our implementation deviates slightly from the paper as we let the final rank obtained fluctuate depending on the nature of data. As some columns can be rejected if alredy sampled in a pass, we can get a variable rank at the end of the algorithm.
This method is not as fast as the *LowRankApprox* package but can provide a competitive approximation when the matrix of data has large variations of L2-norm between columns as the sampling construct the approximation with the largest contribution of the L2-norm of the data matrix.
(Cf tests for examples).
The function *reduceToEpsil* computes an approximation B at a given precision $\epsilon$ : $\frac{E(|| data - B||_{2})}{E(|| data ||_{2})} <= \epsilon$
and determines the rank accordingly.
The function *reduceToRank* needs usually 2 iterations to achieve a good compromise and that is the default used in the code. Run times are of the order of 4.5s for a (10000, 20000) matrix with 2 iterations for a rank = 100 approximation.
## Miscellaneous
There is a logger installed in the code which is in the Info mode (See beginning of PartialSvdStoch.jl).
It can be set in Debug mode and will then provide some log on variables monitoring convergence.
It must be noted that our package computes residual errors with the Froebonius norm and that
the package LowRankApprox uses the spectral norm.
| PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | docs | 2368 | # Tests
To run test, **in the julia REPL** go to the test directory, and run :
**include("runtests.jl")**.
In fact to avoid compilation times, it is best to execute twice the inclusion of the *runtests.jl* file.
The logger is by default (during tests) in Debug configuration and will output time,
and intermediary convergence results (See file runtests.jl)
All the tests uses randomly generated matrices, moreover the algorithms
use random sampling so the cpu times needed, and precisions obtained can fluctuate but the order of magnitude should be consistent with the results announced for a laptop with 2 cores [email protected] , 32 Gb of Memory and
Julia running with 8 threads.
## ifsvd\_versus\_svd
This compares LowRankApproxMc with exact svd,
computing the L2 norm of the difference of singular values.
## ifsvd_lowRankApproxEpsil
This test runs on a matrix of size (10000, 20000).
It has the structure encountered in hyperspectral images where a column is a pixel, and rows represent
a canal (a mass in mass spectrometry imaging). The matrix has some blocks of related pixels
which have expressions in some common rows.
The iterations of incremental svd with sampling size 100, we can reach in 14s a 5% relative error with an adjusted rank=391,
or depending on random data, in 18s to reach a 3.8% relative error and an adjusted rank= 495
## vrpca_epsil
This tests asks for an approx at 0.01.
It extracts a rank 100 matrix at 0.005 precision within 1.8s.
With LowRankApprox.prange we need to go up to rank=500 (initialized with
*opts = LowRankApprox.LRAOptions(rank=500, rtol = 0.0001)* to achieve a relative Froebonius error of 0.005.
It then runs in 1.15s.
So we see that LowRankApprox is really fast but needs many more singular vectors
to achieve the same relative error, so that VrPCA gives a clear reduction of relative error.
Of course VrPCA initialized with LowRankApprox give an analogous reduction
in relative error as in the following test.
## vrpca_withLowRankApprox
This test runs on the same data as vrpca_epsil. It initialize VrPCA
with *LRAOptions(rank=100, rtol=0.001)* and does a svd of order 100. This pass
runs in 0.7s and gives a relative error of 0.02.
The VrPCA iterations run in 3.2s and take us to a relative error of 0.0049.
Once again LowRankApprox is really fast and VrPCA gives a division by 4 of the relative error.
| PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"Apache-2.0"
] | 0.1.1 | dc526f48c4a839accaa9bbb52a01d76ce882d720 | docs | 228 | # PartialSvdStoch
```@meta
CurrentModule = PartialSvdStoch
```
## User types
```@docs
VrPCA
LowRankApproxMc
```
## Public Functions
```@docs
getindex
reduceToRank
reduceToEpsil
iterateVrPCA
getResidualError
isConverged
```
| PartialSvdStoch | https://github.com/jean-pierreBoth/PartialSvdStoch.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 240 | using Combinatorics
open("load_combos.sh", "w") do f
for (a, b, c, d) in permutations(ARGS)
write(f, "julia --project -e 'using $a; using $b; using $c; using $d' && \\\n")
end
return write(f, "echo -e \\\\nDone!\n")
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 1765 | using Documenter, PoreMatMod, PlutoSliderServer
# run the Pluto example notebooks and export them to HTML for inclusion in the docs
cd("examples") # next line fails if not actually in examples/
PlutoSliderServer.export_directory() # runs each notebook in examples/ and exports to HTML
rm("index.html") # previous line makes additional table-of-contents page (not needed)
export_path = "../docs/src/examples/"
if !isdir(export_path)
mkdir(export_path)
end
for file in readdir() # loop over files in examples/
if length(split(file, ".html")) > 1 # select only the HTML files
@info "Staging file $file"
mv(file, export_path * file; force=true) # move HTML files to docs source folder for build
end
end
cd("..") # return to root for running deploydocs
# build the docs
makedocs(; # to test docs, run this call to `makedocs` in the REPL
root=joinpath(dirname(pathof(PoreMatMod)), "..", "docs"),
modules=[PoreMatMod, Xtals],
sitename="PoreMatMod.jl",
clean=true,
pages=[
"PoreMatMod" => "index.md",
"Manual" => [
"Getting Started" => "manual/start.md",
"Loading Data" => "manual/inputs.md",
"Substructure Search" => "manual/find.md",
"Substructure Find/Replace" => "manual/replace.md"
],
"Examples" => "examples.md",
"PoreMatModGO" => "PoreMatModGO.md",
"Contribute/Report Issues" => "collab.md"
],
format=Documenter.HTML(; assets=["assets/flux.css"]),
push_preview=true,
doctest=false # doctests are run in testing; running them here is redundant and slow
)
# deploy the docs
deploydocs(;
repo="github.com/SimonEnsemble/PoreMatMod.jl.git",
versions=["latest" => "v^", "v#.#.#", "dev" => "master"]
)
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 4151 | ### A Pluto.jl notebook ###
# v0.19.11
using Markdown
using InteractiveUtils
# ╔═╡ 0069ec00-f42b-40bb-a82e-c91ec78583e4
# ╔═╡ 37939a7a-0651-11ec-11c1-6b5ef0a19ec2
# load required packages (Pluto.jl will automatically install them)
using PoreMatMod, PlutoUI
# ╔═╡ 2889e30d-442d-4620-b5f6-0216e21c623b
begin
using PoreMatMod.ExampleHelpers
check_example_data()
end
# ╔═╡ 8d523993-6e85-443a-9949-12030552b457
md"""
## Example: append missing hydrogen atoms to linkers of a MOF
"""
# ╔═╡ ab9b556e-5082-48fa-a7ca-b37ef895d703
input_file_message()
# ╔═╡ 9a9bd9fd-5fea-4c01-a87a-5a5a0d332c1a
xtal_folder_message()
# ╔═╡ fcebd06c-9607-42a5-ba1b-e7683b0924ab
rc[:paths][:crystals]
# ╔═╡ af6f9a09-17ad-45dd-b1fd-50f9cc5a692e
moiety_folder_message()
# ╔═╡ 62439d74-601c-40fc-a488-c0838b9ada69
rc[:paths][:moieties]
# ╔═╡ 026100b5-0708-48bb-840d-931605524874
md"""
!!! example \"the task\"
We have an IRMOF-1 crystal structure with hydrogen atoms missing on the linkers, presumably owing to artifacts of X-ray structure determination. We wish to append hydrogen atoms onto the missing positions on the linkers.
**Parent crystal structure**: first, we read in the `.cif` file describing the parent structure, which is not simulation-ready owing to the missing hydrogen atoms.
"""
# ╔═╡ 0433da26-4f59-424f-9603-875d904c0fd5
begin
# read in the parent xtal
parent = Crystal("IRMOF-1_noH.cif") # load .cif file
infer_bonds!(parent, true) # infer bonds
view_structure(parent) # view structure
end
# ╔═╡ 4ad53cf5-d063-4bb6-ae20-1b6cc29902c8
fragment_construction_note()
# ╔═╡ 64b95411-07da-44af-a06e-9e6676328ffd
md"""
**Query fragment**: next, we construct a query fragment to match the corrupted fragment in the IRMOF-1 parent structure.
"""
# ╔═╡ 83532414-6471-4002-b23c-1600243318d1
query = moiety("1,4-C-phenylene_noH.xyz");
# ╔═╡ fc9e8e21-02c0-43ca-980f-55496526d7f3
view_query_or_replacement("1,4-C-phenylene_noH.xyz")
# ╔═╡ f68335d7-b4e0-40b3-b10d-bf406ab42c1c
with_terminal() do
return display_query_or_replacement_file("1,4-C-phenylene_noH.xyz")
end
# ╔═╡ c53f896d-fa27-4290-aa6d-aa8c0c467f3b
md"""
**Replacement fragment**: then, we construct a replacement fragment as a corrected version of the query fragment (with hydrogen atoms appropriately appended).
"""
# ╔═╡ 0d8ac0fd-c7b1-4781-aaa2-33cc8c1c08ae
replacement = moiety("1,4-C-phenylene.xyz");
# ╔═╡ 836f6d08-c507-44c6-b927-c9ea240f40f8
view_query_or_replacement("1,4-C-phenylene.xyz")
# ╔═╡ b172c36b-80bf-4620-b2e4-5c39d719962e
with_terminal() do
return display_query_or_replacement_file("1,4-C-phenylene.xyz")
end
# ╔═╡ 5b71d14a-be80-4ac3-8983-62571d0d4e7d
md"""
**Find and replace**: finally, we search the parent MOF for the query fragment and effect the replacements. Voila; we have a simulation-ready IRMOF-1 structure. 🚀
"""
# ╔═╡ 74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
begin
child = replace(parent, query => replacement)
view_structure(child)
end
# ╔═╡ 5869bf7a-958e-4e51-997a-18497e7deaba
write_cif_message()
# ╔═╡ dbf3a196-dd4d-4ac8-8396-42ac7c7e0ba1
write_cif(child, "simulation_ready_IRMOF-1.cif")
# ╔═╡ Cell order:
# ╠═0069ec00-f42b-40bb-a82e-c91ec78583e4
# ╟─8d523993-6e85-443a-9949-12030552b457
# ╠═37939a7a-0651-11ec-11c1-6b5ef0a19ec2
# ╠═2889e30d-442d-4620-b5f6-0216e21c623b
# ╟─ab9b556e-5082-48fa-a7ca-b37ef895d703
# ╟─9a9bd9fd-5fea-4c01-a87a-5a5a0d332c1a
# ╠═fcebd06c-9607-42a5-ba1b-e7683b0924ab
# ╟─af6f9a09-17ad-45dd-b1fd-50f9cc5a692e
# ╠═62439d74-601c-40fc-a488-c0838b9ada69
# ╟─026100b5-0708-48bb-840d-931605524874
# ╠═0433da26-4f59-424f-9603-875d904c0fd5
# ╟─4ad53cf5-d063-4bb6-ae20-1b6cc29902c8
# ╟─64b95411-07da-44af-a06e-9e6676328ffd
# ╠═83532414-6471-4002-b23c-1600243318d1
# ╟─fc9e8e21-02c0-43ca-980f-55496526d7f3
# ╟─f68335d7-b4e0-40b3-b10d-bf406ab42c1c
# ╟─c53f896d-fa27-4290-aa6d-aa8c0c467f3b
# ╠═0d8ac0fd-c7b1-4781-aaa2-33cc8c1c08ae
# ╟─836f6d08-c507-44c6-b927-c9ea240f40f8
# ╟─b172c36b-80bf-4620-b2e4-5c39d719962e
# ╟─5b71d14a-be80-4ac3-8983-62571d0d4e7d
# ╠═74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
# ╟─5869bf7a-958e-4e51-997a-18497e7deaba
# ╠═dbf3a196-dd4d-4ac8-8396-42ac7c7e0ba1
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 5894 | ### A Pluto.jl notebook ###
# v0.17.3
using Markdown
using InteractiveUtils
# ╔═╡ 8738d1c4-6907-4a7c-96bf-0467b6eb696d
# ╔═╡ ee100c2d-30aa-4b29-b85e-49417e1ed91c
# load required packages (Pluto.jl will automatically install them)
using PoreMatMod, PlutoUI
# ╔═╡ 172f819b-fca8-433a-9a72-e533078e814c
begin
using PoreMatMod.ExampleHelpers
check_example_data()
end
# ╔═╡ 8d523993-6e85-443a-9949-12030552b457
md"""
## Example: correct disorder and remove guest molecules from experimental data
"""
# ╔═╡ 33992496-1700-4033-8deb-694f82bdd1bc
input_file_message()
# ╔═╡ dc03627f-3da3-4175-b52e-664522df2302
xtal_folder_message()
# ╔═╡ 4be347c1-3f1a-40c1-ae38-f82ed692381e
rc[:paths][:crystals]
# ╔═╡ de84b4a3-a365-4860-9729-2377367c64db
moiety_folder_message()
# ╔═╡ b6dff24a-d0a0-4824-8bb2-2dcb60196b0a
rc[:paths][:moieties]
# ╔═╡ 5b71d14a-be80-4ac3-8983-62571d0d4e7d
md"""
!!! example \"the task\"
we have the experimental structure of SIFSIX-Cu-2-i, which features disordered pyridyl rings in the linkers---presumably as an artifact of X-ray structure determination---and acetylene guest molecules in the pores. We wish to (i) correct the disorder by selecting a single conformation for each ring and (ii) remove the guest molecules from its pores.
**Parent crystal structure**: first, we read in the `.cif` file describing the SIFSIX-Cu-2-i parent structure, which presents disordered ligands and guest molecules in the pores.
"""
# ╔═╡ 6d9c3b97-fd26-470c-8acf-8ce10b33b82d
begin
# read in the parent xtal
parent = Crystal("SIFSIX-2-Cu-i.cif"; check_overlap=false)
infer_bonds!(parent, true) # infer bonds
view_structure(parent) # view structure
end
# ╔═╡ c0feae1a-a228-40eb-a234-e58617fa71dd
fragment_construction_note()
# ╔═╡ ba265b61-9341-48fd-9f93-befd3e65d315
md"""
**Query fragment 1 (disordered ring)**: second, we construct a query fragment to match the disordered rings in the parent structure by cutting one out of the parent structure. we mask all atoms of the query fragment except those belonging to a single conformation of the ring. the masked hydrogen and carbon atoms below are shown in light pink and dark pink, respectively.
"""
# ╔═╡ f2907335-798c-4f9f-bbab-fa8763fb43bb
query_disordered_ring = moiety("disordered_ligand!.xyz");
# ╔═╡ efd5d374-929c-4851-9219-d8e2b86ebb85
view_query_or_replacement("disordered_ligand!.xyz")
# ╔═╡ 3077d0db-01e7-4aab-b183-c0f69a1f2da3
with_terminal() do
return display_query_or_replacement_file("disordered_ligand!.xyz")
end
# ╔═╡ 10911157-64eb-485b-86f1-e83dc201b054
md"""
**Query fragment 2 (guest molecule)**: we also construct an acetylene query fragment to match the guest molecules in the parent structure.
"""
# ╔═╡ db0efdc0-9d29-46ca-8992-39cd7a9ad36c
query_guest = moiety("acetylene.xyz");
# ╔═╡ b5a090eb-5796-44bf-a19c-3705e99d26dd
view_query_or_replacement("acetylene.xyz")
# ╔═╡ 83d00463-ae3b-47d8-b65d-ff8a0aa522e8
with_terminal() do
return display_query_or_replacement_file("acetylene.xyz")
end
# ╔═╡ 25ed4da3-525c-4045-82c4-b3cbf8e707e3
md"""
**Replacement fragment**: next, we construct a replacement fragment---a (non-disordered) pyridyl ring---as a corrected version of the first query fragment that represented the disordered ligand.
"""
# ╔═╡ b57e57d8-897b-466a-b2b5-517afd969123
replacement_ring = moiety("4-pyridyl.xyz");
# ╔═╡ fee26c78-75c2-4844-acdb-d2c4cd71d654
view_query_or_replacement("4-pyridyl.xyz")
# ╔═╡ e85d27a8-ec86-4e38-92a4-f8a2ad9a0ce3
with_terminal() do
return display_query_or_replacement_file("4-pyridyl.xyz")
end
# ╔═╡ da89adc2-0688-44c6-9fd2-791bd13c8d74
md"""
**Find and replace**: finally,
1. search the parent MOF for the first query fragment (disordered rings) and effect the replacements with the corrected (single-conformation ring), then
2. search the parent for the second query fragment (guest molecules) as disconnected components, and delete them.
Hooray; we have a simulation-ready SIFSIX-Cu-2-i structure. 💖
n.b.
* if we had not passed the `disconnected_component=true` kwarg, the algorithm would have found and removed the sides of the pyridyl rings which contain a H-C-C-H fragment!
"""
# ╔═╡ 74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
begin
# repair ring disorder
child = replace(parent, query_disordered_ring => replacement_ring)
# search for disconnected acetylene components
search = substructure_search(query_guest, child; disconnected_component=true)
# delete guest molecules
child = substructure_replace(search, nothing)
view_structure(child)
end
# ╔═╡ 11095805-7c76-42f4-836d-919c2cb27d1c
write_cif_message()
# ╔═╡ c5e14b94-427d-4684-9dd7-bc44d965c570
write_cif(child, "simulation_ready_SIFSIX-Cu-2-i.cif")
# ╔═╡ Cell order:
# ╟─8738d1c4-6907-4a7c-96bf-0467b6eb696d
# ╟─8d523993-6e85-443a-9949-12030552b457
# ╠═ee100c2d-30aa-4b29-b85e-49417e1ed91c
# ╠═172f819b-fca8-433a-9a72-e533078e814c
# ╟─33992496-1700-4033-8deb-694f82bdd1bc
# ╟─dc03627f-3da3-4175-b52e-664522df2302
# ╠═4be347c1-3f1a-40c1-ae38-f82ed692381e
# ╟─de84b4a3-a365-4860-9729-2377367c64db
# ╠═b6dff24a-d0a0-4824-8bb2-2dcb60196b0a
# ╟─5b71d14a-be80-4ac3-8983-62571d0d4e7d
# ╠═6d9c3b97-fd26-470c-8acf-8ce10b33b82d
# ╟─c0feae1a-a228-40eb-a234-e58617fa71dd
# ╟─ba265b61-9341-48fd-9f93-befd3e65d315
# ╠═f2907335-798c-4f9f-bbab-fa8763fb43bb
# ╟─efd5d374-929c-4851-9219-d8e2b86ebb85
# ╟─3077d0db-01e7-4aab-b183-c0f69a1f2da3
# ╟─10911157-64eb-485b-86f1-e83dc201b054
# ╠═db0efdc0-9d29-46ca-8992-39cd7a9ad36c
# ╟─b5a090eb-5796-44bf-a19c-3705e99d26dd
# ╟─83d00463-ae3b-47d8-b65d-ff8a0aa522e8
# ╟─25ed4da3-525c-4045-82c4-b3cbf8e707e3
# ╠═b57e57d8-897b-466a-b2b5-517afd969123
# ╟─fee26c78-75c2-4844-acdb-d2c4cd71d654
# ╟─e85d27a8-ec86-4e38-92a4-f8a2ad9a0ce3
# ╟─da89adc2-0688-44c6-9fd2-791bd13c8d74
# ╠═74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
# ╟─11095805-7c76-42f4-836d-919c2cb27d1c
# ╠═c5e14b94-427d-4684-9dd7-bc44d965c570
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 4917 | ### A Pluto.jl notebook ###
# v0.17.3
using Markdown
using InteractiveUtils
# ╔═╡ 8ae2593a-cb48-44c9-b9dc-ab901c358a06
# ╔═╡ 16f0e183-f48d-4dcd-8751-d3c61c875e18
# load required packages (Pluto.jl will automatically install them)
using PoreMatMod, PlutoUI
# ╔═╡ 3cca5289-a829-4717-b796-0834229995d1
begin
using PoreMatMod.ExampleHelpers
check_example_data()
end
# ╔═╡ 8d523993-6e85-443a-9949-12030552b457
md"""
## example: generate a hypothetical MOF structure by decorating its linkers with functional groups
"""
# ╔═╡ 74b45651-21d5-4332-a4a5-866ea1bb02b8
input_file_message()
# ╔═╡ 3ff0cd63-8bdf-4ba5-92b6-e2a52f7573c2
xtal_folder_message()
# ╔═╡ ccc7fc86-5f48-4cc9-bd5c-349fc1d55b0c
rc[:paths][:crystals]
# ╔═╡ b66dd0d5-5bac-4b23-a33f-17305b0d4728
moiety_folder_message()
# ╔═╡ a76e79ee-c82c-4771-818d-5380a5fb4c18
rc[:paths][:moieties]
# ╔═╡ be86f07e-0669-46c2-8c79-80e65dfcc6f2
md"""
!!! example \"the task\"
we have the IRMOF-1 crystal structure, and wish to append acetamido functional groups to six of its (randomly chosen) BDC (1,4-benzodicarboxylate) linkers to give a mixed-linker IRMOF-1 derivative.
**Parent crystal structure**: first, we read in the `.cif` file describing the parent IRMOF-1 crystal structure.
"""
# ╔═╡ b53e7c38-d8f5-4f28-a9dc-f7902a86fdb2
begin
# read in the parent xtal
parent = Crystal("IRMOF-1.cif") # load .cif file
infer_bonds!(parent, true) # infer bonds
view_structure(parent) # view structure
end
# ╔═╡ b402e79a-784b-4d8b-82f1-df4fe1cedad1
fragment_construction_note()
# ╔═╡ 9b2d534a-4f78-4950-add1-9ba645669bb9
md"""
**Query fragment**: next, we construct a query fragment as a _p_-phenylene fragment to match that on the BCD linker of the IRMOF-1 parent structure. we mark one hydrogen atom on the query fragment as "masked" (shown in pink) by tagging its species label with `!` in the input. we need to mask this hydrogen atom because it will eventually be replaced by the acetamido functional group.
"""
# ╔═╡ 4be03110-61ab-4cd6-b3fe-7d51ac5ee771
query = moiety("2-!-p-phenylene.xyz");
# ╔═╡ e5eaaef4-13a0-48bd-9f2b-5040b2d10ac1
view_query_or_replacement("2-!-p-phenylene.xyz")
# ╔═╡ 559ef3c3-a176-4d65-8958-810c9b0b32c5
with_terminal() do
return display_query_or_replacement_file("2-!-p-phenylene.xyz")
end
# ╔═╡ d1aa8a19-3702-40f6-b73e-b9ebfc1a7a71
md"""
**Replacement fragment**: next, we construct a replacement fragment as a modified version of the query fragment (with acetamido group in place of one hydrogen atom).
"""
# ╔═╡ 44e7e665-ae68-4cd4-b45f-138a0fb8910e
replacement = moiety("2-acetylamido-p-phenylene.xyz");
# ╔═╡ af606f02-fbd5-4033-a5f3-56a8f740b1a1
view_query_or_replacement("2-acetylamido-p-phenylene.xyz")
# ╔═╡ c8f8dbd3-4191-460d-944f-f5e456ce8b83
with_terminal() do
return display_query_or_replacement_file("2-!-p-phenylene.xyz")
end
# ╔═╡ 127a2bef-3903-4801-bc75-00a6dde2bc6e
md"""
**Find and replace**: finally, we (i) search the parent MOF for the query fragment and (ii) effect the replacements. Ta-da; we have a hypothetical derivatized IRMOF-1 structure. 🎈
n.b.
* the `nb_loc=6` kwarg indicates that we wish to randomly select 6 matches on the IRMOF-1 parent structure to effect the replacement. the `loc` kwarg grants more control over which BDC linkers are functionalized.
* the acetamido functional groups are appended at random positions on each BDC ligand. the `ori` kwarg grants more control over which positions on each linker are functionalized.
* if we omit `nb_loc=6` as a kwarg, a functional group is appended on all BDC linkers of the parent.
"""
# ╔═╡ 74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
begin
child = replace(parent, query => replacement; nb_loc=6)
view_structure(child)
end
# ╔═╡ 986ecdc4-455f-457e-a964-f00ddfeb53a2
write_cif_message()
# ╔═╡ 71209370-c445-4ff2-a873-b6e31c46419b
write_cif(child, "acetamido-functionalized_IRMOF-1.cif")
# ╔═╡ Cell order:
# ╟─8ae2593a-cb48-44c9-b9dc-ab901c358a06
# ╟─8d523993-6e85-443a-9949-12030552b457
# ╠═16f0e183-f48d-4dcd-8751-d3c61c875e18
# ╠═3cca5289-a829-4717-b796-0834229995d1
# ╠═74b45651-21d5-4332-a4a5-866ea1bb02b8
# ╟─3ff0cd63-8bdf-4ba5-92b6-e2a52f7573c2
# ╠═ccc7fc86-5f48-4cc9-bd5c-349fc1d55b0c
# ╟─b66dd0d5-5bac-4b23-a33f-17305b0d4728
# ╠═a76e79ee-c82c-4771-818d-5380a5fb4c18
# ╟─be86f07e-0669-46c2-8c79-80e65dfcc6f2
# ╠═b53e7c38-d8f5-4f28-a9dc-f7902a86fdb2
# ╟─b402e79a-784b-4d8b-82f1-df4fe1cedad1
# ╟─9b2d534a-4f78-4950-add1-9ba645669bb9
# ╠═4be03110-61ab-4cd6-b3fe-7d51ac5ee771
# ╟─e5eaaef4-13a0-48bd-9f2b-5040b2d10ac1
# ╟─559ef3c3-a176-4d65-8958-810c9b0b32c5
# ╟─d1aa8a19-3702-40f6-b73e-b9ebfc1a7a71
# ╠═44e7e665-ae68-4cd4-b45f-138a0fb8910e
# ╟─af606f02-fbd5-4033-a5f3-56a8f740b1a1
# ╟─c8f8dbd3-4191-460d-944f-f5e456ce8b83
# ╟─127a2bef-3903-4801-bc75-00a6dde2bc6e
# ╠═74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
# ╟─986ecdc4-455f-457e-a964-f00ddfeb53a2
# ╠═71209370-c445-4ff2-a873-b6e31c46419b
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 5071 | ### A Pluto.jl notebook ###
# v0.17.3
using Markdown
using InteractiveUtils
# ╔═╡ 53071de7-da2f-4628-9313-2124693ce525
# ╔═╡ d4e77120-8ee6-4514-b066-6127aaa1d6c9
# load required packages (Pluto.jl will automatically install them)
using PoreMatMod, PlutoUI
# ╔═╡ 468c12c0-886f-409b-b36f-b6ff90063e40
begin
using PoreMatMod.ExampleHelpers
check_example_data()
end
# ╔═╡ 8d523993-6e85-443a-9949-12030552b457
md"""
## Example: introduce missing-linker defects into a MOF structure
"""
# ╔═╡ e2877131-2e59-4e00-b549-70529d8e71e4
input_file_message()
# ╔═╡ 3eb0313b-0a64-482e-930a-14bd0353a00c
xtal_folder_message()
# ╔═╡ d47c97d5-614e-4c61-b65d-f3fb44014cd1
rc[:paths][:crystals]
# ╔═╡ 528b29d8-847a-4723-8fde-fa319a7b8f3f
moiety_folder_message()
# ╔═╡ 1a62d3bf-95f5-4b1b-af12-6f9db700e5f4
rc[:paths][:moieties]
# ╔═╡ 5b71d14a-be80-4ac3-8983-62571d0d4e7d
md"""
!!! example \"the task\"
we have the crystal structure for the MOF UiO-66, and we wish to introduce missing-linker defects by removing BDC (1,4-benzodicarboxylate) linkers and adding formate ion capping groups in their place.
**Parent crystal structure**: first, we read in the `.cif` file describing the parent structure (the UiO-66 unit cell, replicated twice on each crystallographic axis).
"""
# ╔═╡ 8819797c-f1a2-4c46-999d-00316bd21e44
begin
# read in the parent xtal
parent = Crystal("UiO-66.cif") # load .cif file
infer_bonds!(parent, true) # infer bonds
view_structure(parent) # view structure
end
# ╔═╡ 103d3258-5f1c-4b6f-81e3-f45c2bbac844
fragment_construction_note()
# ╔═╡ 15ae88e9-b886-4cc6-9ba7-41111bfa06b0
md"""
**Query fragment**: next, we construct a query fragment to be the BDC linker in the parent structure. the masked atoms to be deleted are tagged with `!` in the `.xyz` input file: the masked hydrogen and carbon atoms are shown in light pink and dark pink, respectively.
"""
# ╔═╡ 1a443428-e283-4205-986e-d0c4ac09bbaa
query = moiety("BDC.xyz");
# ╔═╡ 19282148-e649-4d6e-833d-43fa3cde14c6
view_query_or_replacement("BDC.xyz")
# ╔═╡ d56f8ef4-9a3a-4607-99b1-26034bb23757
with_terminal() do
return display_query_or_replacement_file("BDC.xyz")
end
# ╔═╡ b3a0b763-f9ae-480a-8ad0-ff35f12dc68f
md"""
**Replacement fragment**: next, we construct a replacement fragment as the BDC linker with the _p_-phenylene ring removed, giving a pair of formate ions, spaced so as to neatly replace (but in effect keep) the carboxyl groups of the BDC linker (and in effect remove the _p_-phenylene ring).
"""
# ╔═╡ 6a3779f7-dbc5-47b7-a261-1b6144304d5f
replacement = moiety("formate_caps.xyz");
# ╔═╡ 5d62cc3f-4834-4755-b398-922336a26ed8
view_query_or_replacement("formate_caps.xyz")
# ╔═╡ a9005ea7-9fe4-4112-bd9b-a5bb124b0d04
with_terminal() do
return display_query_or_replacement_file("formate_caps.xyz")
end
# ╔═╡ 03b88236-08cb-4f1f-b23d-5f78581373b4
md"""
**Find and replace**: finally, we search the parent MOF for the query fragment and effect the replacements. nice; we have a UiO-66 crystal structure model harboring engineered missing-linker defects. 🎆
n.b.
* the `loc` kwarg indicates which matches to effect the replacement; we carefully chose these locations to introduce a new channel into the MOF.
"""
# ╔═╡ 74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
begin
child = replace(parent, query => replacement; loc=[3, 9])
view_structure(child)
end
# ╔═╡ 7b34f300-4815-43f3-8f10-18cb6c76c7f4
write_cif_message()
# ╔═╡ 14f1459b-f505-4950-80f4-7e641abb6b7a
write_cif(child, "defected_UiO-66.cif")
# ╔═╡ a31ddf3a-561c-4240-bb8e-481ed3a5083d
md"""
!!! note \"Regarding fragment selection\"
The astute observer will note that a seemingly simpler pair of query/replacement fragments might be chosen, so as to replace each *half* of a BDC linker with a formate ion. This is perfectly fine, but leaves the user with the task of determining twice as many locations upon which to operate, such that the correct *six halves* of BDC linkers (making three complete linkers) are replaced.
"""
# ╔═╡ Cell order:
# ╟─53071de7-da2f-4628-9313-2124693ce525
# ╟─8d523993-6e85-443a-9949-12030552b457
# ╠═d4e77120-8ee6-4514-b066-6127aaa1d6c9
# ╠═468c12c0-886f-409b-b36f-b6ff90063e40
# ╟─e2877131-2e59-4e00-b549-70529d8e71e4
# ╠═3eb0313b-0a64-482e-930a-14bd0353a00c
# ╠═d47c97d5-614e-4c61-b65d-f3fb44014cd1
# ╠═528b29d8-847a-4723-8fde-fa319a7b8f3f
# ╠═1a62d3bf-95f5-4b1b-af12-6f9db700e5f4
# ╟─5b71d14a-be80-4ac3-8983-62571d0d4e7d
# ╠═8819797c-f1a2-4c46-999d-00316bd21e44
# ╟─103d3258-5f1c-4b6f-81e3-f45c2bbac844
# ╟─15ae88e9-b886-4cc6-9ba7-41111bfa06b0
# ╠═1a443428-e283-4205-986e-d0c4ac09bbaa
# ╟─19282148-e649-4d6e-833d-43fa3cde14c6
# ╟─d56f8ef4-9a3a-4607-99b1-26034bb23757
# ╟─b3a0b763-f9ae-480a-8ad0-ff35f12dc68f
# ╠═6a3779f7-dbc5-47b7-a261-1b6144304d5f
# ╟─5d62cc3f-4834-4755-b398-922336a26ed8
# ╟─a9005ea7-9fe4-4112-bd9b-a5bb124b0d04
# ╟─03b88236-08cb-4f1f-b23d-5f78581373b4
# ╠═74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
# ╟─7b34f300-4815-43f3-8f10-18cb6c76c7f4
# ╠═14f1459b-f505-4950-80f4-7e641abb6b7a
# ╟─a31ddf3a-561c-4240-bb8e-481ed3a5083d
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 6877 | ### A Pluto.jl notebook ###
# v0.17.3
using Markdown
using InteractiveUtils
# ╔═╡ 359a6c00-c9a6-441d-b258-55bfb5deb4b5
# ╔═╡ a948f8b3-4ec5-40b9-b2c1-fcf5b8ad67fa
# load required packages (Pluto.jl will automatically install them)
using PoreMatMod, PlutoUI
# ╔═╡ 77c63e60-2708-4fef-a6ea-cb394f114b88
begin
using PoreMatMod.ExampleHelpers
check_example_data()
end
# ╔═╡ 8d523993-6e85-443a-9949-12030552b457
md"""
## example: generating hypothetical MOF structures with different replacement styles
"""
# ╔═╡ 74b45651-21d5-4332-a4a5-866ea1bb02b8
input_file_message()
# ╔═╡ 3ff0cd63-8bdf-4ba5-92b6-e2a52f7573c2
xtal_folder_message()
# ╔═╡ ccc7fc86-5f48-4cc9-bd5c-349fc1d55b0c
rc[:paths][:crystals]
# ╔═╡ b66dd0d5-5bac-4b23-a33f-17305b0d4728
moiety_folder_message()
# ╔═╡ a76e79ee-c82c-4771-818d-5380a5fb4c18
rc[:paths][:moieties]
# ╔═╡ be86f07e-0669-46c2-8c79-80e65dfcc6f2
md"""
!!! example \"the task\"
we have the IRMOF-1 crystal structure, and wish to explore appending the acetamido functional group its BDC linkers using different replacement styles.
**Parent crystal structure**: first, we read in the `.cif` file describing the parent IRMOF-1 crystal structure.
"""
# ╔═╡ b53e7c38-d8f5-4f28-a9dc-f7902a86fdb2
begin
# read in the parent xtal
parent = Crystal("IRMOF-1.cif") # load .cif file
infer_bonds!(parent, true) # infer bonds
view_structure(parent) # view structure
end
# ╔═╡ b402e79a-784b-4d8b-82f1-df4fe1cedad1
fragment_construction_note()
# ╔═╡ 9b2d534a-4f78-4950-add1-9ba645669bb9
md"""
**Query fragment**: next, we construct a query fragment as a _p_-phenylene fragment to match that on the BCD linker of the IRMOF-1 parent structure. we mark one hydrogen atom on the query fragment as "masked" (shown in pink) by tagging its species label with `!` in the input. we need to mask this hydrogen atom because it will eventually be replaced by the acetamido functional group.
"""
# ╔═╡ 4be03110-61ab-4cd6-b3fe-7d51ac5ee771
query = moiety("2-!-p-phenylene.xyz");
# ╔═╡ e5eaaef4-13a0-48bd-9f2b-5040b2d10ac1
view_query_or_replacement("2-!-p-phenylene.xyz")
# ╔═╡ 559ef3c3-a176-4d65-8958-810c9b0b32c5
with_terminal() do
return display_query_or_replacement_file("2-!-p-phenylene.xyz")
end
# ╔═╡ d1aa8a19-3702-40f6-b73e-b9ebfc1a7a71
md"""
**Replacement fragment**: next, we construct a replacement fragment as a modified version of the query fragment (with acetamido group in place of one hydrogen atom).
"""
# ╔═╡ 44e7e665-ae68-4cd4-b45f-138a0fb8910e
replacement = moiety("2-nitro-p-phenylene.xyz");
# ╔═╡ af606f02-fbd5-4033-a5f3-56a8f740b1a1
view_query_or_replacement("2-nitro-p-phenylene.xyz")
# ╔═╡ c8f8dbd3-4191-460d-944f-f5e456ce8b83
with_terminal() do
return display_query_or_replacement_file("2-nitro-p-phenylene.xyz")
end
# ╔═╡ 127a2bef-3903-4801-bc75-00a6dde2bc6e
md"""
### Replacement Modes
There are several options when performing a replacement that control how the replacement fragments will be positioned in the parent structure.
With all three file inputs loaded (IRMOF-1 as `parent`, 2-!-*p*-phenylene as `query`, and 2-nitro-*p*-phenylene as `replacement`) and a `search` performed, replacements can be made.
`PoreMatMod.jl` has several replacement modes, one of which must be specified.
"""
# ╔═╡ 0e3f7334-9e7f-483b-a0ac-70777902bf51
md"""
!!! note \"Note\"
Multiple replacements can be done with a single search.
"""
# ╔═╡ b7b46022-aee0-4d51-8a5e-0c8c005f341a
search = query ∈ parent
# ╔═╡ 68557426-3204-45a1-8801-84c459e5ac66
md"""
#### Default: optimal orientation at all locations
Optimal configurations will be chosen for each location in `search.isomorphisms`, so that each occurrence of the `query` in the `parent` is replaced with minimal perturbation of the conserved atoms from the parent structure.
"""
# ╔═╡ 74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
begin
local child = substructure_replace(search, replacement)
view_structure(child)
end
# ╔═╡ bed9d62f-d61d-4fb1-9a12-188a864fff21
md"""
#### Optimal Orientation at *n* random locations
If only some of the linkers should be replaced, the `nb_loc` argument lets us specify how many.
"""
# ╔═╡ 9dbf7859-762d-4edc-8300-ac3bba151a8a
begin
local child = substructure_replace(search, replacement; nb_loc=8)
view_structure(child)
end
# ╔═╡ 95215fe9-a7e6-4563-94b6-5ed1d5dde03b
md"""
#### Optimal orientation at specific locations
Specific locations are chosen by providing the `loc` argument.
"""
# ╔═╡ 8c22f94c-b235-40b2-8fc8-6052c31a6b6e
begin
local child = substructure_replace(search, replacement; loc=[17, 18, 19, 20])
view_structure(child)
end
# ╔═╡ 6297833a-ea26-4958-ad56-fc76aeabee69
md"""
#### Specific replacements
Providing both the `loc` and `ori` arguments allows specifying the exact configuration used in each replacement. A zero value for any element of `ori` means to use the optimal replacement at the corresponding location.
"""
# ╔═╡ 183f9ff1-810a-4062-a3c6-cdb82dbd8a7a
begin
local child =
substructure_replace(search, replacement; loc=[1, 2, 3, 13], ori=[0, 1, 2, 3])
view_structure(child)
end
# ╔═╡ 0347c45c-899b-4c4d-9b31-f09a205636f0
md"""
#### Random orientations
By using the `random` keyword argument, the search for optimal alignment can be skipped, and an arbitrary alignment option will be used.
"""
# ╔═╡ b7064b05-6e57-4e81-8cbc-b2075166a1af
begin
local child = substructure_replace(search, replacement; nb_loc=24, random=true)
view_structure(child)
end
# ╔═╡ Cell order:
# ╟─359a6c00-c9a6-441d-b258-55bfb5deb4b5
# ╟─8d523993-6e85-443a-9949-12030552b457
# ╠═a948f8b3-4ec5-40b9-b2c1-fcf5b8ad67fa
# ╠═77c63e60-2708-4fef-a6ea-cb394f114b88
# ╟─74b45651-21d5-4332-a4a5-866ea1bb02b8
# ╟─3ff0cd63-8bdf-4ba5-92b6-e2a52f7573c2
# ╠═ccc7fc86-5f48-4cc9-bd5c-349fc1d55b0c
# ╟─b66dd0d5-5bac-4b23-a33f-17305b0d4728
# ╠═a76e79ee-c82c-4771-818d-5380a5fb4c18
# ╟─be86f07e-0669-46c2-8c79-80e65dfcc6f2
# ╠═b53e7c38-d8f5-4f28-a9dc-f7902a86fdb2
# ╟─b402e79a-784b-4d8b-82f1-df4fe1cedad1
# ╟─9b2d534a-4f78-4950-add1-9ba645669bb9
# ╠═4be03110-61ab-4cd6-b3fe-7d51ac5ee771
# ╟─e5eaaef4-13a0-48bd-9f2b-5040b2d10ac1
# ╟─559ef3c3-a176-4d65-8958-810c9b0b32c5
# ╟─d1aa8a19-3702-40f6-b73e-b9ebfc1a7a71
# ╠═44e7e665-ae68-4cd4-b45f-138a0fb8910e
# ╟─af606f02-fbd5-4033-a5f3-56a8f740b1a1
# ╟─c8f8dbd3-4191-460d-944f-f5e456ce8b83
# ╟─127a2bef-3903-4801-bc75-00a6dde2bc6e
# ╟─0e3f7334-9e7f-483b-a0ac-70777902bf51
# ╠═b7b46022-aee0-4d51-8a5e-0c8c005f341a
# ╟─68557426-3204-45a1-8801-84c459e5ac66
# ╠═74aa19d2-b1a4-4333-9ff9-e6ea74e7d989
# ╟─bed9d62f-d61d-4fb1-9a12-188a864fff21
# ╠═9dbf7859-762d-4edc-8300-ac3bba151a8a
# ╟─95215fe9-a7e6-4563-94b6-5ed1d5dde03b
# ╠═8c22f94c-b235-40b2-8fc8-6052c31a6b6e
# ╟─6297833a-ea26-4958-ad56-fc76aeabee69
# ╠═183f9ff1-810a-4062-a3c6-cdb82dbd8a7a
# ╟─0347c45c-899b-4c4d-9b31-f09a205636f0
# ╠═b7064b05-6e57-4e81-8cbc-b2075166a1af
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 3287 | ### A Pluto.jl notebook ###
# v0.17.3
using Markdown
using InteractiveUtils
# ╔═╡ 64b72493-6cac-4b92-9a81-6a5df12f7875
begin
import Pkg
Pkg.add(; url="https://github.com/SimonEnsemble/PoreMatMod.jl")
end
# ╔═╡ 5401e009-923e-4a7f-9f3a-fd534f06d8b0
# load required packages (Pluto.jl will automatically install them)
using PoreMatMod, PlutoUI
# ╔═╡ 0f99b225-db96-485c-9e2c-1b4179601e53
begin
using PoreMatMod.ExampleHelpers
check_example_data()
end
# ╔═╡ 8d523993-6e85-443a-9949-12030552b457
md"""
## example: performing a substructure search to find the linkers in a MOF
"""
# ╔═╡ 74b45651-21d5-4332-a4a5-866ea1bb02b8
input_file_message()
# ╔═╡ 3ff0cd63-8bdf-4ba5-92b6-e2a52f7573c2
xtal_folder_message()
# ╔═╡ ccc7fc86-5f48-4cc9-bd5c-349fc1d55b0c
rc[:paths][:crystals]
# ╔═╡ b66dd0d5-5bac-4b23-a33f-17305b0d4728
moiety_folder_message()
# ╔═╡ a76e79ee-c82c-4771-818d-5380a5fb4c18
rc[:paths][:moieties]
# ╔═╡ be86f07e-0669-46c2-8c79-80e65dfcc6f2
md"""
!!! example \"the task\"
we have the IRMOF-1 crystal structure, and wish to explore appending the acetamido functional group its BDC linkers using different replacement styles.
**Parent crystal structure**: first, we read in the `.cif` file describing the parent IRMOF-1 crystal structure.
"""
# ╔═╡ b53e7c38-d8f5-4f28-a9dc-f7902a86fdb2
begin
# read in the parent xtal
parent = Crystal("IRMOF-1.cif") # load .cif file
infer_bonds!(parent, true) # infer bonds
view_structure(parent) # view structure
end
# ╔═╡ b402e79a-784b-4d8b-82f1-df4fe1cedad1
fragment_construction_note()
# ╔═╡ 9b2d534a-4f78-4950-add1-9ba645669bb9
md"""
**Query fragment**: next, we construct a query fragment as a _p_-phenylene fragment to match that on the BCD linker of the IRMOF-1 parent structure.
"""
# ╔═╡ 4be03110-61ab-4cd6-b3fe-7d51ac5ee771
query = moiety("p-phenylene.xyz");
# ╔═╡ e5eaaef4-13a0-48bd-9f2b-5040b2d10ac1
view_query_or_replacement("p-phenylene.xyz")
# ╔═╡ 559ef3c3-a176-4d65-8958-810c9b0b32c5
with_terminal() do
return display_query_or_replacement_file("p-phenylene.xyz")
end
# ╔═╡ 127a2bef-3903-4801-bc75-00a6dde2bc6e
md"""
### Substructure Search
Find substructures in the `parent` that match the `query`:
"""
# ╔═╡ b7b46022-aee0-4d51-8a5e-0c8c005f341a
search = query ∈ parent
# ╔═╡ 536d3474-bc9c-4576-a120-826020f8d772
hits = isomorphic_substructures(search)
# ╔═╡ ec84ba70-b83e-4a46-9037-aed54bb07b07
view_structure(hits)
# ╔═╡ Cell order:
# ╟─64b72493-6cac-4b92-9a81-6a5df12f7875
# ╟─8d523993-6e85-443a-9949-12030552b457
# ╠═5401e009-923e-4a7f-9f3a-fd534f06d8b0
# ╠═0f99b225-db96-485c-9e2c-1b4179601e53
# ╟─74b45651-21d5-4332-a4a5-866ea1bb02b8
# ╟─3ff0cd63-8bdf-4ba5-92b6-e2a52f7573c2
# ╠═ccc7fc86-5f48-4cc9-bd5c-349fc1d55b0c
# ╟─b66dd0d5-5bac-4b23-a33f-17305b0d4728
# ╠═a76e79ee-c82c-4771-818d-5380a5fb4c18
# ╟─be86f07e-0669-46c2-8c79-80e65dfcc6f2
# ╠═b53e7c38-d8f5-4f28-a9dc-f7902a86fdb2
# ╟─b402e79a-784b-4d8b-82f1-df4fe1cedad1
# ╟─9b2d534a-4f78-4950-add1-9ba645669bb9
# ╠═4be03110-61ab-4cd6-b3fe-7d51ac5ee771
# ╟─e5eaaef4-13a0-48bd-9f2b-5040b2d10ac1
# ╟─559ef3c3-a176-4d65-8958-810c9b0b32c5
# ╟─127a2bef-3903-4801-bc75-00a6dde2bc6e
# ╠═b7b46022-aee0-4d51-8a5e-0c8c005f341a
# ╠═536d3474-bc9c-4576-a120-826020f8d772
# ╠═ec84ba70-b83e-4a46-9037-aed54bb07b07
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 4973 | ### A Pluto.jl notebook ###
# v0.17.3
using Markdown
using InteractiveUtils
# ╔═╡ fd82b765-7a62-4f85-bf60-28c83b1731aa
begin
import Pkg
Pkg.add(; url="https://github.com/SimonEnsemble/PoreMatMod.jl")
end
# ╔═╡ 3bb3966e-a7dd-46c1-b649-33169ce424d2
using PoreMatMod, PlutoUI
# ╔═╡ d3eef6f4-ff15-47f3-8686-2c0cb0fb882d
begin
using PoreMatMod.ExampleHelpers
check_example_data()
end
# ╔═╡ 8e4fd703-f53e-4056-9466-66f07bacad8d
md"## Example: substructure replacement in a high-symmetry parent"
# ╔═╡ 49ce8a40-3c99-48a8-9403-f5538d1d9a67
input_file_message()
# ╔═╡ 98ee7a1e-1c27-4819-b752-01602cde2799
xtal_folder_message()
# ╔═╡ f5a08f77-9830-4e8e-b746-6a1d61f39009
rc[:paths][:crystals]
# ╔═╡ 8c4c9c65-61a3-4ac8-9413-48aab281237e
moiety_folder_message()
# ╔═╡ 4c5e0230-4db5-49de-b9d7-152ebc834d48
rc[:paths][:moieties]
# ╔═╡ e7be5fba-b120-47f5-a952-8577ee847d99
md"""
!!! example \"the task\"
We have a crystallographic unit cell of NiPyC. We wish to append methyl groups onto the PyC linkers.
**Parent crystal structure**: first, we read in the `.cif` file describing the parent structure, which is in a high-symmetry representation, meaning this structure must be reproduced according to the symmetry rules of the unit cell's space group. Normally, structures are automatically transformed to P1 symmetry, so we must specify that we wish to preserve the original unit cell.
"""
# ╔═╡ c0e2ffbd-fb85-4187-b8b5-73edea90969a
begin
# read in the parent xtal, keeping it in its original space group
parent = Crystal("NiPyC_experiment.cif"; convert_to_p1=false) # load cif file
infer_bonds!(parent, true) # infer bonds
view_structure(parent) # view structure
end
# ╔═╡ 0bbe1bf4-89e8-4372-8f6a-93fc89334b00
fragment_construction_note()
# ╔═╡ f02fdbf1-2c43-40df-a678-e3c535751f3e
md"""
**Query fragment**: next, we construct a query fragment to match the linker in NiPyC.
"""
# ╔═╡ 16faf8c8-d5c2-4755-945b-546cdac27350
query = moiety("PyC.xyz");
# ╔═╡ 75610c4a-9218-406c-b28f-8e299e197135
view_query_or_replacement("PyC.xyz")
# ╔═╡ 5e90af51-f777-47f9-980b-19bca38de5d4
with_terminal() do
return display_query_or_replacement_file("PyC.xyz")
end
# ╔═╡ 70468997-24fa-4c1b-9f02-379823f97db8
md"""
**Replacement fragment**: then, we construct a replacement fragment as a corrected version of the query fragment (with hydrogen atoms appropriately appended).
"""
# ╔═╡ aac504f5-080e-47b8-9a33-d43c16dc87e7
replacement = moiety("PyC-CH3.xyz");
# ╔═╡ 976795e6-e696-4a37-9cd1-83b4d2695a96
view_query_or_replacement("PyC-CH3.xyz")
# ╔═╡ 7f82be68-558d-4dce-8492-bcc585ddf448
with_terminal() do
return display_query_or_replacement_file("PyC-CH3.xyz")
end
# ╔═╡ 2e3299b5-3b63-48d9-90d7-b8dde5715907
md"""
**Find and replace**: finally, we search the parent MOF for the query fragment and effect the replacement.
"""
# ╔═╡ 0fd8b373-9fec-4b18-b1a6-1b11741e5215
search = query in parent
# ╔═╡ 0b287f09-a121-430a-a749-dc93492d1680
child = substructure_replace(search, replacement; nb_loc=1, wrap=false)
# ╔═╡ d8ea8d5e-f17a-412b-8461-15ba6d9621ec
write_cif(child)
# ╔═╡ eae2225c-40f0-4d68-a9a2-43a39a82f029
view_structure(child)
# ╔═╡ 000144c6-be54-4774-b449-698e9da0741a
write_cif(child, "data/crystals/symmetry_child.cif")
# ╔═╡ 47efaf2e-6758-42c5-aab2-80c1d7725b4a
md"""
**making the super-cell** once we have the high-symmetry structure modified, we can apply the symmetry rules and get a replicated super-cell.
"""
# ╔═╡ 36a1be30-db0e-4c45-8894-859e36793482
begin
p1_child = Crystal("symmetry_child.cif"; check_overlap=false)
p1_child = replicate(p1_child, (2, 2, 2))
infer_bonds!(p1_child, true)
write_cif(p1_child, "supercell.cif")
view_structure(p1_child)
end
# ╔═╡ Cell order:
# ╟─fd82b765-7a62-4f85-bf60-28c83b1731aa
# ╟─8e4fd703-f53e-4056-9466-66f07bacad8d
# ╠═3bb3966e-a7dd-46c1-b649-33169ce424d2
# ╠═d3eef6f4-ff15-47f3-8686-2c0cb0fb882d
# ╟─49ce8a40-3c99-48a8-9403-f5538d1d9a67
# ╠═98ee7a1e-1c27-4819-b752-01602cde2799
# ╠═f5a08f77-9830-4e8e-b746-6a1d61f39009
# ╟─8c4c9c65-61a3-4ac8-9413-48aab281237e
# ╠═4c5e0230-4db5-49de-b9d7-152ebc834d48
# ╟─e7be5fba-b120-47f5-a952-8577ee847d99
# ╠═c0e2ffbd-fb85-4187-b8b5-73edea90969a
# ╟─0bbe1bf4-89e8-4372-8f6a-93fc89334b00
# ╟─f02fdbf1-2c43-40df-a678-e3c535751f3e
# ╠═16faf8c8-d5c2-4755-945b-546cdac27350
# ╟─75610c4a-9218-406c-b28f-8e299e197135
# ╟─5e90af51-f777-47f9-980b-19bca38de5d4
# ╟─70468997-24fa-4c1b-9f02-379823f97db8
# ╠═aac504f5-080e-47b8-9a33-d43c16dc87e7
# ╟─976795e6-e696-4a37-9cd1-83b4d2695a96
# ╟─7f82be68-558d-4dce-8492-bcc585ddf448
# ╟─2e3299b5-3b63-48d9-90d7-b8dde5715907
# ╠═0fd8b373-9fec-4b18-b1a6-1b11741e5215
# ╠═0b287f09-a121-430a-a749-dc93492d1680
# ╠═d8ea8d5e-f17a-412b-8461-15ba6d9621ec
# ╠═eae2225c-40f0-4d68-a9a2-43a39a82f029
# ╠═000144c6-be54-4774-b449-698e9da0741a
# ╟─47efaf2e-6758-42c5-aab2-80c1d7725b4a
# ╠═36a1be30-db0e-4c45-8894-859e36793482
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 1741 | ### A Pluto.jl notebook ###
# v0.17.3
using Markdown
using InteractiveUtils
# ╔═╡ d757a3a8-1ee3-4afd-b0bd-9d8429250f96
begin
import Pkg
Pkg.add(; url="https://github.com/SimonEnsemble/PoreMatMod.jl")
end
# ╔═╡ 322d1bd1-86ae-47e7-b49d-38687eb3885a
using PoreMatMod
# ╔═╡ 494d2664-b5cf-43fe-850b-538a090dd0e8
using PoreMatMod.ExampleHelpers
# ╔═╡ 095d18b8-b8ab-4bd8-89dc-4382f9375b42
begin
parent = Crystal("UiO-66.cif")
for x in parent.atoms.coords.xf
if x == 1.0
x -= eps(Float64)
elseif x == 0.0
x += eps(Float64)
end
end
end
# ╔═╡ ac94ddb2-314c-49a7-b0bb-4371f93c0429
infer_bonds!(parent, true)
# ╔═╡ ecb86319-1c5c-48f8-98b9-8bccca5e9953
SBU = moiety("SBU.xyz")
# ╔═╡ d7b5abf5-13fb-4644-9502-6c54106be51a
bimetallic_SBU = moiety("bimetallic_SBU.xyz")
# ╔═╡ 44b0cc75-036b-468f-9da7-04c2d97536a9
begin
multi_metal = replace(parent, SBU => bimetallic_SBU)
translate_by!(multi_metal.atoms.coords, Frac([-0.25, -0.25, 0.0]))
end
# ╔═╡ 780437f4-3a42-4aa2-b2e8-599d8d232dc2
write_cif(multi_metal, "multi-metal.cif")
# ╔═╡ ad888be3-2123-4d2f-865a-ff7a63cebf9e
begin
shifted_uio66 = deepcopy(parent)
translate_by!(shifted_uio66.atoms.coords, Frac([-0.25, -0.25, 0.0]))
write_cif(shifted_uio66, "shifted_parent.cif")
end
# ╔═╡ Cell order:
# ╠═d757a3a8-1ee3-4afd-b0bd-9d8429250f96
# ╠═322d1bd1-86ae-47e7-b49d-38687eb3885a
# ╠═494d2664-b5cf-43fe-850b-538a090dd0e8
# ╠═095d18b8-b8ab-4bd8-89dc-4382f9375b42
# ╠═ac94ddb2-314c-49a7-b0bb-4371f93c0429
# ╠═ecb86319-1c5c-48f8-98b9-8bccca5e9953
# ╠═d7b5abf5-13fb-4644-9502-6c54106be51a
# ╠═44b0cc75-036b-468f-9da7-04c2d97536a9
# ╠═780437f4-3a42-4aa2-b2e8-599d8d232dc2
# ╠═ad888be3-2123-4d2f-865a-ff7a63cebf9e
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 19197 | ### A Pluto.jl notebook ###
# v0.17.2
using Markdown
using InteractiveUtils
# ╔═╡ 2065e50f-1bba-4182-ae16-70feecaa1942
using PoreMatMod
# ╔═╡ 5e702404-3665-411e-a4d2-cb7fba303c91
using PoreMatMod.ExampleHelpers
# ╔═╡ 52318187-a575-4864-8185-416faeea27ab
begin
rc[:paths][:crystals] = realpath(joinpath(pwd(), "..", "test", "data", "crystals"))
rc[:paths][:moieties] = realpath(joinpath(pwd(), "..", "test", "data", "moieties"))
end
# ╔═╡ 6922e27b-b848-418b-bf1a-df17315baa80
begin
parent = replicate(Crystal("diamond.cif"; remove_duplicates=true), (2, 2, 1))
strip_numbers_from_atom_labels!(parent)
infer_bonds!(parent, true)
end
# ╔═╡ 418a7421-92ed-406f-9578-34187529c307
write_cif(parent, "diamond_cell.cif")
# ╔═╡ f7d3cb8c-9d12-4f78-94c6-30a308648e69
view_structure(parent)
# ╔═╡ 90f53a39-89b3-41c5-ad8b-c0683b96c9e4
query = moiety("adamantane_C5.xyz")
# ╔═╡ 58b79260-8a7a-4ca4-bdee-4c3c463334ba
replacement = moiety("nitrogen_vacancy.xyz")
# ╔═╡ b835a642-0a24-4796-8e01-e3c4041a6bff
child = replace(parent, query => replacement; loc=[8])
# ╔═╡ 3c003a65-3983-42ed-b445-5618ae21a4a3
write_cif(child, "child.cif")
# ╔═╡ caf947dc-11bd-455d-8fd6-434fa52edada
view_structure(child)
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
Bio3DView = "99c8bb3a-9d13-5280-9740-b4880ed9c598"
PoreMatMod = "2de0d7f0-0963-4438-8bc8-7e7ffe3dc69a"
[compat]
Bio3DView = "~0.1.3"
PoreMatMod = "~0.2.7"
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
[[ANSIColoredPrinters]]
git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c"
uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"
version = "0.0.1"
[[AbstractPlutoDingetjes]]
deps = ["Pkg"]
git-tree-sha1 = "abb72771fd8895a7ebd83d5632dc4b989b022b5b"
uuid = "6e696c72-6542-2067-7265-42206c756150"
version = "1.1.2"
[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
[[ArnoldiMethod]]
deps = ["LinearAlgebra", "Random", "StaticArrays"]
git-tree-sha1 = "62e51b39331de8911e4a7ff6f5aaf38a5f4cc0ae"
uuid = "ec485272-7323-5ecc-a04f-4719b315124d"
version = "0.2.0"
[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[BinaryProvider]]
deps = ["Libdl", "Logging", "SHA"]
git-tree-sha1 = "ecdec412a9abc8db54c0efc5548c64dfce072058"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.10"
[[Bio3DView]]
deps = ["Requires"]
git-tree-sha1 = "7f472efd9b6af772307dd017f9deeff2a243754f"
uuid = "99c8bb3a-9d13-5280-9740-b4880ed9c598"
version = "0.1.3"
[[CSV]]
deps = ["Dates", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode"]
git-tree-sha1 = "b83aa3f513be680454437a0eee21001607e5d983"
uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
version = "0.8.5"
[[CategoricalArrays]]
deps = ["DataAPI", "Future", "JSON", "Missings", "Printf", "Statistics", "StructTypes", "Unicode"]
git-tree-sha1 = "18d7f3e82c1a80dd38c16453b8fd3f0a7db92f23"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.9.7"
[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "4c26b4e9e91ca528ea212927326ece5918a04b47"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.11.2"
[[ChangesOfVariables]]
deps = ["LinearAlgebra", "Test"]
git-tree-sha1 = "9a1d594397670492219635b35a3d830b04730d62"
uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
version = "0.1.1"
[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "dce3e3fea680869eaa0b774b2e8343e9ff442313"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.40.0"
[[Conda]]
deps = ["Downloads", "JSON", "VersionParsing"]
git-tree-sha1 = "6cdc8832ba11c7695f494c9d9a1c31e90959ce0f"
uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d"
version = "1.6.0"
[[Configurations]]
deps = ["ExproniconLite", "OrderedCollections", "TOML"]
git-tree-sha1 = "79e812c535bb9780ba00f3acba526bde5652eb13"
uuid = "5218b696-f38b-4ac9-8b61-a12ec717816d"
version = "0.16.6"
[[Crayons]]
git-tree-sha1 = "3f71217b538d7aaee0b69ab47d9b7724ca8afa0d"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.0.4"
[[DataAPI]]
git-tree-sha1 = "cc70b17275652eb47bc9e5f81635981f13cea5c8"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.9.0"
[[DataFrames]]
deps = ["CategoricalArrays", "Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "d50972453ef464ddcebdf489d11885468b7b83a3"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "0.22.7"
[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "7d9d316f04214f7efdbb6398d545446e246eff02"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.10"
[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"
[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "b19534d1895d702889b219c382a6e18010797f0b"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.6"
[[Documenter]]
deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "f425293f7e0acaf9144de6d731772de156676233"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.27.10"
[[Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
[[ExproniconLite]]
git-tree-sha1 = "8b08cc88844e4d01db5a2405a08e9178e19e479e"
uuid = "55351af7-c7e9-48d6-89ff-24e801d99491"
version = "0.6.13"
[[FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "2db648b6712831ecb333eae76dbfd1c156ca13bb"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.11.2"
[[FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
[[Formatting]]
deps = ["Printf"]
git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8"
uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
version = "0.4.2"
[[FromFile]]
git-tree-sha1 = "81e918d0ed5978fcdacd06b7c64c0c5074c4d55a"
uuid = "ff7dd447-1dcb-4ce3-b8ac-22a812192de7"
version = "0.1.2"
[[Future]]
deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
[[FuzzyCompletions]]
deps = ["REPL"]
git-tree-sha1 = "2cc2791b324e8ed387a91d7226d17be754e9de61"
uuid = "fb4132e2-a121-4a70-b8a1-d5b831dcdcc2"
version = "0.4.3"
[[GitHubActions]]
deps = ["JSON", "Logging"]
git-tree-sha1 = "56e01ec63d13e1cf015d9ff586156eae3cc7cd6f"
uuid = "6b79fd1a-b13a-48ab-b6b0-aaee1fee41df"
version = "0.1.4"
[[Graphs]]
deps = ["ArnoldiMethod", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"]
git-tree-sha1 = "92243c07e786ea3458532e199eb3feee0e7e08eb"
uuid = "86223c79-3864-5bf0-83f7-82e725a168b6"
version = "1.4.1"
[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "0fa77022fe4b511826b39c894c90daf5fce3334a"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.17"
[[Hyperscript]]
deps = ["Test"]
git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9"
uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91"
version = "0.0.4"
[[HypertextLiteral]]
git-tree-sha1 = "2b078b5a615c6c0396c77810d92ee8c6f470d238"
uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
version = "0.9.3"
[[IOCapture]]
deps = ["Logging", "Random"]
git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
version = "0.2.2"
[[Inflate]]
git-tree-sha1 = "f5fc07d4e706b84f72d54eedcc1c13d92fb0871c"
uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
version = "0.1.2"
[[IniFile]]
deps = ["Test"]
git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8"
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
version = "0.5.0"
[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[[InverseFunctions]]
deps = ["Test"]
git-tree-sha1 = "a7254c0acd8e62f1ac75ad24d5db43f5f19f3c65"
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
version = "0.1.2"
[[InvertedIndices]]
git-tree-sha1 = "bee5f1ef5bf65df56bdd2e40447590b272a5471f"
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
version = "1.1.0"
[[IrrationalConstants]]
git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151"
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
version = "0.1.1"
[[IteratorInterfaceExtensions]]
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"
[[JLD2]]
deps = ["DataStructures", "FileIO", "MacroTools", "Mmap", "Pkg", "Printf", "Reexport", "TranscodingStreams", "UUIDs"]
git-tree-sha1 = "46b7834ec8165c541b0b5d1c8ba63ec940723ffb"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.4.15"
[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.2"
[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
[[LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
[[LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[LogExpFunctions]]
deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "be9eef9f9d78cecb6f262f3c10da151a6c5ab827"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.5"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[MacroTools]]
deps = ["Markdown", "Random"]
git-tree-sha1 = "3d3e902b31198a27340d0bf00d6ac452866021cf"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.9"
[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"]
git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.0.3"
[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
[[MetaGraphs]]
deps = ["Graphs", "JLD2", "Random"]
git-tree-sha1 = "2af69ff3c024d13bde52b34a2a7d6887d4e7b438"
uuid = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
version = "0.7.1"
[[Missings]]
deps = ["DataAPI"]
git-tree-sha1 = "f8c673ccc215eb50fcadb285f522420e29e69e1c"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "0.4.5"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
[[MsgPack]]
deps = ["Serialization"]
git-tree-sha1 = "a8cbf066b54d793b9a48c5daa5d586cf2b5bd43d"
uuid = "99f44e22-a591-53d1-9472-aa23ef4bd671"
version = "1.1.0"
[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
[[OrderedCollections]]
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.4.1"
[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "bfd7d8c7fd87f04543810d9cbd3995972236ba1b"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.1.2"
[[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
[[Pluto]]
deps = ["Base64", "Configurations", "Dates", "Distributed", "FileWatching", "FuzzyCompletions", "HTTP", "InteractiveUtils", "Logging", "Markdown", "MsgPack", "Pkg", "REPL", "Sockets", "TableIOInterface", "Tables", "UUIDs"]
git-tree-sha1 = "669c67f837da26719ff9102cd9b193e0d2114472"
uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
version = "0.17.3"
[[PlutoSliderServer]]
deps = ["Base64", "Configurations", "Distributed", "FromFile", "GitHubActions", "HTTP", "Logging", "Pkg", "Pluto", "SHA", "Sockets", "TOML", "UUIDs"]
git-tree-sha1 = "ed9660bb2c9eee9d389601bd80a10cee3dd64f0b"
uuid = "2fc8631c-6f24-4c5b-bca7-cbb509c42db4"
version = "0.2.7"
[[PlutoUI]]
deps = ["AbstractPlutoDingetjes", "Base64", "Dates", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "UUIDs"]
git-tree-sha1 = "b68904528fd538f1cb6a3fbc44d2abdc498f9e8e"
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
version = "0.7.21"
[[PooledArrays]]
deps = ["DataAPI", "Future"]
git-tree-sha1 = "db3a23166af8aebf4db5ef87ac5b00d36eb771e2"
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
version = "1.4.0"
[[PoreMatMod]]
deps = ["Bio3DView", "CSV", "DataFrames", "Graphs", "LinearAlgebra", "MetaGraphs", "Pluto", "PlutoSliderServer", "PlutoUI", "Reexport", "StatsBase", "Xtals"]
git-tree-sha1 = "53bccf1b4a3c0b5e3c7d70cbc93a6bbda802edaa"
uuid = "2de0d7f0-0963-4438-8bc8-7e7ffe3dc69a"
version = "0.2.7"
[[PrettyTables]]
deps = ["Crayons", "Formatting", "Markdown", "Reexport", "Tables"]
git-tree-sha1 = "574a6b3ea95f04e8757c0280bb9c29f1a5e35138"
uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
version = "0.11.1"
[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
[[PyCall]]
deps = ["Conda", "Dates", "Libdl", "LinearAlgebra", "MacroTools", "Serialization", "VersionParsing"]
git-tree-sha1 = "4ba3651d33ef76e24fef6a598b63ffd1c5e1cd17"
uuid = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
version = "1.92.5"
[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.2.2"
[[Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.1.3"
[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
[[SentinelArrays]]
deps = ["Dates", "Random"]
git-tree-sha1 = "f45b34656397a1f6e729901dc9ef679610bd12b5"
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
version = "1.3.8"
[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
[[SimpleTraits]]
deps = ["InteractiveUtils", "MacroTools"]
git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231"
uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
version = "0.9.4"
[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[SortingAlgorithms]]
deps = ["DataStructures", "Random", "Test"]
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "0.3.1"
[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "3c76dde64d03699e074ac02eb2e8ba8254d428da"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.2.13"
[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
[[StatsAPI]]
git-tree-sha1 = "0f2aa8e32d511f758a2ce49208181f7733a0936a"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
version = "1.1.0"
[[StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "2bb0cb32026a66037360606510fca5984ccc6b75"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.13"
[[StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "d24a825a95a6d98c385001212dc9020d609f2d4f"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.8.1"
[[TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
[[TableIOInterface]]
git-tree-sha1 = "9a0d3ab8afd14f33a35af7391491ff3104401a35"
uuid = "d1efa939-5518-4425-949f-ab857e148477"
version = "0.1.6"
[[TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"
[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "fed34d0e71b91734bf0a7e10eb1bb05296ddbcd0"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.6.0"
[[Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
[[Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[TranscodingStreams]]
deps = ["Random", "Test"]
git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.9.6"
[[URIs]]
git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.3.0"
[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[[VersionParsing]]
git-tree-sha1 = "e575cf85535c7c3292b4d89d89cc29e8c3098e47"
uuid = "81def892-9a0e-5fdd-b105-ffc91e053289"
version = "1.2.1"
[[Xtals]]
deps = ["Bio3DView", "CSV", "DataFrames", "Documenter", "Graphs", "JLD2", "LinearAlgebra", "Logging", "MetaGraphs", "Printf", "PyCall", "UUIDs"]
git-tree-sha1 = "3147503cd35c4f2b3744fe36301c7de3efee98c5"
uuid = "ede5f01d-793e-4c47-9885-c447d1f18d6d"
version = "0.3.9"
[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
[[nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
[[p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
"""
# ╔═╡ Cell order:
# ╠═2065e50f-1bba-4182-ae16-70feecaa1942
# ╠═5e702404-3665-411e-a4d2-cb7fba303c91
# ╠═52318187-a575-4864-8185-416faeea27ab
# ╠═6922e27b-b848-418b-bf1a-df17315baa80
# ╠═418a7421-92ed-406f-9578-34187529c307
# ╠═f7d3cb8c-9d12-4f78-94c6-30a308648e69
# ╠═90f53a39-89b3-41c5-ad8b-c0683b96c9e4
# ╠═58b79260-8a7a-4ca4-bdee-4c3c463334ba
# ╠═b835a642-0a24-4796-8e01-e3c4041a6bff
# ╠═3c003a65-3983-42ed-b445-5618ae21a4a3
# ╠═caf947dc-11bd-455d-8fd6-434fa52edada
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 3853 | ### A Pluto.jl notebook ###
# v0.17.3
using Markdown
using InteractiveUtils
# ╔═╡ 5b182574-5656-4035-85c1-89d1c92ff719
begin
import Pkg
Pkg.add(; url="https://github.com/SimonEnsemble/PoreMatMod.jl")
end
# ╔═╡ 1a73bdc4-9394-4212-9ae8-3b8654a496c0
using PoreMatMod
# ╔═╡ f05cdf05-1661-41c7-863d-15a436791ac4
using PoreMatMod.ExampleHelpers
# ╔═╡ 0b644231-c25a-4d9f-895d-16fc612613ec
md"# Azepine"
# ╔═╡ 916b9bc9-c6c9-444b-9281-e3709c248b75
begin
benzodiazepine_parent = moiety("benzodiazepine.xyz")
remove_bonds!(benzodiazepine_parent)
local new_box = replicate(unit_cube(), (20, 20, 20))
local new_atoms =
Frac(Cart(benzodiazepine_parent.atoms, benzodiazepine_parent.box), new_box)
local new_charges =
Frac(Cart(benzodiazepine_parent.charges, benzodiazepine_parent.box), new_box)
benzodiazepine_parent =
Crystal(benzodiazepine_parent.name, new_box, new_atoms, new_charges)
infer_bonds!(benzodiazepine_parent, false)
benzo_fragment = moiety("benzo_fragment.xyz")
chloro_benzo_fragment = moiety("chloro_benzo_fragment.xyz")
diazepine_fragment = moiety("diazepine_fragment.xyz")
N_methyl_diazepine = moiety("N_methyl_diazepine.xyz")
end
# ╔═╡ da1f22fb-8e16-439b-934a-280ed31635df
begin
intermediate = replace(benzodiazepine_parent, diazepine_fragment => N_methyl_diazepine)
diazepam = replace(intermediate, benzo_fragment => chloro_benzo_fragment)
end
# ╔═╡ 7d73fa2e-9ee5-4002-97a6-496f4d186512
begin
local temp = deepcopy(intermediate)
translate_by!(temp.atoms.coords, Frac([0.5, 0.5, 0.5]))
wrap!(temp)
write_cif(temp, "intermediate.cif")
local temp = deepcopy(diazepam)
translate_by!(temp.atoms.coords, Frac([0.5, 0.5, 0.5]))
wrap!(temp)
write_cif(temp, "diazepam.cif")
end
# ╔═╡ 6fe41bf5-cf36-4313-8886-cfca2825c6cd
md"# Slab"
# ╔═╡ faff7bea-0d3a-45fe-8a88-b288b390e35b
function read_poscar(filename::String)::Crystal
filedata = readlines(filename)
box_matrix =
Matrix(reduce(hcat, [parse.(Float64, row) for row in split.(filedata[3:5])])')
species = Symbol.(split(filedata[6]))
atom_counts = parse.(Int, split(filedata[7]))
nb_atoms = sum(atom_counts)
species_vec = reduce(
vcat,
[[element for _ in 1:atom_counts[i]] for (i, element) in enumerate(species)]
)
box = Box(box_matrix)
coords = Frac(
reduce(hcat, [parse.(Float64, row) for row in split.(filedata[9:(nb_atoms + 8)])])
)
atoms = Atoms(nb_atoms, species_vec, coords)
charges = Charges(nb_atoms, zeros(nb_atoms), coords)
return Crystal(filename, box, atoms, charges)
end
# ╔═╡ db771098-8097-4748-85c7-ece4faed4e43
begin
poscar = read_poscar("data/crystals/POSCAR")
infer_bonds!(poscar, true)
end
# ╔═╡ 35c1c1d5-ea01-4d15-80c3-63330744b037
write_cif(poscar, "poscar.cif")
# ╔═╡ b09ea1c5-67b5-4953-8fef-c5144f09186b
hydrated_Pd2 = moiety("hydrated_Pd2.xyz")
# ╔═╡ b7a6a162-39cc-4137-b803-94c2a5326b6e
OA_Pd2 = moiety("OA_Pd2.xyz")
# ╔═╡ e232cfc8-a954-4089-be59-a9fa5b3a2736
oxidative_addition = replace(poscar, hydrated_Pd2 => OA_Pd2)
# ╔═╡ 908ab709-c12a-455b-994b-89e600d47b06
write_cif(oxidative_addition, "oxidative_addition.cif")
# ╔═╡ Cell order:
# ╟─5b182574-5656-4035-85c1-89d1c92ff719
# ╠═1a73bdc4-9394-4212-9ae8-3b8654a496c0
# ╠═f05cdf05-1661-41c7-863d-15a436791ac4
# ╟─0b644231-c25a-4d9f-895d-16fc612613ec
# ╠═916b9bc9-c6c9-444b-9281-e3709c248b75
# ╠═da1f22fb-8e16-439b-934a-280ed31635df
# ╠═7d73fa2e-9ee5-4002-97a6-496f4d186512
# ╟─6fe41bf5-cf36-4313-8886-cfca2825c6cd
# ╠═faff7bea-0d3a-45fe-8a88-b288b390e35b
# ╠═db771098-8097-4748-85c7-ece4faed4e43
# ╠═35c1c1d5-ea01-4d15-80c3-63330744b037
# ╠═b09ea1c5-67b5-4953-8fef-c5144f09186b
# ╠═b7a6a162-39cc-4137-b803-94c2a5326b6e
# ╠═e232cfc8-a954-4089-be59-a9fa5b3a2736
# ╠═908ab709-c12a-455b-994b-89e600d47b06
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 5936 | module ExampleHelpers
using Graphs, Logging, Markdown, Reexport, MetaGraphs, LinearAlgebra
using Bio3DView: viewfile
@reexport using Xtals
include("moiety.jl")
function __init__()
# list of required files for examples
global required_files = Dict(
:crystals => [
"IRMOF-1.cif",
"SIFSIX-2-Cu-i.cif",
"IRMOF-1_noH.cif",
"UiO-66.cif",
"NiPyC_fragment_trouble.cif"
],
:moieties => [
"2-!-p-phenylene.xyz",
"2-acetylamido-p-phenylene.xyz",
"1,4-C-phenylene_noH.xyz",
"1,4-C-phenylene.xyz",
"4-pyridyl.xyz",
"acetylene.xyz",
"BDC.xyz",
"disordered_ligand!.xyz",
"formate_caps.xyz",
"SBU.xyz"
]
)
rc[:r_tag] = '!'
return rc[:paths][:moieties] = joinpath(rc[:paths][:data], "moieties")
end
function check_example_data()
# make sure directories are present and the right files for the examples
for file_type in [:moieties, :crystals]
# make sure directories exist
if !isdir(rc[:paths][file_type])
@warn "$(rc[:paths][file_type]) directory not present; creating it."
mkpath(rc[:paths][file_type])
end
for required_file in required_files[file_type]
where_it_shld_be = joinpath(rc[:paths][file_type], required_file)
if !isfile(where_it_shld_be)
@warn "$where_it_shld_be not present; copying it from src."
where_it_is = normpath(
joinpath(
@__DIR__,
"..",
"examples",
"data",
String(file_type),
required_file
)
)
cp(where_it_is, where_it_shld_be)
end
end
end
end
function input_file_message()
return md"""
!!! note \"input files for the example Pluto notebooks\"
if the input files required for the example Pluto notebooks are not present in the correct folders, `ExampleHelpers` automatically copies the required input files from the `examples/data` directory of the `PoreMatMod.jl` source code to the folders `rc[:paths][:crystals]` and `rc[:paths][:moieties]`. all input files for the examples are also on Github [here](https://github.com/SimonEnsemble/PoreMatMod.jl/tree/master/examples/data).
n.b. you may change the folders from which `PoreMatMod.jl` reads input files by setting `rc[:paths][:crystals]` and `rc[:paths][:moieties]` as the desired path. for example, if you desire to store your crystal structures in a folder `~/my_xtals/` (a folder in your home directory), set:
```julia
rc[:paths][:crystals] = joinpath(homedir(), \"my_xtals\").
```
"""
end
function xtal_folder_message()
return md"""
📕 folder from which `PoreMatMod.jl` reads `.cif` files that represent crystal structures:
"""
end
function moiety_folder_message()
return md"""
📕 folder from which `PoreMatMod.jl` reads `.xyz` files that represent fragments/moities:
"""
end
function fragment_construction_note()
return md"""
!!! note \"how can we construct the query/replacement fragments?\"
two options we use: (1) use Avogadro as a molecule builder/editor and export it as `.xyz` or (2) cut the appropriate fragment out of the MOF crystal structure in the `.cif` file using e.g. iRASPA.
"""
end
write_cif_message() = md"""
write the child crystal structure to file for downstream molecular simulations
"""
# function to visualize a crystal in the notebook
function view_structure(xtal::Crystal; drop_cross_pb=true)
# write the box mesh
write_vtk(xtal.box, "temp_unit_cell.vtk")
# drop symmetry info and charges
x = deepcopy(
Crystal(
xtal.name,
xtal.box,
xtal.atoms,
Charges{Frac}(0),
xtal.bonds,
Xtals.SymmetryInfo()
)
)
# drop cross-boundary bonds (they don't render correctly)
if drop_cross_pb
# drop the cross-boundary bonds
drop_cross_pb_bonds!(x)
end
write_mol2(x; filename="temp_view.mol2")
output = nothing
try
output = viewfile("temp_view.mol2", "mol2"; vtkcell="temp_unit_cell.vtk")
catch
output = viewfile("temp_view.mol2", "mol2"; vtkcell="temp_unit_cell.vtk", html=true)
finally
rm("temp_unit_cell.vtk")
rm("temp_view.mol2")
end
return output
end
# function to visualize a moiety in the notebook
function view_query_or_replacement(filename::String)
moty = moiety(filename) # load the moiety
for i in 1:(moty.atoms.n) # fix H! atom bonding bug (tagged atom covalent radius too large in JMol)
if moty.atoms.species[i] == :H!
moty.atoms.species[i] = :He
end
if moty.atoms.species[i] == :C!
moty.atoms.species[i] = :Ne
end
end
# write temporary modified file, view it, and delete it
filename = joinpath(rc[:paths][:moieties], "temp_" * filename)
write_xyz(moty, filename)
output = nothing
try
output = viewfile(filename, "xyz")
catch
output = viewfile(filename, "xyz"; html=true)
finally
rm(filename)
end
return output
end
# function to print the contents of a moiety file
function display_query_or_replacement_file(filename::String)
filename = joinpath(rc[:paths][:moieties], filename)
println("contents of: ", filename, "\n")
open(filename, "r") do io
return print(read(io, String))
end
end
export display_query_or_replacement_file,
view_query_or_replacement,
view_structure,
write_cif_message,
xtal_folder_message,
moiety_folder_message,
fragment_construction_note,
input_file_message,
check_example_data
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 700 | module PoreMatMod
using DataFrames, Graphs, LinearAlgebra, MetaGraphs, Pluto, Reexport, StatsBase
@reexport using Xtals
using PrecompileSignatures: @precompile_signatures
import Base.(∈), Base.show, Base.replace
__init__() = add_bonding_rules(tagged_bonding_rules())
export
# search.jl
Search,
substructure_search,
nb_isomorphisms,
nb_locations,
nb_ori_at_loc,
isomorphic_substructures,
# replace.jl
substructure_replace,
# moiety.jl
moiety,
# misc.jl
PoreMatModGO
include("Ullmann.jl")
include("moiety.jl")
include("search.jl")
include("replace.jl")
include("ExampleHelpers.jl")
include("misc.jl")
@precompile_signatures(PoreMatMod)
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 25484 | ### A Pluto.jl notebook ###
# v0.18.2
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local iv = try
Base.loaded_modules[Base.PkgId(
Base.UUID("6e696c72-6542-2067-7265-42206c756150"),
"AbstractPlutoDingetjes"
)].Bonds.initial_value
catch
b -> missing
end
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
el
end
end
# ╔═╡ 6c1969e0-02f5-11eb-3fa2-09931a63b1ac
begin
using PoreMatMod, PlutoUI, Bio3DView
HOME = joinpath(homedir(), ".PoreMatModGO")
rc[:paths][:crystals] = HOME
rc[:paths][:moieties] = HOME
if !isdir(HOME)
mkdir(HOME)
end
cd(HOME)
md"""
# 💠 PoreMatModGO 🚀
This notebook interactively substitutes moieties within a crystal using a modified implementation of Ullmann's algorithm to perform substructure searches and applying singular value decomposition to align fragments of the generated materials. Read the docs [here](SimonEnsemble.github.io/PoreMatMod.jl).
See the original publication on PoreMatMod.jl here: [(article)](https://doi.org/10.33774/chemrxiv-2021-vx5r3) [(GitHub)](https://github.com/SimonEnsemble/PoreMatMod.jl)
"""
end
# ╔═╡ 5dc43a20-10b8-11eb-26dc-7fb98e9aeb1a
md"""
Adrian Henle, [Simon Ensemble](http://simonensemble.github.io), 2021
$(Resource("https://simonensemble.github.io/osu_logo.jpg", :width => 250))
"""
# ╔═╡ 90696d20-10b7-11eb-20b5-6174faeaf613
@bind load_inputs Button("Reset")
# ╔═╡ 50269ffe-02ef-11eb-0614-f11975d991fe
begin
load_inputs
# input fields: query, replacement, xtal
md"""
##### Input Files
Parent Crystal $(@bind parent_crystal FilePicker())
Search Moiety $(@bind search_moiety FilePicker())
Replace Moiety $(@bind replace_moiety FilePicker())
"""
end
# ╔═╡ 33b1fb50-0f73-11eb-2ab2-9d2cb6c5a533
# write file input strings to files in temp directory
begin
# dict for tracking load status of inputs
isloaded = Dict([:replacement => false, :query => false, :parent => false])
# replacement loader
if !isnothing(replace_moiety)
write("replacement.xyz", replace_moiety["data"])
replacement = moiety("replacement.xyz")
isloaded[:replacement] = true
end
# query loader
if !isnothing(search_moiety)
write("query.xyz", search_moiety["data"])
query = moiety("query.xyz")
isloaded[:query] = true
end
# xtal loader
if !isnothing(parent_crystal)
write("parent.cif", parent_crystal["data"])
xtal = Crystal("parent.cif"; check_overlap=false)
Xtals.strip_numbers_from_atom_labels!(xtal)
infer_bonds!(xtal, true)
isloaded[:parent] = true
end
# run search and display terminal message
if isloaded[:query] && isloaded[:parent]
search = query ∈ xtal
with_terminal() do
@info "Search Results" isomorphisms = nb_isomorphisms(search) locations =
nb_locations(search)
end
end
end
# ╔═╡ 415e9210-0f71-11eb-15c8-e7484b5be309
# choose replacement type
if all(values(isloaded))
md"""
### Find/Replace Options
Mode $(@bind replace_mode Select(["", "random replacement at each location", "random replacement at n random locations", "random replacement at specific locations", "specific replacements"]))
"""
end
# ╔═╡ 3997c4d0-0f75-11eb-2976-c161879b8d0c
# options populated w/ conditional logic based on mode selection
if all(values(isloaded))
local output = nothing
x = ["$(x)" for x in 1:nb_locations(search)]
if replace_mode == "random replacement at each location"
output = nothing
elseif replace_mode == "random replacement at n random locations"
output = md"Number of locations $(@bind nb_loc Slider(1:nb_locations(search)))"
elseif replace_mode == "random replacement at specific locations"
output = md"Locations $(@bind loc MultiSelect(x))"
elseif replace_mode == "specific replacements"
output = md"""
Locations $(@bind loc MultiSelect(x))
Orientations $(@bind ori TextField())
"""
end
output
end
# ╔═╡ 69edca20-0f94-11eb-13ba-334438ca2406
if all(values(isloaded))
new_xtal_flag = true
if replace_mode == "random replacement at each location"
new_xtal = substructure_replace(search, replacement)
elseif replace_mode == "random replacement at n random locations" && nb_loc > 0
new_xtal = substructure_replace(search, replacement; nb_loc=nb_loc)
elseif replace_mode == "random replacement at specific locations" && loc ≠ []
new_xtal =
substructure_replace(search, replacement; loc=[parse(Int, x) for x in loc])
elseif replace_mode == "specific replacements"
if loc ≠ [] && ori ≠ "" && length(loc) == length(split(ori, ","))
new_xtal = substructure_replace(
search,
replacement;
loc=[parse(Int, x) for x in loc],
ori=[parse(Int, x) for x in split(ori, ",")]
)
else
new_xtal_flag = false
end
else
new_xtal_flag = false
end
if new_xtal_flag
with_terminal() do
if replace_mode == "random replacement at each location"
@info replace_mode new_xtal
elseif replace_mode == "random replacement at n random locations"
@info replace_mode nb_loc new_xtal
elseif replace_mode == "random replacement at specific locations"
@info replace_mode loc new_xtal
elseif replace_mode == "specific replacements"
@info replace_mode loc ori new_xtal
end
end
end
end;
# ╔═╡ 5918f770-103d-11eb-0537-81036bd3e675
if all(values(isloaded)) && new_xtal_flag
write_cif(new_xtal, "crystal.cif")
write_xyz(new_xtal, "atoms.xyz")
write_vtk(new_xtal.box, "unit_cell.vtk")
write_bond_information(new_xtal, "bonds.vtk")
no_pb = deepcopy(new_xtal)
drop_cross_pb_bonds!(no_pb)
write_mol2(new_xtal; filename="crystal.mol2")
write_mol2(no_pb; filename="view.mol2")
viewfile("view.mol2", "mol2"; vtkcell="unit_cell.vtk", axes=Axes(4, 0.25))
end
# ╔═╡ 31832e30-1054-11eb-24ed-219fd3e236a1
if all(values(isloaded)) && new_xtal_flag
download_cif = DownloadButton(read("crystal.cif"), "crystal.cif")
download_box = DownloadButton(read("unit_cell.vtk"), "unit_cell.vtk")
download_xyz = DownloadButton(read("atoms.xyz"), "atoms.xyz")
download_bonds = DownloadButton(read("bonds.vtk"), "bonds.vtk")
download_mol2 = DownloadButton(read("crystal.mol2"), "crystal.mol2")
md"""
### Output Files
Complete Crystal $download_mol2 $download_cif
Components $download_xyz $download_bonds $download_box
"""
end
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
Bio3DView = "99c8bb3a-9d13-5280-9740-b4880ed9c598"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
PoreMatMod = "2de0d7f0-0963-4438-8bc8-7e7ffe3dc69a"
[compat]
Bio3DView = "~0.1.3"
PlutoUI = "~0.7.14"
PoreMatMod = "~0.2.0"
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
[[ANSIColoredPrinters]]
git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c"
uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"
version = "0.0.1"
[[AbstractPlutoDingetjes]]
deps = ["Pkg"]
git-tree-sha1 = "abb72771fd8895a7ebd83d5632dc4b989b022b5b"
uuid = "6e696c72-6542-2067-7265-42206c756150"
version = "1.1.2"
[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
[[ArnoldiMethod]]
deps = ["LinearAlgebra", "Random", "StaticArrays"]
git-tree-sha1 = "62e51b39331de8911e4a7ff6f5aaf38a5f4cc0ae"
uuid = "ec485272-7323-5ecc-a04f-4719b315124d"
version = "0.2.0"
[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[BinaryProvider]]
deps = ["Libdl", "Logging", "SHA"]
git-tree-sha1 = "ecdec412a9abc8db54c0efc5548c64dfce072058"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.10"
[[Bio3DView]]
deps = ["Requires"]
git-tree-sha1 = "7f472efd9b6af772307dd017f9deeff2a243754f"
uuid = "99c8bb3a-9d13-5280-9740-b4880ed9c598"
version = "0.1.3"
[[CSV]]
deps = ["Dates", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode"]
git-tree-sha1 = "b83aa3f513be680454437a0eee21001607e5d983"
uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
version = "0.8.5"
[[CategoricalArrays]]
deps = ["DataAPI", "Future", "JSON", "Missings", "Printf", "Statistics", "StructTypes", "Unicode"]
git-tree-sha1 = "18d7f3e82c1a80dd38c16453b8fd3f0a7db92f23"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.9.7"
[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "f885e7e7c124f8c92650d61b9477b9ac2ee607dd"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.11.1"
[[ChangesOfVariables]]
deps = ["LinearAlgebra", "Test"]
git-tree-sha1 = "9a1d594397670492219635b35a3d830b04730d62"
uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
version = "0.1.1"
[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "dce3e3fea680869eaa0b774b2e8343e9ff442313"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.40.0"
[[CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
[[Conda]]
deps = ["JSON", "VersionParsing"]
git-tree-sha1 = "299304989a5e6473d985212c28928899c74e9421"
uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d"
version = "1.5.2"
[[Configurations]]
deps = ["ExproniconLite", "OrderedCollections", "TOML"]
git-tree-sha1 = "79e812c535bb9780ba00f3acba526bde5652eb13"
uuid = "5218b696-f38b-4ac9-8b61-a12ec717816d"
version = "0.16.6"
[[Crayons]]
git-tree-sha1 = "3f71217b538d7aaee0b69ab47d9b7724ca8afa0d"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.0.4"
[[DataAPI]]
git-tree-sha1 = "cc70b17275652eb47bc9e5f81635981f13cea5c8"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.9.0"
[[DataFrames]]
deps = ["CategoricalArrays", "Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "d50972453ef464ddcebdf489d11885468b7b83a3"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "0.22.7"
[[DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "7d9d316f04214f7efdbb6398d545446e246eff02"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.10"
[[DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"
[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "b19534d1895d702889b219c382a6e18010797f0b"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.6"
[[Documenter]]
deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "f425293f7e0acaf9144de6d731772de156676233"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.27.10"
[[Downloads]]
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
[[ExproniconLite]]
git-tree-sha1 = "8b08cc88844e4d01db5a2405a08e9178e19e479e"
uuid = "55351af7-c7e9-48d6-89ff-24e801d99491"
version = "0.6.13"
[[FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "2db648b6712831ecb333eae76dbfd1c156ca13bb"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.11.2"
[[FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
[[Formatting]]
deps = ["Printf"]
git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8"
uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
version = "0.4.2"
[[FromFile]]
git-tree-sha1 = "81e918d0ed5978fcdacd06b7c64c0c5074c4d55a"
uuid = "ff7dd447-1dcb-4ce3-b8ac-22a812192de7"
version = "0.1.2"
[[Future]]
deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
[[FuzzyCompletions]]
deps = ["REPL"]
git-tree-sha1 = "2cc2791b324e8ed387a91d7226d17be754e9de61"
uuid = "fb4132e2-a121-4a70-b8a1-d5b831dcdcc2"
version = "0.4.3"
[[GitHubActions]]
deps = ["JSON", "Logging"]
git-tree-sha1 = "56e01ec63d13e1cf015d9ff586156eae3cc7cd6f"
uuid = "6b79fd1a-b13a-48ab-b6b0-aaee1fee41df"
version = "0.1.4"
[[Graphs]]
deps = ["ArnoldiMethod", "DataStructures", "Distributed", "Inflate", "LinearAlgebra", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics"]
git-tree-sha1 = "92243c07e786ea3458532e199eb3feee0e7e08eb"
uuid = "86223c79-3864-5bf0-83f7-82e725a168b6"
version = "1.4.1"
[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "0fa77022fe4b511826b39c894c90daf5fce3334a"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.17"
[[Hyperscript]]
deps = ["Test"]
git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9"
uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91"
version = "0.0.4"
[[HypertextLiteral]]
git-tree-sha1 = "2b078b5a615c6c0396c77810d92ee8c6f470d238"
uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
version = "0.9.3"
[[IOCapture]]
deps = ["Logging", "Random"]
git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
version = "0.2.2"
[[Inflate]]
git-tree-sha1 = "f5fc07d4e706b84f72d54eedcc1c13d92fb0871c"
uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
version = "0.1.2"
[[IniFile]]
deps = ["Test"]
git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8"
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
version = "0.5.0"
[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[[InverseFunctions]]
deps = ["Test"]
git-tree-sha1 = "a7254c0acd8e62f1ac75ad24d5db43f5f19f3c65"
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
version = "0.1.2"
[[InvertedIndices]]
git-tree-sha1 = "bee5f1ef5bf65df56bdd2e40447590b272a5471f"
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
version = "1.1.0"
[[IrrationalConstants]]
git-tree-sha1 = "7fd44fd4ff43fc60815f8e764c0f352b83c49151"
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
version = "0.1.1"
[[IteratorInterfaceExtensions]]
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"
[[JLD2]]
deps = ["DataStructures", "FileIO", "MacroTools", "Mmap", "Pkg", "Printf", "Reexport", "TranscodingStreams", "UUIDs"]
git-tree-sha1 = "46b7834ec8165c541b0b5d1c8ba63ec940723ffb"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.4.15"
[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.2"
[[LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
[[LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
[[LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
[[LinearAlgebra]]
deps = ["Libdl", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[LogExpFunctions]]
deps = ["ChainRulesCore", "ChangesOfVariables", "DocStringExtensions", "InverseFunctions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "be9eef9f9d78cecb6f262f3c10da151a6c5ab827"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.5"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[MacroTools]]
deps = ["Markdown", "Random"]
git-tree-sha1 = "3d3e902b31198a27340d0bf00d6ac452866021cf"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.9"
[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"]
git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.0.3"
[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
[[MetaGraphs]]
deps = ["Graphs", "JLD2", "Random"]
git-tree-sha1 = "2af69ff3c024d13bde52b34a2a7d6887d4e7b438"
uuid = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
version = "0.7.1"
[[Missings]]
deps = ["DataAPI"]
git-tree-sha1 = "f8c673ccc215eb50fcadb285f522420e29e69e1c"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "0.4.5"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
[[MsgPack]]
deps = ["Serialization"]
git-tree-sha1 = "a8cbf066b54d793b9a48c5daa5d586cf2b5bd43d"
uuid = "99f44e22-a591-53d1-9472-aa23ef4bd671"
version = "1.1.0"
[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
[[OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
[[OrderedCollections]]
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.4.1"
[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "bfd7d8c7fd87f04543810d9cbd3995972236ba1b"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.1.2"
[[Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
[[Pluto]]
deps = ["Base64", "Configurations", "Dates", "Distributed", "FileWatching", "FuzzyCompletions", "HTTP", "InteractiveUtils", "Logging", "Markdown", "MsgPack", "Pkg", "REPL", "Sockets", "TableIOInterface", "Tables", "UUIDs"]
git-tree-sha1 = "a5b3fee95de0c0a324bab53a03911395936d15d9"
uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
version = "0.17.2"
[[PlutoSliderServer]]
deps = ["Base64", "Configurations", "Distributed", "FromFile", "GitHubActions", "HTTP", "Logging", "Pkg", "Pluto", "SHA", "Sockets", "TOML", "UUIDs"]
git-tree-sha1 = "ed9660bb2c9eee9d389601bd80a10cee3dd64f0b"
uuid = "2fc8631c-6f24-4c5b-bca7-cbb509c42db4"
version = "0.2.7"
[[PlutoUI]]
deps = ["AbstractPlutoDingetjes", "Base64", "Dates", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "UUIDs"]
git-tree-sha1 = "b68904528fd538f1cb6a3fbc44d2abdc498f9e8e"
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
version = "0.7.21"
[[PooledArrays]]
deps = ["DataAPI", "Future"]
git-tree-sha1 = "db3a23166af8aebf4db5ef87ac5b00d36eb771e2"
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
version = "1.4.0"
[[PoreMatMod]]
deps = ["Bio3DView", "CSV", "DataFrames", "Graphs", "LinearAlgebra", "MetaGraphs", "PlutoSliderServer", "PlutoUI", "Reexport", "StatsBase", "Xtals"]
git-tree-sha1 = "e4b40bedba7a4aadefe93b52b809de10539bc915"
uuid = "2de0d7f0-0963-4438-8bc8-7e7ffe3dc69a"
version = "0.2.6"
[[PrettyTables]]
deps = ["Crayons", "Formatting", "Markdown", "Reexport", "Tables"]
git-tree-sha1 = "574a6b3ea95f04e8757c0280bb9c29f1a5e35138"
uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
version = "0.11.1"
[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
[[PyCall]]
deps = ["Conda", "Dates", "Libdl", "LinearAlgebra", "MacroTools", "Serialization", "VersionParsing"]
git-tree-sha1 = "4ba3651d33ef76e24fef6a598b63ffd1c5e1cd17"
uuid = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
version = "1.92.5"
[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[[Random]]
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.2.2"
[[Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.1.3"
[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
[[SentinelArrays]]
deps = ["Dates", "Random"]
git-tree-sha1 = "f45b34656397a1f6e729901dc9ef679610bd12b5"
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
version = "1.3.8"
[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
[[SimpleTraits]]
deps = ["InteractiveUtils", "MacroTools"]
git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231"
uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
version = "0.9.4"
[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[SortingAlgorithms]]
deps = ["DataStructures", "Random", "Test"]
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "0.3.1"
[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "3c76dde64d03699e074ac02eb2e8ba8254d428da"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.2.13"
[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
[[StatsAPI]]
git-tree-sha1 = "0f2aa8e32d511f758a2ce49208181f7733a0936a"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
version = "1.1.0"
[[StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "2bb0cb32026a66037360606510fca5984ccc6b75"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.13"
[[StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "d24a825a95a6d98c385001212dc9020d609f2d4f"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.8.1"
[[TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
[[TableIOInterface]]
git-tree-sha1 = "9a0d3ab8afd14f33a35af7391491ff3104401a35"
uuid = "d1efa939-5518-4425-949f-ab857e148477"
version = "0.1.6"
[[TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"
[[Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
git-tree-sha1 = "fed34d0e71b91734bf0a7e10eb1bb05296ddbcd0"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.6.0"
[[Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
[[Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[TranscodingStreams]]
deps = ["Random", "Test"]
git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.9.6"
[[URIs]]
git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.3.0"
[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[[VersionParsing]]
git-tree-sha1 = "e575cf85535c7c3292b4d89d89cc29e8c3098e47"
uuid = "81def892-9a0e-5fdd-b105-ffc91e053289"
version = "1.2.1"
[[Xtals]]
deps = ["Bio3DView", "CSV", "DataFrames", "Documenter", "Graphs", "JLD2", "LinearAlgebra", "Logging", "MetaGraphs", "Printf", "PyCall", "UUIDs"]
git-tree-sha1 = "3147503cd35c4f2b3744fe36301c7de3efee98c5"
uuid = "ede5f01d-793e-4c47-9885-c447d1f18d6d"
version = "0.3.9"
[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
[[libblastrampoline_jll]]
deps = ["Artifacts", "Libdl", "OpenBLAS_jll"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
[[nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
[[p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
"""
# ╔═╡ Cell order:
# ╟─6c1969e0-02f5-11eb-3fa2-09931a63b1ac
# ╟─50269ffe-02ef-11eb-0614-f11975d991fe
# ╟─33b1fb50-0f73-11eb-2ab2-9d2cb6c5a533
# ╟─415e9210-0f71-11eb-15c8-e7484b5be309
# ╟─3997c4d0-0f75-11eb-2976-c161879b8d0c
# ╟─69edca20-0f94-11eb-13ba-334438ca2406
# ╟─5918f770-103d-11eb-0537-81036bd3e675
# ╟─31832e30-1054-11eb-24ed-219fd3e236a1
# ╟─5dc43a20-10b8-11eb-26dc-7fb98e9aeb1a
# ╟─90696d20-10b7-11eb-20b5-6174faeaf613
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 6853 | # "compatibility matrix"
# M₀[α, β] = 1 if any only if:
# deg(β ∈ graph) ≥ deg(α ∈ subgraph)
# and
# species(α ∈ subgraph) == species(β ∈ graph)
function compatibility_matrix(
subgraph::MetaGraph,
subgraph_species::Array{Symbol, 1},
graph::MetaGraph,
graph_species::Array{Symbol, 1},
disconnected_component::Bool
)::Array{Bool, 2}
# allocate M. rows correspond to subgraph nodes, columns to graph nodes.
M₀ = zeros(Bool, nv(subgraph), nv(graph))
# Get adjacency matrices and 4th/8th degree path matrices
adjmat_S = adjacency_matrix(subgraph)
adjmat_G = adjacency_matrix(graph)
deg_S = adjmat_S^2
deg_G = adjmat_G^2
path4_S = deg_S^2
path4_G = deg_G^2
path8_S = path4_S^2
path8_G = path4_G^2
if !disconnected_component # search for substructures
@inbounds for β in 1:nv(graph) # Loop over rows (subgraph nodes)
@inbounds for α in 1:nv(subgraph) # Loop over columns (graph nodes)
# Record Bool for each (i,j): true if atom species match, graph node degree is sufficient, and 4 and 8 length self-paths are sufficient.
M₀[α, β] =
subgraph_species[α] == graph_species[β] &&
deg_G[β, β] ≥ deg_S[α, α] &&
path4_G[β, β] ≥ path4_S[α, α] &&
path8_G[β, β] ≥ path8_S[α, α]
end
end
else # search only for exact, isolated matches (no substructures)
@inbounds for β in 1:nv(graph) # Loop over rows (subgraph nodes)
@inbounds for α in 1:nv(subgraph) # Loop over columns (graph nodes)
# Record Bool for each (i,j): true if atom species match, and graph node degree matches.
M₀[α, β] =
subgraph_species[α] == graph_species[β] && deg_G[β, β] == deg_S[α, α]
end
end
end
return M₀
end
# list of nodes β ∈ graph that could possibly correpond with node α ∈ subgraph
function candidate_list(M::Array{Bool, 2}, α::Int)::Array{Int, 1}
@inbounds @views return findall(M[α, :])
end
# does node α have possible candidate matches in the graph?
function has_candidates(M::Array{Bool, 2}, α::Int)::Bool
@inbounds return any([M[α, β] for β in 1:size(M, 2)])
end
function is_isomorphism(M::Array{Bool, 2})::Bool
# (1) each row of M, corresponding to a node α ∈ subgraph, contains exactly one 1.
# i.e., every subgraph node has exactly one correspondence
# (2) no column of M, corresponding to a node β ∈ graph, contains more than one 1.
# i.e., a graph node does not correspond to more than 1 subgraph node.
@inbounds return !(
any([sum(M[α, :]) ≠ 1 for α in 1:size(M, 1)]) || any([sum(M[:, β]) > 1 for β in 1:size(M, 2)])
)
end
# idea here:
# if any subgraph node α has no possible correspondence w/ a node β in the graph, no point in continuing
# return true iff M has no empty candidate lists for subgraph nodes.
function possibly_contains_isomorphism(M::Array{Bool, 2})::Bool
@inbounds return all([has_candidates(M, α) for α in 1:size(M, 1)])
end
function prune!(M::Array{Bool, 2}, subgraph::MetaGraph, graph::MetaGraph)
pruned = true # to enter while loop
while pruned
pruned = false
@inbounds for α in 1:size(M, 1) # loop thru subgraph nodes
# get neighbors of node α
neighbors_of_α = neighbors(subgraph, α)
# loop thru candidate matches β ∈ graph for this subgraph node α
@inbounds for β in candidate_list(M, α)
neighbors_of_β = neighbors(graph, β)
# now, suppose α ∈ subgraph and β ∈ graph correspond...
@inbounds for x in neighbors_of_α
# if there is no neighbor of β that could correspond to x, neighbor of α, then, contradiction.
if isdisjoint(candidate_list(M, x), neighbors_of_β)
M[α, β] = false
pruned = true
end
end
end
end
end
end
function assign_correspondence!(M::Array{Bool, 2}, α::Int, β::Int)
M[α, :] .= false # zero out row of subgraph node
M[:, β] .= false # zero out column of graph node
return M[α, β] = true # assign correspondence at intersection
end
# soln:
# soln[α ∈ subgraph] = β ∈ graph where α corresponds to β
function depth_first_search!(
α::Int,
subgraph::MetaGraph,
graph::MetaGraph,
M::Array{Bool, 2},
soln::Array{Int, 1},
β_mapped::Array{Bool, 1},
solns::Array{Array{Int, 1}, 1}
)
# if reached here from previous solution, exit.
if α > size(M, 1)
return nothing
end
# loop thru un-assigned graph nodes β that could possibly correspond to subnode α
@inbounds for β in candidate_list(M, α)
# if βraph is already mapped, not a viable solution.
# (not sure if necessary, i.e. if M already knows this)
if β_mapped[β]
continue
end
# make a copy so we can restore later.
M′ = deepcopy(M)
# explore scenario where α ∈ subgraph corresponds to β ∈ graph
assign_correspondence!(M′, α, β)
soln[α] = β
β_mapped[β] = true
# prune tree
prune!(M′, subgraph, graph)
# if we reached bottom of tree, iso-morphism is found!
if α == size(M′, 1)
# do we hv to check if it's a sol'n or is it guarenteed? why prune then?
if is_isomorphism(M′)
push!(solns, deepcopy(soln))
end
# don't return b/c we need to look at other candidates
end
if M′[α, β] && possibly_contains_isomorphism(M′)
# we've assigned α, go deeper in the depth first search
depth_first_search!(α + 1, subgraph, graph, M′, soln, β_mapped, solns)
end
β_mapped[β] = false
soln[α] = 0
end
end
@doc raw"""
returns an array of arrays, each containing one unique subgraph isomorphism
"""
function find_subgraph_isomorphisms(
subgraph::MetaGraph,
subgraph_species::Array{Symbol, 1},
graph::MetaGraph,
graph_species::Array{Symbol, 1},
disconnected_component::Bool=false
)
# store list of solutions here
solns = Array{Array{Int, 1}, 1}()
# encodes an isomorhism. maps α ∈ subgraph --> β ∈ graph
soln = [0 for _ in 1:nv(subgraph)]
# tell us which β ∈ graph are mapped already.
# entry β true iff β mapped
β_mapped = [false for _ in 1:nv(graph)]
# initial compatability matrix based on degrees of nodes and species
M₀ = compatibility_matrix(
subgraph,
subgraph_species,
graph,
graph_species,
disconnected_component
)
depth_first_search!(1, subgraph, graph, M₀, soln, β_mapped, solns)
return solns
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 639 | """
PoreMatModGO()
Launches the GUI Pluto notebook.
"""
function PoreMatModGO()
try
# notebook path
pmmg_ntbk = joinpath(pathof(PoreMatMod), "..", "PoreMatModGO.jl")
# run the notebook in Pluto
Pluto.run(; notebook=pmmg_ntbk)
catch
# download as a temporary file in case of access issues
pmmg_ntbk = download(
"https://raw.githubusercontent.com/SimonEnsemble/PoreMatMod.jl/master/src/PoreMatModGO.jl"
)
Pluto.run(; notebook=pmmg_ntbk)
end
end
BANNER = String(read(joinpath(dirname(pathof(PoreMatMod)), "banner.txt")))
banner() = println(BANNER)
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 4405 | """
Returns bonding rules involving R-group-tagged atoms
"""
function tagged_bonding_rules()::Array{BondingRule}
newrules = []
for rule in rc[:bonding_rules]
if rule.species_i != :*
push!(
newrules,
BondingRule(Symbol("$(rule.species_i)!"), rule.species_j, rule.max_dist)
)
push!(
newrules,
BondingRule(Symbol("$(rule.species_j)!"), rule.species_i, rule.max_dist)
)
push!(
newrules,
BondingRule(
Symbol("$(rule.species_i)!"),
Symbol("$(rule.species_j)!"),
rule.max_dist
)
)
end
end
return newrules
end
"""
Returns R group indices (whichever atoms have species symbols appended by '!')
"""
function r_group_indices(xtal::Crystal)::Array{Int}
R = []
for (idx, label) in enumerate(xtal.atoms.species) # loop over crystal atoms to find tags
# if String representation of label Symbol ends in !, atom is in R
tokens = split("$label", rc[:r_tag])
if length(tokens) == 2 && tokens[2] == "" # other ! in symbol not tolerated.
push!(R, idx)
end
end
return R
end
"""
Un-tags R group atoms (removes '!' suffix)
"""
function untag_r_group!(xtal::Crystal)
r = r_group_indices(xtal) # get indices of R group
for i in r
xtal.atoms.species[i] = Symbol(split("$(xtal.atoms.species[i])", rc[:r_tag])[1])
end
end
"""
Returns a copy of a crystal w/ R group atoms deleted
"""
function subtract_r_group(xtal::Crystal)::Crystal
not_r = [i for i in eachindex(xtal.atoms.species) if !(i ∈ r_group_indices(xtal))]
coords = xtal.atoms.coords[not_r]
species = xtal.atoms.species[not_r]
return Crystal("no_r_$(xtal.name)", xtal.box, Atoms(species, coords), xtal.charges)
end
## moiety import function (exposed)
@doc raw"""
q = moiety(xyz_filename)
Generates a moiety (`Crystal`) from an .xyz file found in `rc[:paths][:moieties]`.
Use `set_path_to_data` or set `rc[:paths][:moieties]` to change the path from which the XYZ file is read.
Atoms appended with '!' are tagged for replacement via `substructure_replace`.
Bonds are inferred automatically via `infer_bonds!`.
# Arguments
- `xyz_filename::Union{String,Nothing}` the moiety input file name, an `.xyz` file; if set to `nothing` the moiety is the null set.
- `bonding_rules::Union{Vector{BondingRule},Nothing}` (optional) a list of rules to use for inferring the bonding network of the atoms loaded from the XYZ file. If set to `nothing`, the default rules are used.
- `presort::Bool` whether to sort the atoms by bonding order for structure search efficiency. Set `false` to skip pre-sorting and maintain indexing order with source file. Does not apply to !-tagged atoms, which will still be moved to the end of the list.
"""
function moiety(
name::Union{String, Nothing};
bonding_rules::Union{Vector{BondingRule}, Nothing}=nothing,
presort::Bool=true
)::Crystal
# make box (arbitrary unit cube)
box = unit_cube()
# handle deletion option (replace-with-nothing)
if !isnothing(name)
xf = Frac(read_xyz("$(rc[:paths][:moieties])/$name"), box)
else
name = "nothing"
xf = Atoms{Frac}(0)
end
# generate Crystal from moiety XYZ coords
charges = Charges{Frac}(0)
moiety = Crystal(name, box, xf, charges)
# ID R group
R_group_indices = r_group_indices(moiety)
# handle custom vs. default bonding rules
if isnothing(bonding_rules)
infer_bonds!(moiety, false)
else
infer_bonds!(moiety, false; bonding_rules=bonding_rules)
end
# sort by node degree
sp = sortperm(degree(moiety.bonds); rev=true)
order = presort ? sp : eachindex(sp)
# ordered atoms
if length(R_group_indices) > 0
order_wo_R = order[[i for i in eachindex(order) if !(order[i] ∈ R_group_indices)]]
else
order_wo_R = order
end
# append R-group to the end
order = vcat(order_wo_R, R_group_indices)
# rebuild Atoms
atoms = Atoms(moiety.atoms.species[order], moiety.atoms.coords[order])
# nodes are sorted by bond order, and R group is moved to end & tagged w/ !
moiety = Crystal(name, box, atoms, charges)
infer_bonds!(moiety, false)
return moiety
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 18263 | """
child = replace(parent, query => replacement)
Generates a `child` crystal structure by (i) searches the `parent` crystal structure for subgraphs that match the `query` then
(ii) replaces the substructures of the `parent` matching the `query` fragment with the `replacement` fragment.
Equivalent to calling `substructure_replace(query ∈ parent, replacement)`.
Accepts the same keyword arguments as [`substructure_replace`](@ref).
"""
function replace(p::Crystal, pair::Pair; kwargs...)
return substructure_replace(pair[1] ∈ p, pair[2]; kwargs...)
end
"""
alignment = Alignment(rot::Matrix{Float64}, shift_1::Vector{Float64}, shift_2::Vector{Float64}, err::Float64)
Data structure for tracking alignment in substructure find/replace operations.
"""
struct Alignment
rot::Matrix{Float64}
# before rotation
shift_1::Vector{Float64}
# after rotation
shift_2::Vector{Float64}
# error
err::Float64
end
struct Installation
aligned_replacement::Crystal
q2p::Dict{Int, Int}
r2p::Dict{Int, Int}
end
function get_r2p_alignment(
replacement::Crystal,
parent::Crystal,
r2p::Dict{Int, Int},
q2p::Dict{Int, Int}
)
center = (X::Matrix{Float64}) -> sum(X; dims=2)[:] / size(X, 2)
# when both centered to origin
@assert replacement.atoms.n ≥ 3 && parent.atoms.n ≥ 3 "Parent and replacement must each be at least 3 atoms for SVD alignment."
###
# compute centered Cartesian coords of the atoms of
# replacement fragment involved in alignment
###
atoms_r = Cart(replacement.atoms[[r for (r, p) in r2p]], replacement.box)
X_r = atoms_r.coords.x
x_r_center = center(X_r)
X_r = X_r .- x_r_center
###
# compute centered Cartesian coords of the atoms of
# parent involved in alignment
###
# handle fragments cut across the PB using the parent subset isomorphic to query
parent_substructure = deepcopy(parent[[p for (q, p) in q2p]])
conglomerate!(parent_substructure) # must do this for when replacement fragment is disconnected
# prepare parent substructure having correspondence with replacement
p2ps = Dict([p => i for (i, p) in enumerate([p for (q, p) in q2p])]) # parent to parent subset map
parent_substructure_to_align_to =
parent_substructure[[p2ps[p] for p in [p for (r, p) in r2p]]]
atoms_p = Cart(parent_substructure_to_align_to.atoms, parent.box)
X_p = atoms_p.coords.x
x_p_center = center(X_p)
X_p = X_p .- x_p_center
# solve the orthogonal procrustes probelm via SVD
F = svd(X_r * X_p')
# optimal rotation matrix
rot = F.V * F.U'
err = norm(rot * X_r - X_p)
return Alignment(rot, -x_r_center, x_p_center, err)
end
function conglomerate!(parent_substructure::Crystal)
# snip the cross-PB bonds
bonds = deepcopy(parent_substructure.bonds)
if length(connected_components(bonds)) > 1
@warn "# connected components in parent substructure > 1. assuming the substructure does not cross the periodic boundary..."
return
end
drop_cross_pb_bonds!(bonds)
# find connected components of bonding graph without cross-PB bonds
# these are the components split across the boundary
conn_comps = connected_components(bonds)
# if substructure is entireline in the unit cell, it's already conglomerated :)
if length(conn_comps) == 1
return
end
# we wish to shift all connected components to a reference component,
# defined to be the largest component for speed.
conn_comps_shifted = [false for c in eachindex(conn_comps)]
ref_comp_id = argmax(length.(conn_comps))
conn_comps_shifted[ref_comp_id] = true # consider it shifted.
# has atom p been shifted?
function shifted_atom(p::Int)
# loop over all connected components that have been shifted
for conn_comp in conn_comps[conn_comps_shifted]
# if parent substructure atom in this, yes!
if p in conn_comp
return true
end
end
# reached this far, atom p is not in component that has been shifted.
return false
end
# to which component does atom p belong?
find_component(p::Int) =
for c in eachindex(conn_comps)
if p in conn_comps[c]
return c
end
end
# until all components have been shifted to the reference component...
while !all(conn_comps_shifted)
# loop over cross-PB edges in the parent substructure
for ed in edges(parent_substructure.bonds)
if get_prop(parent_substructure.bonds, ed, :cross_boundary)
# if one edge belongs to unshifted component and another belogs to any component that has been shifted...
if shifted_atom(ed.src) && !shifted_atom(ed.dst)
p_ref, p = ed.src, ed.dst
elseif shifted_atom(ed.dst) && !shifted_atom(ed.src)
p_ref, p = ed.dst, ed.src
else
continue # both are shifted or both are unshifted. ignore this cross-PB edge
end
# here's the unshifted component we will shift next, to be next to the shifted components.
comp_id = find_component(p)
# find displacement vector for this cross-PB edge.
dx =
parent_substructure.atoms.coords.xf[:, p_ref] -
parent_substructure.atoms.coords.xf[:, p]
# get distance to nearest image
n_dx = copy(dx)
nearest_image!(n_dx)
# shift all atoms in this component by this vector.
for atom_idx in conn_comps[comp_id]
parent_substructure.atoms.coords.xf[:, atom_idx] .+= dx - n_dx
end
# mark that we've shifted this component.
conn_comps_shifted[comp_id] = true
end
end
end
return
end
function aligned_replacement(
replacement::Crystal,
parent::Crystal,
r2p_alignment::Alignment
)
# put replacement into cartesian space
atoms_r = Cart(replacement.atoms, replacement.box)
# rotate replacement to align with parent_subset
atoms_r.coords.x[:, :] =
r2p_alignment.rot * (atoms_r.coords.x .+ r2p_alignment.shift_1) .+
r2p_alignment.shift_2
# cast atoms back to Frac
return Crystal(
replacement.name,
parent.box,
Frac(atoms_r, parent.box),
Charges{Frac}(0),
replacement.bonds,
replacement.symmetry
)
end
function effect_replacements(
search::Search,
replacement::Crystal,
configs::Vector{Tuple{Int, Int}},
name::String
)::Crystal
nb_not_masked = sum(.!occursin.(rc[:r_tag], String.(search.query.atoms.species)))
if replacement.atoms.n > 0
q_unmasked_in_r = substructure_search(search.query[1:nb_not_masked], replacement)
q2r = Dict([q => q_unmasked_in_r.isomorphisms[1][1][q] for q in 1:nb_not_masked])
else
q2r = Dict{Int, Int}()
end
installations = [
optimal_replacement(search, replacement, q2r, loc_id, [ori_id]) for
(loc_id, ori_id) in configs
]
child = install_replacements(search.parent, installations, name)
# handle `missing` values in edge :cross_boundary attribute
for edge in edges(child.bonds) # loop over edges
# check if cross-boundary info is missing
if ismissing(get_prop(child.bonds, edge, :cross_boundary))
# check if bond crosses boundary
distance_e = get_prop(child.bonds, edge, :distance) # distance in edge property
dxa = Cart(
Frac(
child.atoms.coords.xf[:, src(edge)] -
child.atoms.coords.xf[:, dst(edge)]
),
child.box
) # Cartesian displacement
distance_a = norm(dxa.x) # current euclidean distance by atom coords
set_prop!(
child.bonds,
edge,
:cross_boundary,
!isapprox(distance_e, distance_a; atol=0.1)
)
end
end
return child
end
function install_replacements(
parent::Crystal,
replacements::Vector{Installation},
name::String
)::Crystal
# create child w/o symmetry rules for sake of crystal addition
child = Crystal(
name,
parent.box,
parent.atoms,
parent.charges,
parent.bonds,
Xtals.SymmetryInfo()
)
obsolete_atoms = Int[] # to delete at the end
# loop over replacements to install
for installation in replacements
replacement, q2p, r2p =
installation.aligned_replacement, installation.q2p, installation.r2p
#add into parent
if replacement.atoms.n > 0
child = +(child, replacement; check_overlap=false)
end
# reconstruct bonds
for (r, p) in r2p # p is in parent_subst
p_nbrs = neighbors(parent.bonds, p)
for p_nbr in p_nbrs
if !(p_nbr in values(q2p)) # p_nbr not in parent_subst
# need bond nbr => r in child, where r is in replacement
e = (p_nbr, child.atoms.n - replacement.atoms.n + r)
# create edge
add_edge!(child.bonds, e)
# copy edge attributes from parent (:cross_boundary will need to be reassessed later)
set_props!(child.bonds, e[1], e[2], props(parent.bonds, p, p_nbr))
set_prop!(child.bonds, e[1], e[2], :cross_boundary, missing)
end
end
end
# accumulate atoms to delete
obsolete_atoms = vcat(obsolete_atoms, values(q2p)...)
end
# delete obsolete atoms
obsolete_atoms = unique(obsolete_atoms)
keep_atoms = [p for p in 1:(child.atoms.n) if !(p in obsolete_atoms)]
child = child[keep_atoms]
# restore symmetry rules
child =
Crystal(name, child.box, child.atoms, child.charges, child.bonds, parent.symmetry)
# return result
return child
end
function optimal_replacement(
search::Search,
replacement::Crystal,
q2r::Dict{Int, Int},
loc_id::Int,
ori_ids::Vector{Int}
)
# unpack search arg
isomorphisms, parent = search.isomorphisms, search.parent
if q2r == Dict{Int, Int}() # "replace-with-nothing" operation
q2p = isomorphisms[loc_id][1]
r2p = Dict([0 => p for p in values(q2p)])
return Installation(replacement, q2p, r2p)
end
if ori_ids == [0]
ori_ids = [1:nb_ori_at_loc(search)[loc_id]...]
end
# loop over ori_ids to find best r2p_alignment
r2p_alignment = Alignment(zeros(1, 1), [0.0], [0.0], Inf)
best_ori = 0
best_r2p = Dict{Int, Int}()
for ori_id in ori_ids
# find r2p isom
q2p = isomorphisms[loc_id][ori_id]
r2p = Dict([r => q2p[q] for (q, r) in q2r])
# calculate alignment
test_alignment = get_r2p_alignment(replacement, parent, r2p, q2p)
# keep best alignment and generating ori_id
if test_alignment.err < r2p_alignment.err
r2p_alignment = test_alignment
best_ori = ori_id
best_r2p = r2p
end
end
opt_aligned_replacement = aligned_replacement(replacement, parent, r2p_alignment)
# return the replacement modified according to r2p_alignment
@assert ne(opt_aligned_replacement.bonds) == ne(replacement.bonds)
return Installation(opt_aligned_replacement, isomorphisms[loc_id][best_ori], best_r2p)
end
@doc raw"""
child = substructure_replace(search, replacement; random=false, nb_loc=0, loc=Int[], ori=Int[], name="new_xtal", verbose=false, remove_duplicates=false, periodic_boundaries=true)
Replace the substructures of `search.parent` matching the `search.query` fragment with the `replacement` fragment,
at locations and orientations specified by the keyword arguments `random`, `nb_loc`, `loc`, and `ori`.
Default behavior is to effect replacements at all "hit" locations in the parent structure and, at each location,
choose the orientation giving the optimal (lowest error) spatial aligment.
Returns a new `Crystal` with the specified modifications (returns `search.parent` if no replacements are made).
# Arguments
- `search::Search` the `Search` for a substructure moiety in the parent crystal
- `replacement::Crystal` the moiety to use for replacement of the searched substructure
- `random::Bool` set `true` to select random replacement orientations
- `nb_loc::Int` assign a value to select random replacement at `nb_loc` random locations
- `loc::Array{Int}` assign value(s) to select specific locations for replacement. If `ori` is not specified, replacement orientation is random.
- `ori::Array{Int}` assign value(s) when `loc` is assigned to specify exact configurations for replacement. `0` values mean the configuration at that location should be selected for optimal alignment with the parent.
- `name::String` assign to give the generated `Crystal` a name ("new_xtal" by default)
- `verbose::Bool` set `true` to print console messages about the replacement(s) being performed
- `remove_duplicates::Bool` set `true` to automatically combine overlapping atoms of the same species in generated structures.
- `reinfer_bonds::Bool` set `true` to re-infer bonds after producing a structure
- `periodic_boundaries::Bool` set `false` to disable periodic boundary conditions when checking for atom duplication or re-inferring bonds
"""
function substructure_replace(
search::Search,
replacement::Crystal;
random::Bool=false,
nb_loc::Int=0,
loc::Array{Int}=Int[],
ori::Array{Int}=Int[],
name::String="new_xtal",
verbose::Bool=false,
remove_duplicates::Bool=false,
periodic_boundaries::Bool=true,
reinfer_bonds::Bool=false,
wrap::Bool=true
)::Crystal
# replacement at all locations (default)
if nb_loc == 0 && loc == Int[] && ori == Int[]
nb_loc = nb_locations(search)
loc = [1:nb_loc...]
if random
ori = [rand(1:nb_ori_at_loc(search)[i]) for i in loc]
if verbose
@info "Replacing" q_in_p = search r = replacement.name mode = "random ori @ all loc"
end
else
ori = zeros(Int, nb_loc)
if verbose
@info "Replacing" q_in_p = search r = replacement.name mode = "optimal ori @ all loc"
end
end
# replacement at nb_loc random locations
elseif nb_loc > 0 && ori == Int[] && loc == Int[]
loc = sample([1:nb_locations(search)...], nb_loc; replace=false)
if random
ori = [rand(1:nb_ori_at_loc(search)[i]) for i in loc]
if verbose
@info "Replacing" q_in_p = search r = replacement.name mode = "random ori @ $nb_loc loc"
end
else
ori = zeros(Int, nb_loc)
if verbose
@info "Replacing" q_in_p = search r = replacement.name mode = "optimal ori @ $nb_loc loc"
end
end
# specific replacements
elseif ori ≠ Int[] && loc ≠ Int[]
@assert length(loc) == length(ori) "one orientation per location"
nb_loc = length(ori)
if verbose
@info "Replacing" q_in_p = search r = replacement.name mode = "loc: $loc\tori: $ori"
end
# replacement at specific locations
elseif loc ≠ Int[]
nb_loc = length(loc)
if random
ori = [rand(1:nb_ori_at_loc(search)[i]) for i in loc]
if verbose
@info "Replacing" q_in_p = search r = replacement.name mode = "random ori @ loc: $loc"
end
else
ori = zeros(Int, nb_loc)
if verbose
@info "Replacing" q_in_p = search r = replacement.name mode = "optimal ori @ loc: $loc"
end
end
end
# remove charges from parent
if search.parent.charges.n > 0
@warn "Dropping charges from parent."
p = search.parent
search = Search(
Crystal(p.name, p.box, p.atoms, Charges{Frac}(0), p.bonds, p.symmetry),
search.query,
search.isomorphisms
)
end
# generate configuration tuples (location, orientation)
configs = Tuple{Int, Int}[(loc[i], ori[i]) for i in 1:nb_loc]
# process replacements
child = effect_replacements(search, replacement, configs, name)
if remove_duplicates
child = Crystal(
child.name,
child.box,
Xtals.remove_duplicates(child.atoms, child.box, periodic_boundaries),
Xtals.remove_duplicates(child.charges, child.box, periodic_boundaries)
)
end
if wrap
# throw error if installed replacement fragment spans the unit cell
if any(abs.(child.atoms.coords.xf) .> 2.0)
error(
"installed replacement fragment too large for the unit cell; replicate the parent and try again."
)
end
# wrap coordinates
wrap!(child.atoms.coords)
# check :cross_boundary edge attributes
for edge in edges(child.bonds) # loop over edges
distance_e = get_prop(child.bonds, edge, :distance) # distance in edge property
dxa = Cart(
Frac(
child.atoms.coords.xf[:, src(edge)] -
child.atoms.coords.xf[:, dst(edge)]
),
child.box
) # Cartesian displacement
distance_a = norm(dxa.x) # current euclidean distance by atom coords
set_prop!(
child.bonds,
edge,
:cross_boundary,
!isapprox(distance_e, distance_a; atol=0.1)
)
end
end
if reinfer_bonds
remove_bonds!(child)
infer_bonds!(child, periodic_boundaries)
end
return child
end
function substructure_replace(search::Search, replacement::Nothing; kwargs...)
return substructure_replace(search, moiety(nothing); kwargs...)
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 4651 | """
search = Search(parent, query, results)
Stores the `parent` and `query` used for a substructure search and the results (isomorphisms) of the subgraph matching algorithm.
## attributes
- `search.parent::Crystal` # the parent in the search
- `search.query::Crystal` # the query in the search
- `search.isomorphisms::Vector{Vector{Vector{Int}}}` # the query-to-parent correspondences
The isomorphisms are grouped by location in the parent `Crystal` and can be examined using `nb_isomorphisms`, `nb_locations`, and `nb_ori_at_loc`.
Subgraph isomorphisms are encoded like
isom = search.isomorphisms[i_loc][i_ori] = [7, 21, 9]
where `isom[k]` is the index of the atom in `search.parent` corresponding to atom `k` in `search.query` for the isomorphism at location `i_loc` and orientation `i_ori`.
"""
struct Search
parent::Crystal
query::Crystal
isomorphisms::Vector{Vector{Dict{Int, Int}}}
end
function Base.show(io::IO, s::Search)
begin
println(io, s.query.name, " ∈ ", s.parent.name)
print(io, nb_isomorphisms(s), " hits in ", nb_locations(s), " locations.")
end
end
"""
nb_isomorphisms(search::Search)
Returns the number of isomorphisms found in the specified `Search`
# Arguments
- `search::Search` a substructure `Search` object
"""
function nb_isomorphisms(search::Search)::Int
return sum(nb_ori_at_loc(search))
end
"""
nb_locations(search::Search)
Returns the number of unique locations in the `parent` (sets of atoms in the `parent`) at which the
specified `Search` results contain isomorphisms.
# Arguments
- `search::Search` a substructure `Search` object
"""
function nb_locations(search::Search)::Int
return length(search.isomorphisms)
end
"""
nb_ori_at_loc(search)
Returns a array containing the number of isomorphic configurations at a given
location (collection of atoms) for which the specified `Search` results
contain isomorphisms.
# Arguments
- `search::Search` a substructure `Search` object
"""
function nb_ori_at_loc(search::Search)::Array{Int}
return length.(search.isomorphisms)
end
# extension of infix `in` operator for syntactic sugar
# this allows all of the following:
# s ∈ g → find the moiety in the crystal
# [s1, s2] .∈ [g] → find each moiety in a crystal
# s .∈ [g1, g2] → find the moiety in each crystal
# [s1, s2] .∈ [g1, g2] → find each moiety in each crystal
(∈)(s::Crystal, g::Crystal) = substructure_search(s, g)
"""
iso_structs = isomorphic_substructures(s::Search)::Crystal
Returns a crystal consisting of the atoms of the `parent` involved in subgraph isomorphisms in the search `s`
"""
function isomorphic_substructures(s::Search)::Crystal
return s.parent[reduce(
vcat,
collect.(values.([s.isomorphisms[i][1] for i in 1:nb_locations(s)]))
)]
end
"""
substructure_search(query, parent; disconnected_component=false)
Searches for a substructure within a `Crystal` and returns a `Search` struct
containing all identified subgraph isomorphisms. Matches are made on the basis
of atomic species and chemical bonding networks, including bonds across unit cell
periodic boundaries. The search moiety may optionally contain markup for
designating atoms to replace with other moieties.
# Arguments
- `query::Crystal` the search moiety
- `parent::Crystal` the parent structure
- `disconnected_component::Bool=false` if true, disables substructure searching (e.g. for finding guest molecules)
"""
function substructure_search(
query::Crystal,
parent::Crystal;
disconnected_component::Bool=false
)::Search
if parent.atoms.n == 0
return
end
@assert ne(parent.bonds) > 0 "The parent structure must have bonds. Use `infer_bonds!(xtal, pbc)` to create them."
# Make a copy w/o R tags for searching
moty = deepcopy(query)
untag_r_group!(moty)
# Get array of configuration arrays
configs = find_subgraph_isomorphisms(
moty.bonds,
moty.atoms.species,
parent.bonds,
parent.atoms.species,
disconnected_component
)
df = DataFrame(; p_subset=[sort(c) for c in configs], isomorphism=configs)
results = Vector{Dict{Int, Int}}[]
for (i, df_loc) in enumerate(groupby(df, :p_subset))
q2p_loc = Dict{Int, Int}[]
for isomorphism in df_loc.isomorphism
q2p = Dict([q => p for (q, p) in enumerate(isomorphism)])
push!(q2p_loc, q2p)
end
push!(results, q2p_loc)
end
return Search(parent, query, results)
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 387 | using PoreMatMod
import Aqua
# ambiguity testing finds many "problems" outside the scope of this package
ambiguities = false
# to skip when checking for stale dependencies and missing compat entries
# Aqua is added in a separate CI job, so (ironically) does not work w/ itself
stale_deps = (ignore=[:Aqua],)
Aqua.test_all(PoreMatMod; ambiguities=ambiguities, stale_deps=stale_deps)
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 589 | module PoreMatMod_Test
using Test, PoreMatMod
@testset "correct_missing_Hs" begin
include("../examples/correct_missing_Hs.jl")
@test true
end
@testset "disorder_and_guests" begin
include("../examples/disorder_and_guests.jl")
@test true
end
@testset "make_hypothetical_MOF" begin
include("../examples/make_hypothetical_MOF.jl")
@test true
end
@testset "missing_linker_defect" begin
include("../examples/missing_linker_defect.jl")
@test true
end
@testset "replacement_modes" begin
include("../examples/replacement_modes.jl")
@test true
end
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 7071 | module PoreMatMod_Test
using Test, Graphs, PoreMatMod, LinearAlgebra
NiPyC_fragment_trouble = Crystal("NiPyC_fragment_trouble.cif")
irmof1 = Crystal("IRMOF-1.cif")
PyC = moiety("PyC.xyz")
p_phenylene = moiety("p-phenylene.xyz")
tagged_p_phenylene = moiety("2-!-p-phenylene.xyz")
acetamido_p_phen = moiety("2-acetylamido-p-phenylene.xyz")
@testset "replacement split across PB" begin
parent = deepcopy(NiPyC_fragment_trouble)
query = deepcopy(PyC)
replacement = moiety("PyC-CH3.xyz")
@test_throws AssertionError replace(parent, query => replacement)
infer_bonds!(parent, true)
child = replace(parent, query => replacement)
@test ne(child.bonds) == ne(parent.bonds) + 3 * 2 # added H -> CH3 on two PyC ligands
# test conglomerate worked.
remove_bonds!(child)
infer_bonds!(child, true)
@test ne(child.bonds) == ne(parent.bonds) + 3 * 2 # added H -> CH3 on two PyC ligands
end
@testset "split across PB, non-connected replacement" begin
parent = Crystal("NiPyC_fragment_trouble.cif"; convert_to_p1=false)
infer_bonds!(parent, true)
query = moiety("PyC_split.xyz")
replacement = moiety("PyC_split_replacement.xyz")
child = replace(parent, query => replacement)
# ensure O atoms aligned
parent_Os = parent[parent.atoms.species .== :O]
child_Os = child[child.atoms.species .== :O]
nb_Os = parent_Os.atoms.n
@test parent_Os.atoms.n == nb_Os
min_distances = [Inf for _ in 1:nb_Os] # from parent
for i in 1:nb_Os
for j in 1:nb_Os
r = norm(parent_Os.atoms.coords.xf[:, i] - child_Os.atoms.coords.xf[:, j])
if r < min_distances[i]
min_distances[i] = r
end
end
end
@test all(min_distances .< 0.01)
end
@testset "replacement spans twice the unit cell" begin
parent = deepcopy(NiPyC_fragment_trouble)
infer_bonds!(parent, true)
query = deepcopy(PyC)
replacement = moiety("PyC-long_chain.xyz")
@test_throws Exception replace(parent, query => replacement)
end
@testset "substructure_search" begin
xtal = deepcopy(irmof1)
strip_numbers_from_atom_labels!(xtal)
infer_bonds!(xtal, true)
timil125 = Crystal("Ti-MIL-125.cif")
strip_numbers_from_atom_labels!(timil125)
infer_bonds!(timil125, true)
query = deepcopy(p_phenylene)
p_phenylene_w_R_grp = deepcopy(tagged_p_phenylene)
search1 = query ∈ xtal
@test nb_isomorphisms(search1) == 96
@test nb_locations(search1) == 24
@test nb_ori_at_loc(search1)[1] == 4
@test search1.isomorphisms[1][1] == Dict([
q => p for (q, p) in enumerate([233, 306, 318, 245, 185, 197, 414, 329, 402, 341])
])
search2 = query ∈ timil125
@test nb_isomorphisms(search2) == 48
@test nb_locations(search2) == 12
@test nb_ori_at_loc(search2)[1] == 4
@test search2.isomorphisms[1][1] == Dict([
q => p for (q, p) in enumerate([8, 140, 144, 141, 7, 133, 186, 185, 190, 189])
])
search3 = p_phenylene_w_R_grp ∈ timil125
@test nb_isomorphisms(search3) == 48
@test nb_locations(search3) == 12
@test nb_ori_at_loc(search3)[1] == 4
@test search3.isomorphisms[1][1] == Dict([
q => p for (q, p) in enumerate([8, 140, 144, 141, 7, 133, 185, 190, 189, 186])
])
query = moiety("!-S-bromochlorofluoromethane.xyz")
parent = moiety("S-bromochlorofluoromethane.xyz")
search = query ∈ parent
@test search.isomorphisms[1][1] ==
Dict([q => p for (q, p) in enumerate([1, 2, 3, 4, 5])])
@test [parent.atoms.species[search.isomorphisms[1][1][i]] for i in 1:4] == query.atoms.species[1:4] &&
query.atoms.species[5] == :H! &&
parent.atoms.species[search.isomorphisms[1][1][5]] == :H
query = deepcopy(p_phenylene)
parent = Crystal("IRMOF-1_one_ring.cif")
strip_numbers_from_atom_labels!(parent)
infer_bonds!(parent, true)
search = query ∈ parent
@test search.isomorphisms[1][1] ==
Dict([q => p for (q, p) in enumerate([34, 38, 39, 36, 26, 27, 51, 46, 50, 48])])
q1 = moiety("glycine_res.xyz")
q2 = moiety("glycine_res.xyz"; presort=false)
search = q1 ∈ q2
@test q1.atoms.coords.xf ≠ q2.atoms.coords.xf
@test length(search.isomorphisms) == 1
end # test set: substructure_search
@testset "find_replace" begin
parent = deepcopy(irmof1)
strip_numbers_from_atom_labels!(parent)
infer_bonds!(parent, true)
query = deepcopy(tagged_p_phenylene)
replacement = deepcopy(acetamido_p_phen)
new_xtal = replace(parent, query => replacement)
@test new_xtal.atoms.n == 592
new_xtal = replace(parent, query => replacement; nb_loc=1)
@test new_xtal.atoms.n == 431
new_xtal = replace(parent, query => replacement; loc=[2, 3])
@test new_xtal.atoms.n == 438
new_xtal = replace(parent, query => replacement; loc=[2, 3, 4], ori=[1, 1, 1])
@test new_xtal.atoms.n == 445
replacement = deepcopy(p_phenylene)
new_xtal = replace(parent, query => replacement)
@test ne(new_xtal.bonds) == ne(parent.bonds)
replacement = deepcopy(acetamido_p_phen)
new_xtal = replace(parent, query => replacement; nb_loc=1)
@test ne(new_xtal.bonds) == (ne(parent.bonds) - ne(query.bonds) + ne(replacement.bonds))
xtal = deepcopy(irmof1)
strip_numbers_from_atom_labels!(xtal)
infer_bonds!(xtal, true)
query = deepcopy(tagged_p_phenylene)
nb_bonds(xtal) = ne(xtal.bonds)
# test that a "no-op" leaves the number of bonds unchanged
replacement = deepcopy(p_phenylene)
@test nb_bonds(replace(xtal, query => replacement)) == nb_bonds(xtal)
# test that adding a new moiety increases the number of bonds correctly
replacement = deepcopy(acetamido_p_phen)
@test ne((replace(xtal, query => replacement; nb_loc=1)).bonds) ==
(ne(xtal.bonds) - ne(query.bonds) + ne(replacement.bonds))
end
@testset "conglomerate test" begin
xtal = Crystal("conglomerate_test.cif")
infer_bonds!(xtal, false)
@test ne(xtal.bonds) == 1
remove_bonds!(xtal)
@test ne(xtal.bonds) == 0
infer_bonds!(xtal, true)
@test ne(xtal.bonds) == 5
PoreMatMod.conglomerate!(xtal)
remove_bonds!(xtal)
translate_by!(xtal.atoms.coords, Frac([0.5, 0.5, 0.5]))
infer_bonds!(xtal, false)
@test ne(xtal.bonds) == 5
end
@testset "remove duplicates" begin
parent = moiety("ADC.xyz")
new_box = replicate(unit_cube(), (10, 10, 10))
new_atoms = Frac(Cart(parent.atoms, parent.box), new_box)
new_charges = Frac(Cart(parent.charges, parent.box), new_box)
parent = Crystal(parent.name, new_box, new_atoms, new_charges)
infer_bonds!(parent, false)
query = moiety("naphthyl_fragment.xyz")
replacement = moiety("F_naphthyl_fragment.xyz")
child = replace(
parent,
query => replacement;
nb_loc=2,
remove_duplicates=true,
reinfer_bonds=true
)
@test child.atoms.n == parent.atoms.n
@test nv(child.bonds) == nv(parent.bonds) && ne(child.bonds) == ne(parent.bonds)
end
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 1191 | module Moiety_Test
using Test, PoreMatMod
# function for a specific test case. NOT a generally useful function!
# frag and moty inputs are expected to be permuted sets of atoms with unique species
function test_is_equiv(frag::Crystal, moty::Crystal)::Bool
for (f, f_label) in enumerate(frag.atoms.species)
for (m, m_label) in enumerate(moty.atoms.species)
if f_label == m_label
for i in 1:3
if frag.atoms.coords.xf[i, f] ≠ moty.atoms.coords.xf[i, m]
return false # detected an atom w/ inconsistent coordinates
end
end
end
end
end
return true
end
@testset "Moiety Tests" begin
moiety_bcfm = moiety("S-bromochlorofluoromethane.xyz")
moiety_2!bcfm = moiety("!-S-bromochlorofluoromethane.xyz")
@test moiety_bcfm.atoms.species == [:C, :Cl, :F, :Br, :H]
@test moiety_2!bcfm.atoms.species == [:C, :Cl, :F, :Br, :H!]
@test PoreMatMod.subtract_r_group(moiety_2!bcfm).atoms.species == [:C, :Cl, :F, :Br]
null_moiety = moiety(nothing; bonding_rules=rc[:bonding_rules])
@test null_moiety.atoms.n == 0
end
end # module
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 363 | testfiles = [
"moiety.jl"
"ullmann.jl"
"findreplace.jl"
"examples.jl"
]
@assert VERSION.major == 1
@assert VERSION.minor ≥ 6
using Test, Documenter, PoreMatMod
PoreMatMod.banner()
for testfile in testfiles
@info "Running test/$testfile"
@time include(testfile)
end
if VERSION.minor ≥ 7
@time doctest(PoreMatMod)
end
@info "Done."
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | code | 1537 | module Ullmann_Test
using Test, Graphs, MetaGraphs, PoreMatMod
# add a list of edges to a graph
add_edges!(g, edges) =
for edge in edges
add_edge!(g, edge[1], edge[2])
end
# make a graph with the listed labels and edges
function build_graph(labels, edges)
g = MetaGraph()
add_vertices!(g, length(labels))
add_edges!(g, edges)
return g, labels
end
@testset "Ullmann Tests" begin
# (graph, labels)
(g, lg) = build_graph(
[:A, :B, :B, :C, :A, :A],
[(1, 2), (2, 3), (3, 4), (4, 2), (3, 5), (5, 6)]
)
(s1, l1) = build_graph([:B, :C], [(1, 2)])
(s2, l2) = build_graph([:A, :B], [(1, 2)])
(s3, l3) = build_graph([:B, :B, :C], [(1, 2), (2, 3), (3, 1)])
(s4, l4) = build_graph([:B, :D, :C], [(1, 2), (2, 3), (3, 1)])
(s5, l5) = build_graph([:B, :A, :B, :C, :D], [(1, 2), (1, 3), (1, 4), (1, 5)])
(s6, l6) = build_graph([:A, :A], [])
(s7, l7) = build_graph([:A, :A, :B], [(1, 2), (2, 3)])
@test PoreMatMod.find_subgraph_isomorphisms(g, lg, g, lg) == [[1, 2, 3, 4, 5, 6]]
@test PoreMatMod.find_subgraph_isomorphisms(s1, l1, g, lg) == [[2, 4], [3, 4]]
@test PoreMatMod.find_subgraph_isomorphisms(s2, l2, g, lg) == [[1, 2], [5, 3]]
@test PoreMatMod.find_subgraph_isomorphisms(s3, l3, g, lg) == [[2, 3, 4], [3, 2, 4]]
@test PoreMatMod.find_subgraph_isomorphisms(s4, l4, g, lg) == []
@test PoreMatMod.find_subgraph_isomorphisms(s5, l5, g, lg) == []
@test PoreMatMod.find_subgraph_isomorphisms(s7, l7, g, lg) == [[6, 5, 3]]
end
end
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | docs | 188 | If you are interested in contributing, find a bug, want a new feature, or have questions about the software, please [open an issue.](https://github.com/SimonEnsemble/PoreMatMod.jl/issues)
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | docs | 5178 | ## 
`PoreMatMod.jl` is a [Julia](https://julialang.org/) package for (i) subgraph matching and (ii) modifying crystal structures such as metal-organic frameworks (MOFs).
Functioning as a "find-and-replace" tool on atomistic crystal structure models of porous materials, `PoreMatMod.jl` is useful for:
:hammer: subgraph matching to filter databases of crystal structures
:hammer: constructing hypothetical crystal structure models of functionalized structures
:hammer: introducing defects into crystal structures
:hammer: repairing artifacts of X-ray structure determination, such as missing hydrogen atoms, disorder, and guest molecules
N.b. while `PoreMatMod.jl` was developed for MOFs and other porous crystalline materials, its find-and-replace operations can be applied to discrete, molecular structures as well by assigning an arbitrary unit cell.
| **Documentation** | **Build Status** | **Test Coverage** |
|:------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| [](https://SimonEnsemble.github.io/PoreMatMod.jl/dev) | [](https://github.com/SimonEnsemble/PoreMatMod.jl/actions/workflows/CI_build.yml) [](https://github.com/SimonEnsemble/PoreMatMod.jl/actions/workflows/doc_deployment.yml) [](https://github.com/SimonEnsemble/PoreMatMod.jl/actions/workflows/weekly.yml) | [](https://codecov.io/gh/SimonEnsemble/PoreMatMod.jl) [](https://github.com/JuliaTesting/Aqua.jl) |
## Installation
`PoreMatMod.jl` is a registered Julia package and can be installed by entering the following line in the Julia REPL when in package mode (type `]` to enter package mode):
```
pkg> add PoreMatMod
```
## Gallery of examples
Link to examples [here](https://simonensemble.github.io/PoreMatMod.jl/dev/examples/) with raw [Pluto](https://github.com/fonsp/Pluto.jl) notebooks [here](https://github.com/SimonEnsemble/PoreMatMod.jl/tree/master/examples).
## Citing
If you found `PoreMatMod.jl` useful, please cite our paper in *J. Chem. Inf. Model.* (ACS Editors' Choice) [here](https://pubs.acs.org/doi/10.1021/acs.jcim.1c01219) [preprint [here](https://chemrxiv.org/engage/chemrxiv/article-details/615cf5127d3da5dd7bee4a22)]. :point_down:
```latex
@article{Henle2022,
doi = {10.1021/acs.jcim.1c01219},
url = {https://doi.org/10.1021/acs.jcim.1c01219},
year = {2022},
month = jan,
publisher = {American Chemical Society ({ACS})},
volume = {62},
number = {3},
pages = {423--432},
author = {E. Adrian Henle and Nickolas Gantzler and Praveen K. Thallapally and Xiaoli Z. Fern and Cory M. Simon},
title = {{PoreMatMod}.jl: Julia Package for in Silico Postsynthetic Modification of Crystal Structure Models},
journal = {Journal of Chemical Information and Modeling}
}
```
## Contributing
We encourage feature requests and feedback [on GitHub](https://github.com/SimonEnsemble/PoreMatMod.jl/issues).
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | docs | 829 | # PoreMatModGO
To make `PoreMatMod.jl` more accessible, an express graphical interface, `PoreMatModGO`, is provided.
The `PoreMatModGO` interface, built on `Pluto.jl`, enables interactive application of chemical substructure find/replace operations with minimal setup and no code provided by the user.
Follow the steps in [Getting Started](../manual/start).
Then, simply launch the GUI notebook via `Pluto`:
```julia
using PoreMatMod
PoreMatModGO()
```
The notebook may take several minutes to launch the first time, especially on Windows.
Prepare file inputs per the [manual](../manual/inputs) and load them into `PoreMatModGO` using the graphical interface.
All [replacement](../manual/replace) modes are available with interactive visual previews and outputs are downloadable in `.cif`, `.xyz`, and `.vtk` file formats.
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | docs | 404 | # Contributing/Reporting Issues
### Reporting Issues
Please report any bugs or make suggestions for improvements by filing an issue on Github [here](https://github.com/SimonEnsemble/PoreMatMod.jl/issues).
### `PoreMatMod.jl` Wants You!
We welcome contributions (pull requests) for bug fixes, improvements, new features, etc. If the change is fundamental/major, please post an issue to discuss first.
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | docs | 2360 | ```@meta
DocTestSetup = quote
using PoreMatMod
end
```
## Examples
The [Pluto notebooks](https://github.com/fonsp/Pluto.jl) (`.jl`) containing the Julia code and the input files for all examples are in the [examples directory](https://github.com/SimonEnsemble/PoreMatMod.jl/tree/master/examples).
Click on the images or descriptions below to see Pluto notebooks demonstrating each use case.
!!! example "Example: Find substructures in a crystal"
Identify the *p*-phenylene fragments in IRMOF-1.
[link](../examples/substructure_search.html)
[

](../examples/substructure_search.html)
!!! example "Example: Generate hypothetical structures"
Decorate IRMOF-1 with a functional group: *ortho* substitution with an acetylamido group at one quarter of the *p*-phenylene moieties.
[link](../examples/make_hypothetical_MOF.html)
[

](../examples/make_hypothetical_MOF.html)
!!! example "Example: Using different replacement modes"
Replace BDC with nitro-BDC in IRMOF-1 using the different replacement modes to control (i) which linkers are functionalized and (ii) the substitution site on each linker.
[link](../examples/replacement_modes.html)
[

](../examples/replacement_modes.html)
!!! example "Example: Insert missing hydrogen atoms"
Insert missing H atoms in IRMOF-1.
[link](../examples/correct_missing_Hs.html)
[

](../examples/correct_missing_Hs.html)
!!! example "Example: Repair Disorder and Remove Adsorbates"
Correct the crystallographic disorder of the PyC-2 ligands and remove guest molecules from the pores of SIFSIX-Cu-2-i.
[link](../examples/disorder_and_guests.html)
[

](../examples/disorder_and_guests.html)
!!! example "Example: Generate Missing-Linker Defects"
Create a new channel in UiO-66 by introducing missing-linker defects and formate ion capping.
[link](../examples/missing_linker_defect.html)
[

](../examples/missing_linker_defect.html)
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
|
[
"MIT"
] | 0.2.20 | 131cd2b2ae892b6949a0b9aa375c689802e99c9d | docs | 2538 | 
`PoreMatMod.jl` is a software package in [Julia](https://julialang.org/) for (i) subgraph matching and (ii) modifying crystal structures.
Functioning as a "find-and-replace" tool on atomistic crystal structure models of porous materials, `PoreMatMod.jl` can:
- search crystals for chemical substructures
- create libraries of hypothetical structures by e.g. decoration with functional groups
- correct artifacts of X-ray structure determination (missing H, disorder, guests)
- introduce defects into crystal structures
`PoreMatMod.jl` implements
1. (for find operations) Ullmann's algorithm for subgraph isomorphism search
2. (for replace operations) the orthogonal Procrustes algorithm for point cloud alignment.
Periodic boundary conditions are respected, and the unit cell is preserved.
While developed primarily for porous crystals such as metal-organic frameworks (MOFs), `PoreMatMod.jl` can operate on any periodic atomistic system as well as discrete molecules.
### Introductory example: creating a functionalized MOF structure
Suppose we wish to decorate the linkers of IRMOF-1 with trifluoromethyl (tfm) groups.
The `PoreMatMod.jl` code below accomplishes this by (i) searching the parent IRMOF-1 structure for a phenylene query fragment and (ii) replacing each instance with a tfm-phenylene replacement fragment to give the child structure.
```julia
# read crystal structure of the parent MOF
parent_xtal = Crystal("IRMOF-1.cif")
# read query and replacement fragments
query_fragment = moiety("p-phenylene.xyz") # masked atoms marked with !
replacement_fragment = moiety("tfm-p-phenylene.xyz")
# (1) search parent structure for query fragment
# (2) replace occurrences of query fragment with replacement fragments
# (with randomly chosen orientations)
child_xtal = replace(parent_xtal, query_fragment => replacement_fragment)
```

!!! example "Further examples"
See the [examples page](https://simonensemble.github.io/PoreMatMod.jl/examples/) for links to Pluto notebooks with `PoreMatMod.jl` code to accomplish various find-and-replace tasks.
!!! note "Please cite our paper!"
If you found `PoreMatMod.jl` useful, please cite our paper:
> A. Henle, N. Gantzler, P. Thallapally, X. Fern, C. Simon. `PoreMatMod.jl`: Julia package for _in silico_ post-synthetic modification of crystal structure models. [Journal of Chemical Information and Modeling](https://pubs.acs.org/doi/10.1021/acs.jcim.1c01219). (2022)
| PoreMatMod | https://github.com/SimonEnsemble/PoreMatMod.jl.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.