Skip to content

Commit 4f3aec3

Browse files
feat(showcase): introduce width-aware TwoColumn struct and update display logic
1 parent bc881b5 commit 4f3aec3

2 files changed

Lines changed: 70 additions & 50 deletions

File tree

binder/start

Lines changed: 0 additions & 6 deletions
This file was deleted.

showcase/showcase1.jl

Lines changed: 70 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,53 @@ ul#recent{ max-height: none; }
9696

9797
# ╔═╡ 4462e48f-0d08-4ad9-8dd9-12f4f5912f38
9898
begin
99-
struct TwoColumn{A, B}
100-
left::A
101-
right::B
102-
end
99+
struct TwoColumn{A,B}
100+
left::A
101+
right::B
102+
end
103103

104-
function Base.show(io, mime::MIME"text/html", tc::TwoColumn)
105-
write(io,
106-
"""
107-
<div style="display: flex;">
108-
<div style="flex: 50%;">
109-
""")
110-
show(io, mime, tc.left)
111-
write(io,
112-
"""
113-
</div>
114-
<div style="flex: 50%;">
115-
""")
116-
show(io, mime, tc.right)
117-
write(io,
118-
"""
119-
</div>
120-
</div>
121-
""")
122-
end
104+
# New light wrapper that carries widths (percentages)
105+
struct TwoColumnWithWidths{A,B}
106+
left::A
107+
right::B
108+
widths::NTuple{2,Float64} # (left%, right%)
109+
end
110+
111+
# Convenience “constructor” with keywords — old calls still work,
112+
# new calls with kws return the width-aware wrapper
113+
TwoColumn(left, right; left_pct::Real=50.0, right_pct::Real=50.0) =
114+
TwoColumnWithWidths{typeof(left), typeof(right)}(left, right, (float(left_pct), float(right_pct)))
115+
116+
# Original show (defaults to 50/50)
117+
function Base.show(io, mime::MIME"text/html", tc::TwoColumn)
118+
write(io, """
119+
<div style="display:flex;">
120+
<div style="flex: 50%;">""")
121+
show(io, mime, tc.left)
122+
write(io, """
123+
</div>
124+
<div style="flex: 50%;">""")
125+
show(io, mime, tc.right)
126+
write(io, """
127+
</div>
128+
</div>""")
129+
end
130+
131+
# New show for width-aware variant
132+
function Base.show(io, mime::MIME"text/html", tc::TwoColumnWithWidths)
133+
l, r = tc.widths
134+
write(io, """
135+
<div style="display:flex;">
136+
<div style="flex: $(l)%;">""")
137+
show(io, mime, tc.left)
138+
write(io, """
139+
</div>
140+
<div style="flex: $(r)%;">""")
141+
show(io, mime, tc.right)
142+
write(io, """
143+
</div>
144+
</div>""")
145+
end
123146

