Skip to content

Commit

Permalink
Add additiona methods for res2tep and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonp0420 committed Dec 13, 2024
1 parent f61afbe commit 9d24a4d
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 10 deletions.
16 changes: 11 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,33 @@ Triangulate = "f7e6ffb2-c36d-4f8f-a77e-16e897189344"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
DelimitedFiles = "1.9"
FFTW = "1.8"
FileIO = "1.16.2"
GeoInterface = "1.3.3"
JLD2 = "0.5.8"
GeoInterface = "1.3"
JLD2 = "0.5"
LibGEOS = "0.9"
LoggingExtras = "1.0.3"
LoggingExtras = "1.1"
MetalSurfaceImpedance = "1.0"
NearestNeighbors = "0.4.16"
NearestNeighbors = "0.4"
OffsetArrays = "1.13"
OhMyThreads = "0.7"
PkgVersion = "0.3.3"
PolygonOps = "0.1.2"
PrecompileTools = "1.2"
ProgressMeter = "1.9.0"
ProgressMeter = "1.10"
RecipesBase = "1.3.4"
Reexport = "1.2.2"
SLEEFPirates = "0.6.42"
StaticArrays = "1.9.2"
TicraUtilities = "1.1.0"
Triangulate = "2.3.2"
Unitful = "1.19.0"
Dates = "1.11"
InteractiveUtils = "1.10"
LinearAlgebra = "1.10"
Logging = "1.10"
Printf = "1.10"
julia = "1"

[extras]
Expand Down
22 changes: 18 additions & 4 deletions src/Outputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,18 @@ end # function

