Skip to content

Commit 412a20d

Browse files
chore(examples): remove unused example files and clean up project structure
1 parent a3a3eaa commit 412a20d

17 files changed

Lines changed: 440 additions & 413 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Manifest.toml
2727

2828
# the hidden folder of shame
2929
temp/
30+
local/
3031

3132
# Internal files
3233
dev

examples/18kV_1000mm2_trifoil_export.pscx

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

examples/525kV_1600mm2_bipole_export.pscx

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

examples/cables_library.json

Lines changed: 109 additions & 112 deletions
Large diffs are not rendered by default.

examples/materials_library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"alpha": 0.004,
109109
"__julia_type__": "LineCableModels.Materials.Material",
110110
"eps_r": 1,
111-
"mu_r": 1,
111+
"mu_r": 0.999983,
112112
"rho": 2.14e-7
113113
},
114114
"copper_corrected": {

examples/tutorial1.jl

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,86 +31,81 @@ materials with their standard properties.
3131
materials_db = MaterialsLibrary()
3232

3333
# Inspect the contents of the materials library:
34-
df_initial = list_materialslibrary(materials_db)
34+
df_initial = DataFrame(materials_db)
3535

3636
#=
37-
The function [`list_materialslibrary`](@ref) returns a `DataFrame` with all materials and their properties, namely: electrical resistivity, relative permittivity, relative permeability, reference temperature, and temperature coefficient.
37+
The function [`DataFrame`](@ref) returns a `DataFrame` with all materials and their properties, namely: electrical resistivity, relative permittivity, relative permeability, reference temperature, and temperature coefficient.
3838
=#
3939

4040
# ## Adding new materials
4141
#=
4242
!!! note "Note"
43-
New materials can be added to the library using the [`Material`](@ref) constructor followed by [`store_materialslibrary!`](@ref).
43+
New materials can be added to the library using the [`Material`](@ref) constructor followed by [`add!`](@ref).
4444
4545
It might be useful to add other conductor materials with corrected properties based on recognized standards [cigre531](@cite) [IEC60287](@cite).
4646
=#
4747

4848
copper_corrected = Material(1.835e-8, 1.0, 0.999994, 20.0, 0.00393) # Copper with corrected resistivity from IEC 60287-3-2
49-
store_materialslibrary!(materials_db, "copper_corrected", copper_corrected)
49+
add!(materials_db, "copper_corrected", copper_corrected)
5050
aluminum_corrected = Material(3.03e-8, 1.0, 0.999994, 20.0, 0.00403) # Aluminum with corrected resistivity from IEC 60287-3-2
51-
store_materialslibrary!(materials_db, "aluminum_corrected", aluminum_corrected)
51+
add!(materials_db, "aluminum_corrected", aluminum_corrected)
5252
lead = Material(21.4e-8, 1.0, 0.999983, 20.0, 0.00400) # Lead or lead alloy
53-
store_materialslibrary!(materials_db, "lead", lead)
53+
add!(materials_db, "lead", lead)
5454
steel = Material(13.8e-8, 1.0, 300.0, 20.0, 0.00450) # Steel
55-
store_materialslibrary!(materials_db, "steel", steel)
55+
add!(materials_db, "steel", steel)
5656
bronze = Material(3.5e-8, 1.0, 1.0, 20.0, 0.00300) # Bronze
57-
store_materialslibrary!(materials_db, "bronze", bronze)
57+
add!(materials_db, "bronze", bronze)
5858
stainless_steel = Material(70.0e-8, 1.0, 500.0, 20.0, 0.0) # Stainless steel
59-
store_materialslibrary!(materials_db, "stainless_steel", stainless_steel)
59+
add!(materials_db, "stainless_steel", stainless_steel)
6060

6161
#=
6262
When modeling cables for EMT analysis, one might be concerned with the impact of insulators and semiconductive layers on cable constants. Common insulation materials and semicons with different dielectric properties are reported in Table 6 of [cigre531](@cite). Let us include some of these materials in the [`MaterialsLibrary`](@ref) to help our future selves.
6363
=#
6464

6565
epr = Material(1e15, 3.0, 1.0, 20.0, 0.005) # EPR (ethylene propylene rubber)
66-
store_materialslibrary!(materials_db, "epr", epr)
66+
add!(materials_db, "epr", epr)
6767
pvc = Material(1e15, 8.0, 1.0, 20.0, 0.1) # PVC (polyvinyl chloride)
68-
store_materialslibrary!(materials_db, "pvc", pvc)
68+
add!(materials_db, "pvc", pvc)
6969
laminated_paper = Material(1e15, 2.8, 1.0, 20.0, 0.0) # Laminated paper propylene
70-
store_materialslibrary!(materials_db, "laminated_paper", laminated_paper)
70+
add!(materials_db, "laminated_paper", laminated_paper)
7171
carbon_pe = Material(0.06, 1e3, 1.0, 20.0, 0.0) # Carbon-polyethylene compound (semicon)
72-
store_materialslibrary!(materials_db, "carbon_pe", carbon_pe)
72+
add!(materials_db, "carbon_pe", carbon_pe)
7373
conductive_paper = Material(18.5, 8.6, 1.0, 20.0, 0.0) # Conductive paper layer (semicon)
74-
store_materialslibrary!(materials_db, "conductive_paper", conductive_paper)
74+
add!(materials_db, "conductive_paper", conductive_paper)
7575

7676
# ## Removing materials
7777
#=
7878
!!! note "Note"
79-
Materials can be removed from the library with the [`remove_materialslibrary!`](@ref) function.
79+
Materials can be removed from the library with the [`delete!`](@ref) function.
8080
=#
8181

8282
# Add a duplicate material by accident:
83-
store_materialslibrary!(materials_db, "epr_dupe", epr)
83+
add!(materials_db, "epr_dupe", epr)
8484

85-
# And now remove it using the [`remove_materialslibrary!`](@ref) function:
86-
remove_materialslibrary!(materials_db, "epr_dupe")
85+
# And now remove it using the [`delete!`](@ref) function:
86+
delete!(materials_db, "epr_dupe")
8787

8888
# Examine the updated library after removing the duplicate:
8989
println("Material properties compiled from CIGRE TB-531 and IEC 60287:")
90-
df_final = list_materialslibrary(materials_db)
90+
df_final = DataFrame(materials_db)
9191

9292
# ## Saving the materials library to JSON
9393
output_file = joinpath(@__DIR__, "materials_library.json")
94-
save_materialslibrary(
95-
materials_db,
96-
file_name=output_file,
97-
);
94+
save(materials_db, file_name=output_file);
9895

9996

10097
# ## Retrieving materials for use
10198
#=
10299
!!! note "Note"
103-
To load from an existing JSON file, instantiate a new [`MaterialsLibrary`](@ref) followed by a call to the [`load_materialslibrary!`](@ref) method. Materials can be retrieved from the library using the [`get_material`](@ref) function.
100+
To load from an existing JSON file, instantiate a new [`MaterialsLibrary`](@ref) followed by a call to the [`load!`](@ref) method. Materials can be retrieved from the library using the [`get`](@ref) function.
104101
=#
105102

106103
# Initialize a new [`MaterialsLibrary`](@ref) and load from the JSON file:
107104
materials_from_json = MaterialsLibrary()
108-
load_materialslibrary!(
109-
materials_from_json,
110-
file_name=output_file,
111-
)
105+
load!(materials_from_json, file_name=output_file)
106+
112107
# Retrieve a material and display the object:
113-
copper = get_material(materials_from_json, "copper_corrected")
108+
copper = get(materials_from_json, "copper_corrected")
114109

115110
# Access the material properties:
116111
println("\nRetrieved copper_corrected material properties:")

examples/tutorial2.jl

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ using LineCableModels
3939

4040
# Initialize materials library with default values:
4141
materials_db = MaterialsLibrary(add_defaults=true)
42-
list_materialslibrary(materials_db)
42+
DataFrame(materials_db)
4343

4444
#=
4545
```julia
4646
# Alternatively, it can be loaded from the example file built in the previous tutorial:
47-
load_materialslibrary!(
47+
load!(
4848
materials_db,
4949
file_name = "materials_library.json",
5050
)
@@ -191,19 +191,19 @@ The core consists of a 4-layer AAAC stranded conductor with 61 wires arranged in
191191
=#
192192

193193
# Initialize the conductor object and assign the central wire:
194-
material = get_material(materials_db, "aluminum")
194+
material = get(materials_db, "aluminum")
195195
core = ConductorGroup(WireArray(0, Diameter(d_w), 1, 0, material))
196196

197197
#=
198198
!!! tip "Convenience methods"
199-
The [`addto_conductorgroup!`](@ref) method internally passes the `radius_ext` of the existing object to the `radius_in` argument of the new conductor. This enables easy stacking of multiple layers without redundancy. Moreover, the [`Diameter`](@ref) method is a convenience function that converts the diameter to radius at the constructor level. This maintains alignment with manufacturer specifications while enabling internal calculations to use radius values directly. This approach eliminates repetitive unit conversions and potential sources of implementation error.
199+
The [`add!`](@ref) method internally passes the `radius_ext` of the existing object to the `radius_in` argument of the new conductor. This enables easy stacking of multiple layers without redundancy. Moreover, the [`Diameter`](@ref) method is a convenience function that converts the diameter to radius at the constructor level. This maintains alignment with manufacturer specifications while enabling internal calculations to use radius values directly. This approach eliminates repetitive unit conversions and potential sources of implementation error.
200200
=#
201201

202202
# Add the subsequent layers of wires and inspect the object:
203-
addto_conductorgroup!(core, WireArray, Diameter(d_w), 6, 15, material)
204-
addto_conductorgroup!(core, WireArray, Diameter(d_w), 12, 13.5, material)
205-
addto_conductorgroup!(core, WireArray, Diameter(d_w), 18, 12.5, material)
206-
addto_conductorgroup!(core, WireArray, Diameter(d_w), 24, 11, material)
203+
add!(core, WireArray, Diameter(d_w), 6, 15, material)
204+
add!(core, WireArray, Diameter(d_w), 12, 13.5, material)
205+
add!(core, WireArray, Diameter(d_w), 18, 12.5, material)
206+
add!(core, WireArray, Diameter(d_w), 24, 11, material)
207207

208208
#=
209209
### Inner semiconductor
@@ -218,12 +218,12 @@ the conductor and insulation, eliminating air gaps and reducing field concentrat
218218
=#
219219

220220
# Inner semiconductive tape:
221-
material = get_material(materials_db, "polyacrylate")
221+
material = get(materials_db, "polyacrylate")
222222
main_insu = InsulatorGroup(Semicon(core, Thickness(t_sct), material))
223223

224224
# Inner semiconductor (1000 Ω.m as per IEC 840):
225-
material = get_material(materials_db, "semicon1")
226-
addto_insulatorgroup!(main_insu, Semicon, Thickness(t_sc_in), material)
225+
material = get(materials_db, "semicon1")
226+
add!(main_insu, Semicon, Thickness(t_sc_in), material)
227227

228228
#=
229229
### Main insulation
@@ -233,8 +233,8 @@ medium and high voltage cables due to its excellent dielectric properties.
233233
=#
234234

235235
# Add the insulation layer:
236-
material = get_material(materials_db, "pe")
237-
addto_insulatorgroup!(main_insu, Insulator, Thickness(t_ins), material)
236+
material = get(materials_db, "pe")
237+
add!(main_insu, Insulator, Thickness(t_ins), material)
238238

239239
#=
240240
### Outer semiconductor
@@ -244,12 +244,12 @@ transition from insulation to the metallic screen.
244244
=#
245245

246246
# Outer semiconductor (500 Ω.m as per IEC 840):
247-
material = get_material(materials_db, "semicon2")
248-
addto_insulatorgroup!(main_insu, Semicon, Thickness(t_sc_out), material)
247+
material = get(materials_db, "semicon2")
248+
add!(main_insu, Semicon, Thickness(t_sc_out), material)
249249

250250
# Outer semiconductive tape:
251-
material = get_material(materials_db, "polyacrylate")
252-
addto_insulatorgroup!(main_insu, Semicon, Thickness(t_sct), material)
251+
material = get(materials_db, "polyacrylate")
252+
add!(main_insu, Semicon, Thickness(t_sct), material)
253253

254254
# Group core-related components:
255255
core_cc = CableComponent("core", core, main_insu)
@@ -273,7 +273,7 @@ datasheet_info = NominalData(
273273
cable_design = CableDesign(cable_id, core_cc, nominal_data=datasheet_info)
274274

275275
# At this point, it becomes possible to preview the cable design:
276-
plt1 = preview_cabledesign(cable_design)
276+
plt1 = preview(cable_design)
277277

278278
#=
279279
### Wire screens
@@ -287,23 +287,23 @@ The metallic screen (typically copper) serves multiple purposes:
287287

288288
# Build the wire screens on top of the previous layer:
289289
lay_ratio = 10 # typical value for wire screens
290-
material = get_material(materials_db, "copper")
290+
material = get(materials_db, "copper")
291291
screen_con =
292292
ConductorGroup(WireArray(main_insu, Diameter(d_ws), num_sc_wires, lay_ratio, material))
293293

294294
# Add the equalizing copper tape wrapping the wire screen:
295-
addto_conductorgroup!(screen_con, Strip, Thickness(t_cut), w_cut, lay_ratio, material)
295+
add!(screen_con, Strip, Thickness(t_cut), w_cut, lay_ratio, material)
296296

297297
# Water blocking tape over screen:
298-
material = get_material(materials_db, "polyacrylate")
298+
material = get(materials_db, "polyacrylate")
299299
screen_insu = InsulatorGroup(Semicon(screen_con, Thickness(t_wbt), material))
300300

301301
# Group sheath components and assign to design:
302302
sheath_cc = CableComponent("sheath", screen_con, screen_insu)
303-
addto_cabledesign!(cable_design, sheath_cc)
303+
add!(cable_design, sheath_cc)
304304

305305
# Examine the newly added components:
306-
plt2 = preview_cabledesign(cable_design)
306+
plt2 = preview(cable_design)
307307

308308
#=
309309
### Outer jacket components
@@ -313,27 +313,27 @@ and PE (polyethylene) outer jacket for mechanical protection.
313313
=#
314314

315315
# Add the aluminum foil (moisture barrier):
316-
material = get_material(materials_db, "aluminum")
316+
material = get(materials_db, "aluminum")
317317
jacket_con = ConductorGroup(Tubular(screen_insu, Thickness(t_alt), material))
318318

319319
# PE layer after aluminum foil:
320-
material = get_material(materials_db, "pe")
320+
material = get(materials_db, "pe")
321321
jacket_insu = InsulatorGroup(Insulator(jacket_con, Thickness(t_pet), material))
322322

323323
# PE jacket (outer mechanical protection):
324-
material = get_material(materials_db, "pe")
325-
addto_insulatorgroup!(jacket_insu, Insulator, Thickness(t_jac), material)
324+
material = get(materials_db, "pe")
325+
add!(jacket_insu, Insulator, Thickness(t_jac), material)
326326

327327
#=
328328
!!! tip "Convenience methods"
329-
To facilitate data entry, it is possible to call the [`addto_cabledesign!`](@ref) method directly on the [`ConductorGroup`](@ref) and [`InsulatorGroup`](@ref) constituents of the component to include, without instantiating the [`CableComponent`](@ref) first.
329+
To facilitate data entry, it is possible to call the [`add!`](@ref) method directly on the [`ConductorGroup`](@ref) and [`InsulatorGroup`](@ref) constituents of the component to include, without instantiating the [`CableComponent`](@ref) first.
330330
=#
331331

332332
# Assign the jacket parts directly to the design:
333-
addto_cabledesign!(cable_design, "jacket", jacket_con, jacket_insu)
333+
add!(cable_design, "jacket", jacket_con, jacket_insu)
334334

335335
# Inspect the finished cable design:
336-
plt3 = preview_cabledesign(cable_design)
336+
plt3 = preview(cable_design)
337337

338338
#=
339339
## Examining the cable parameters (RLC)
@@ -342,29 +342,29 @@ In this section, the cable design is examined and the calculated parameters are
342342
=#
343343

344344
# Compare with datasheet information (R, L, C values):
345-
core_df = to_df(cable_design, :baseparams)
345+
core_df = DataFrame(cable_design, :baseparams)
346346

347347
# Obtain the equivalent electromagnetic properties of the cable:
348-
components_df = to_df(cable_design, :components)
348+
components_df = DataFrame(cable_design, :components)
349349

350350
# Get detailed description of all cable parts:
351-
detailed_df = to_df(cable_design, :detailed)
351+
detailed_df = DataFrame(cable_design, :detailed)
352352

353353
#=
354354
## Saving the cable design
355355
356356
!!! note "Cables library"
357-
Designs can be saved to a library for future use. The [`CablesLibrary`](@ref) is a container for storing multiple cable designs, allowing for easy access and reuse in different projects. Library management is performed using the [`list_cableslibrary`](@ref), [`store_cableslibrary!`](@ref), and [`save_cableslibrary`](@ref) functions.
357+
Designs can be saved to a library for future use. The [`CablesLibrary`](@ref) is a container for storing multiple cable designs, allowing for easy access and reuse in different projects. Library management is performed using the [`DataFrame`](@ref), [`add!`](@ref), and [`save`](@ref) functions.
358358
=#
359359

360360
# Store the cable design and inspect the library contents:
361361
library = CablesLibrary()
362-
store_cableslibrary!(library, cable_design)
363-
list_cableslibrary(library)
362+
add!(library, cable_design)
363+
DataFrame(library)
364364

365365
# Save to file for later use:
366366
output_file = joinpath(@__DIR__, "cables_library.json")
367-
save_cableslibrary(library, file_name=output_file);
367+
save(library, file_name=output_file);
368368

369369

370370
#=
@@ -385,7 +385,7 @@ f = 10.0 .^ range(0, stop=6, length=10) # Frequency range
385385
earth_params = EarthModel(f, 100.0, 10.0, 1.0) # 100 Ω·m resistivity, εr=10, μr=1
386386

387387
# Earth model base (DC) properties:
388-
earthmodel_df = to_df(earth_params)
388+
earthmodel_df = DataFrame(earth_params)
389389

390390
#=
391391
### Three-phase system in trifoil configuration
@@ -400,21 +400,22 @@ y0 = -1
400400
xa, ya, xb, yb, xc, yc = trifoil_formation(x0, y0, 0.035)
401401

402402
# Initialize the `LineCableSystem` with the first cable (phase A):
403-
cablepos = CablePosition(cable_design, xa, ya, Dict("core" => 1, "sheath" => 0, "jacket" => 0))
403+
cablepos = CablePosition(cable_design, xa, ya,
404+
Dict("core" => 1, "sheath" => 0, "jacket" => 0))
404405
cable_system = LineCableSystem("18kV_1000mm2_trifoil", 1000.0, cablepos)
405406

406407
# Add remaining cables (phases B and C):
407-
addto_linecablesystem!(cable_system, cable_design, xb, yb,
408+
add!(cable_system, cable_design, xb, yb,
408409
Dict("core" => 2, "sheath" => 0, "jacket" => 0),
409410
)
410-
addto_linecablesystem!(
411+
add!(
411412
cable_system, cable_design, xc, yc,
412413
Dict("core" => 3, "sheath" => 0, "jacket" => 0),
413414
)
414415

415416
#=
416417
!!! note "Phase mapping"
417-
The [`addto_linecablesystem!`](@ref) function allows the specification of phase mapping for each cable. The `Dict` argument maps the cable components to their respective phases, where `core` is the conductor, `sheath` is the screen, and `jacket` is the outer jacket. The values (1, 2, 3) represent the phase numbers (A, B, C) in this case. Components mapped to phase 0 will be Kron-eliminated (grounded). Components set to the same phase will be bundled into an equivalent phase.
418+
The [`add!`](@ref) function allows the specification of phase mapping for each cable. The `Dict` argument maps the cable components to their respective phases, where `core` is the conductor, `sheath` is the screen, and `jacket` is the outer jacket. The values (1, 2, 3) represent the phase numbers (A, B, C) in this case. Components mapped to phase 0 will be Kron-eliminated (grounded). Components set to the same phase will be bundled into an equivalent phase.
418419
=#
419420

420421
#=
@@ -424,10 +425,10 @@ In this section the complete three-phase cable system is examined.
424425
=#
425426

426427
# Display system details:
427-
system_df = to_df(cable_system)
428+
system_df = DataFrame(cable_system)
428429

429430
# Visualize the cross-section of the three-phase system:
430-
plt4 = preview_linecablesystem(cable_system, zoom_factor=0.15)
431+
plt4 = preview(cable_system, zoom_factor=0.15)
431432

432433
#=
433434
## PSCAD export
@@ -437,7 +438,7 @@ The final step showcases how to export the model for electromagnetic transient s
437438

438439
# Export to PSCAD input file:
439440
output_file = joinpath(@__DIR__, "$(cable_system.system_id)_export.pscx")
440-
export_file = export_pscad_lcp(cable_system, earth_params, file_name=output_file);
441+
export_file = export_data(:pscad, cable_system, earth_params, file_name=output_file);
441442

442443
#=
443444
## Conclusion

0 commit comments

Comments
 (0)