124147
struct Foldable{C}
125148
title::String
@@ -443,30 +466,32 @@ TwoColumn(
443466

444467
# ╔═╡ a3f5a8c5-4ab9-4a33-abab-7907ffab1347
445468
md"""
446-
## Enhanced cable modeling
469+
## Uncertainty quantification in cable parameters
447470
"""
448471

449-
# ╔═╡ 3ff0eea3-9f1d-487f-a752-be6462f4bfb7
450-
md"""$(LocalResource(joinpath(@__DIR__, "..", "docs", "src", "assets", "logo.svg"), :width => 120, :style => "float: left; margin-right: 40px; margin-bottom: 20px;"))
451-
### LineCableModels.jl
452-
##### Toolbox developed in Julia language to compute the electrical parameters of coaxial arbitrarily-layered underground/overhead cables with uncertainty quantification. It focuses on calculating line and cable impedances and admittances in the frequency-domain, accounting for skin effect, insulation properties, and earth-return impedances with frequency-dependent soil models.
453-
454-
#### Overview
455-
456-
- **Comprehensive cable modeling:** Detailed representation of conductors (solid, tubular, stranded), insulation layers, screens, armoring, and semicons.
457-
- **Line and cable constants:** Accurate DC and AC parameters (R, L, C, G) with correction factors for temperature, stranding, and helical effects.
458-
- **Propagation characteristics:** Rigorous electromagnetic models for cable internal impedances and earth-return paths.
459-
- **Multiple solvers:** Analytical formulations, finite element modeling, and interfaces to EMT programs, including PSCAD.
460-
- **Materials and cables library:** Store and reuse standardized material properties and cable designs across projects.
461-
- **Open-source:** Under active development, multi-purpose, with complete documentation and examples in the `LineCableModels.jl` [repository](https://electa-git.github.io/LineCableModels.jl/).
462-
463-
#### Uncertainty quantification
472+
# ╔═╡ 382252ca-ede1-4043-b921-7834e59810cb
473+
md"""
474+
#### - Physical quantities are treated as nominal values associated to the corresponding uncertainties, i.e. ``\hat{x} = x ± \delta x``, ``\hat{y} = y ± \delta y``. Uncertainties are propagated according to the linear error propagation theory by using the package `Measurements.jl`.
475+
"""
464476

465-
- Every physical quantity represented in `LineCableModels.jl` is treated as a nominal value associated to an uncertainty, i.e. ``x ± \delta x``. Uncertainties are propagated according to the linear error propagation theory by using the package `Measurements.jl`.
477+
# ╔═╡ 96121e5b-6b5b-4ab1-81d0-6dcbe924cda2
466478

467-
$(LocalResource(joinpath(@__DIR__, "..", "assets", "img", "cable_dark_mode.svg"), :width => 800, :style => "display: block; margin-top: 50px; margin-left: auto; margin-right: auto;"))
479+
TwoColumn(
480+
md"""
481+
$(LocalResource(joinpath(@__DIR__, "..", "assets", "img", "cable_dark_mode.svg"), :width => 800, :style => "display: block; margin-top: 50px; margin-left: auto; margin-right: auto;"))
482+
""",
483+
md"""
484+
#### - Addition and subtraction:
485+
#### ``\hat{z} = \hat{x} \pm \hat{y} = (x \pm y) \pm \sqrt{(\delta x)^2 + (\delta y)^2}``
486+
#### - Multiplication and division:
487+
#### ``\hat{z} = (x \cdot y \text{ or } x/y) \pm \delta z``
488+
#### ``\frac{\delta z}{|z|} = \sqrt{\left(\frac{\delta x}{x}\right)^2 + \left(\frac{\delta y}{y}\right)^2}``
489+
#### - For an arbitrary function ``f(\hat{x}, \hat{y}, ...)``
490+
#### ``\delta f = \sqrt{\left( \frac{\partial f}{\partial x} \delta x \right)^2 + \left( \frac{\partial f}{\partial y} \delta y \right)^2 + \dots }``
468491
469-
"""
492+
!!! warning "Warning"
493+
Even when subtracting the nominal values ($x-y$), the uncertainties are still combined, leading to a larger total uncertainty.
494+
"""; left_pct=65, right_pct=35)
470495

471496

472497
# ╔═╡ a8ea0da0-36f1-44d4-9415-d3041f34c23f
@@ -953,14 +978,15 @@ md"""
953978
# ╟─3e6a9c64-827d-4491-bcac-252ee7b1dc81
954979
# ╟─877a84cc-979f-48c9-ac41-59be60b4850b
955980
# ╟─a3f5a8c5-4ab9-4a33-abab-7907ffab1347
956-
# ╟─3ff0eea3-9f1d-487f-a752-be6462f4bfb7
981+
# ╟─382252ca-ede1-4043-b921-7834e59810cb
982+
# ╟─96121e5b-6b5b-4ab1-81d0-6dcbe924cda2
957983
# ╟─a8ea0da0-36f1-44d4-9415-d3041f34c23f
958984
# ╟─f5fa7e28-97a7-456b-87a9-5ac4b76be9d4
959985
# ╟─8c2eaef0-4e01-41b9-b1a6-a20dfa9b2d57
960986
# ╟─cb8f01ae-26e0-44ce-8347-298ab692ac63
961987
# ╟─29222f8e-fb07-4bdb-8939-f18e668d2037
962988
# ╟─c1595a9d-7882-4b66-a1fc-fe6de19f1ef6
963-
# ╟─c13e262c-2dd2-43da-a01b-a95adb7eaa7d
989+
# ╠═c13e262c-2dd2-43da-a01b-a95adb7eaa7d
964990
# ╠═c2539b01-ac04-48e4-a973-6a5d8a0e2b58
965991
# ╠═c7c7ce65-3a0c-4ac6-82f0-f9f58e46f47e
966992
# ╟─062439db-1e3f-497e-96c1-e1f65f80399b

0 commit comments

Comments
 (0)