"""
res2tep(results::Vector{Result}; name="tep", class="res2tep") -> t::TEPperiodic
res2tep(resultfile::AbstractString; name="tep", class="res2tep") -> t::TEPperiodic
res2tep(results::Vector{Result}, tepfile::AbstractString; name="tep", class="res2tep") -> t::TEPperiodic
res2tep(resultfile::AbstractString, tepfile::AbstractString; name="tep", class="res2tep") -> t::TEPperiodic
Convert a vector of `Result` elements into a `TEPperiodic` object, as defined in the
[TicraUtilities](https://github.com/simonp0420/TicraUtilities.jl) package. If positional argument
`tepfile` is provided, the `TEPperiodic` object will be saved to this file name as a TICRA-compatible
TEP (tabulated electrical properties) file. If this argument is not supplied, then the user can manually
write the output of this function to a TEP file using the function `write_tepfile` of the
[TicraUtilities](https://github.com/simonp0420/TicraUtilities.jl) package.
TEP (tabulated electrical properties) file. If the first positional argument is an `AbstractString`, it is
assumed to be the name of a PSSFSS results file, from which the vector of results will be read.
The keyword arguments are used to provide values for the same-named fields in the TEP structure.
`results` must contain the results of a PSSFSS analysis sweep over θ and ϕ (and possibly frequency) such that
`results` (or `resultfile`) must contain the results of a PSSFSS analysis sweep over θ and ϕ (and possibly frequency) such that
1. Incidence angles θ and ϕ rather than incremental phasings ψ₁ and ψ₂ were used.
1. If more than one ϕ value is used, then all ϕ values in the range `0:Δϕ:(360-Δϕ)` must be present.
1. The entire 3-dimensional Cartesian product of all angles and frequencies must be present.
Expand All @@ -528,6 +530,18 @@ function res2tep(results::Vector{Result}, tepfile::AbstractString; name="tep", c
return t
end

function res2tep(resultfile::AbstractString, tepfile::AbstractString; name="tep", class="res2tep")
results = read_result_file(resultfile)
t = res2tep(results; name, class)
TicraUtilities.write_tepfile(tepfile, t)
return t
end

function res2tep(resultfile::AbstractString; name="tep", class="res2tep")
results = read_result_file(resultfile)
return res2tep(results; name, class)
end

function res2tep(results::Vector{Result}; name="tep", class="res2tep")
theta, phi, freqs = _check_results_for_tep!(results)
mff = @SMatrix [1 -1; -1 1]
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TicraUtilities = "97d36a8d-cc3e-473e-9421-8a7b112c16eb"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ end
@safetestset "Full Tests" begin
include("full_test.jl")
end

@safetestset "TEP test" begin
include("tep_test.jl")
end

if get(ENV, "BENCHMARK", "false") == "true"
include("benchmark.jl")
Expand Down
27 changes: 27 additions & 0 deletions test/tep_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using PSSFSS
using Test
@testset "TEP Creation" begin
using PSSFSS
using TicraUtilities: TicraUtilities as TU
FGHz = 3.0
Px = Py = 5.0
Lx = 4.0
Ly = 0.2
Nx = 130
Ny = 6
sheet = rectstrip(; Px, Py, Lx, Ly, Nx, Ny, units=cm, sigma=5.7e8)
steering == 0:30:60, ϕ = 0:60:300)
strata = [Layer(), sheet, Layer()]
resultfile = tempname()
logfile = devnull
showprogress = false
results = analyze(strata, FGHz, steering; resultfile, logfile, showprogress)
teppssfss_file = tempname()
res2tep(resultfile, teppssfss_file)
tep_pssfss = TU.read_tepfile(teppssfss_file)
tep_ticra = TU.read_tepfile(joinpath(pkgdir(PSSFSS), "test", "ticra_tools_dipole.tep"))
@test maximum(abs, TU.get_sff(tep_pssfss) - TU.get_sff(tep_ticra)) < 0.001
@test maximum(abs, TU.get_sfr(tep_pssfss) - TU.get_sfr(tep_ticra)) < 0.001
@test maximum(abs, TU.get_srf(tep_pssfss) - TU.get_srf(tep_ticra)) < 0.001
@test maximum(abs, TU.get_srr(tep_pssfss) - TU.get_srr(tep_ticra)) < 0.001
end
45 changes: 45 additions & 0 deletions test/ticra_tools_dipole.tep
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[Title] Electrical Properties of Periodic Unit Cell
[Version] 1.0.0
[Name] strip_01
[Class] periodic_unit_cell_rectangular_patch
[Frequencies] 1
[ParameterSweeps] 0
[IncidenceAngles] 0.000 60.000 3 0.000 300.000 6 [deg]

[Frequency] 1 3.00000000 [GHz]
[SFront] -0.00000275 -0.00169425 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.21023730 -0.40673981 0.99999725 -0.00169425 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.78976270 -0.40673981
[SRear] -0.00000275 -0.00169425 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.21023730 -0.40673981 0.99999725 -0.00169425 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.78976270 -0.40673981
[SFront] -0.00000344 -0.00149632 0.00000000 0.00000000 0.00000000 0.00000000 -0.14181702 -0.34816039 0.99999656 -0.00149632 0.00000000 0.00000000 0.00000000 0.00000000 0.85818298 -0.34816039
[SRear] -0.00000344 -0.00149632 0.00000000 0.00000000 0.00000000 0.00000000 -0.14181702 -0.34816039 0.99999656 -0.00149632 0.00000000 0.00000000 0.00000000 0.00000000 0.85818298 -0.34816039
[SFront] -0.00000768 -0.00100278 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.04417554 -0.20478660 0.99999232 -0.00100278 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.95582446 -0.20478660
[SRear] -0.00000768 -0.00100278 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.04417554 -0.20478660 0.99999232 -0.00100278 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.95582446 -0.20478660
[SFront] -0.15767866 -0.30547842 -0.09103423 -0.17538987 -0.09103423 -0.17538987 -0.05256139 -0.10295564 0.84232134 -0.30547842 -0.09103423 -0.17538987 -0.09103423 -0.17538987 0.94743861 -0.10295564
[SRear] -0.15767866 -0.30547842 -0.09103423 -0.17538987 -0.09103423 -0.17538987 -0.05256139 -0.10295564 0.84232134 -0.30547842 -0.09103423 -0.17538987 -0.09103423 -0.17538987 0.94743861 -0.10295564
[SFront] -0.20158462 -0.34698498 -0.10079145 -0.17275676 -0.10078987 -0.17276275 -0.05039740 -0.08785502 0.79841538 -0.34698498 -0.10079145 -0.17275676 -0.10078987 -0.17276275 0.94960260 -0.08785502
[SRear] -0.20158462 -0.34698498 -0.10079145 -0.17275676 -0.10078987 -0.17276275 -0.05039740 -0.08785502 0.79841538 -0.34698498 -0.10079145 -0.17275676 -0.10078987 -0.17276275 0.94960260 -0.08785502
[SFront] -0.44212317 -0.46035189 -0.12762823 -0.13264339 -0.12762766 -0.13267301 -0.03684366 -0.03915826 0.55787683 -0.46035189 -0.12762823 -0.13264339 -0.12762766 -0.13267301 0.96315634 -0.03915826
[SRear] -0.44212317 -0.46035189 -0.12762823 -0.13264339 -0.12762766 -0.13267301 -0.03684366 -0.03915826 0.55787683 -0.46035189 -0.12762823 -0.13264339 -0.12762766 -0.13267301 0.96315634 -0.03915826
[SFront] -0.15767866 -0.30547842 0.09103423 0.17538987 0.09103423 0.17538987 -0.05256139 -0.10295564 0.84232134 -0.30547842 0.09103423 0.17538987 0.09103423 0.17538987 0.94743861 -0.10295564
[SRear] -0.15767866 -0.30547842 0.09103423 0.17538987 0.09103423 0.17538987 -0.05256139 -0.10295564 0.84232134 -0.30547842 0.09103423 0.17538987 0.09103423 0.17538987 0.94743861 -0.10295564
[SFront] -0.20158462 -0.34698498 0.10079145 0.17275676 0.10078987 0.17276275 -0.05039740 -0.08785502 0.79841538 -0.34698498 0.10079145 0.17275676 0.10078987 0.17276275 0.94960260 -0.08785502
[SRear] -0.20158462 -0.34698498 0.10079145 0.17275676 0.10078987 0.17276275 -0.05039740 -0.08785502 0.79841538 -0.34698498 0.10079145 0.17275676 0.10078987 0.17276275 0.94960260 -0.08785502
[SFront] -0.44212317 -0.46035189 0.12762823 0.13264339 0.12762766 0.13267301 -0.03684366 -0.03915826 0.55787683 -0.46035189 0.12762823 0.13264339 0.12762766 0.13267301 0.96315634 -0.03915826
[SRear] -0.44212317 -0.46035189 0.12762823 0.13264339 0.12762766 0.13267301 -0.03684366 -0.03915826 0.55787683 -0.46035189 0.12762823 0.13264339 0.12762766 0.13267301 0.96315634 -0.03915826
[SFront] -0.00000275 -0.00169425 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.21023730 -0.40673981 0.99999725 -0.00169425 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.78976270 -0.40673981
[SRear] -0.00000275 -0.00169425 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.21023730 -0.40673981 0.99999725 -0.00169425 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.78976270 -0.40673981
[SFront] -0.00000344 -0.00149632 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.14181702 -0.34816039 0.99999656 -0.00149632 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.85818298 -0.34816039
[SRear] -0.00000344 -0.00149632 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.14181702 -0.34816039 0.99999656 -0.00149632 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.85818298 -0.34816039
[SFront] -0.00000768 -0.00100278 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.04417554 -0.20478660 0.99999232 -0.00100278 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.95582446 -0.20478660
[SRear] -0.00000768 -0.00100278 -0.00000000 -0.00000000 -0.00000000 -0.00000000 -0.04417554 -0.20478660 0.99999232 -0.00100278 -0.00000000 -0.00000000 -0.00000000 -0.00000000 0.95582446 -0.20478660
[SFront] -0.15767866 -0.30547842 -0.09103423 -0.17538987 -0.09103423 -0.17538987 -0.05256139 -0.10295564 0.84232134 -0.30547842 -0.09103423 -0.17538987 -0.09103423 -0.17538987 0.94743861 -0.10295564
[SRear] -0.15767866 -0.30547842 -0.09103423 -0.17538987 -0.09103423 -0.17538987 -0.05256139 -0.10295564 0.84232134 -0.30547842 -0.09103423 -0.17538987 -0.09103423 -0.17538987 0.94743861 -0.10295564
[SFront] -0.20158462 -0.34698498 -0.10079145 -0.17275676 -0.10078987 -0.17276275 -0.05039740 -0.08785502 0.79841538 -0.34698498 -0.10079145 -0.17275676 -0.10078987 -0.17276275 0.94960260 -0.08785502
[SRear] -0.20158462 -0.34698498 -0.10079145 -0.17275676 -0.10078987 -0.17276275 -0.05039740 -0.08785502 0.79841538 -0.34698498 -0.10079145 -0.17275676 -0.10078987 -0.17276275 0.94960260 -0.08785502
[SFront] -0.44212317 -0.46035189 -0.12762823 -0.13264339 -0.12762766 -0.13267301 -0.03684366 -0.03915826 0.55787683 -0.46035189 -0.12762823 -0.13264339 -0.12762766 -0.13267301 0.96315634 -0.03915826
[SRear] -0.44212317 -0.46035189 -0.12762823 -0.13264339 -0.12762766 -0.13267301 -0.03684366 -0.03915826 0.55787683 -0.46035189 -0.12762823 -0.13264339 -0.12762766 -0.13267301 0.96315634 -0.03915826
[SFront] -0.15767866 -0.30547842 0.09103423 0.17538987 0.09103423 0.17538987 -0.05256139 -0.10295564 0.84232134 -0.30547842 0.09103423 0.17538987 0.09103423 0.17538987 0.94743861 -0.10295564
[SRear] -0.15767866 -0.30547842 0.09103423 0.17538987 0.09103423 0.17538987 -0.05256139 -0.10295564 0.84232134 -0.30547842 0.09103423 0.17538987 0.09103423 0.17538987 0.94743861 -0.10295564
[SFront] -0.20158462 -0.34698498 0.10079145 0.17275676 0.10078987 0.17276275 -0.05039740 -0.08785502 0.79841538 -0.34698498 0.10079145 0.17275676 0.10078987 0.17276275 0.94960260 -0.08785502
[SRear] -0.20158462 -0.34698498 0.10079145 0.17275676 0.10078987 0.17276275 -0.05039740 -0.08785502 0.79841538 -0.34698498 0.10079145 0.17275676 0.10078987 0.17276275 0.94960260 -0.08785502
[SFront] -0.44212317 -0.46035189 0.12762823 0.13264339 0.12762766 0.13267301 -0.03684366 -0.03915826 0.55787683 -0.46035189 0.12762823 0.13264339 0.12762766 0.13267301 0.96315634 -0.03915826
[SRear] -0.44212317 -0.46035189 0.12762823 0.13264339 0.12762766 0.13267301 -0.03684366 -0.03915826 0.55787683 -0.46035189 0.12762823 0.13264339 0.12762766 0.13267301 0.96315634 -0.03915826

0 comments on commit 9d24a4d

Please sign in to comment.