Skip to content

Commit

Permalink
Julia 1.9rc3 precompilation (#272)
Browse files Browse the repository at this point in the history
* Fix Julia 1.9rc3 precompilation
* fix doctests by removing non-deterministic behavior

---------

Co-authored-by: fpacaud <[email protected]>
  • Loading branch information
michel2323 and frapac authored May 16, 2023
1 parent d07036e commit 7c2037a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 78 deletions.
18 changes: 9 additions & 9 deletions docs/src/man/formulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,22 +346,22 @@ The function `pflow` follows the same API, as any regular
julia> n_balance = length(pflow)
14
julia> pflow(stack) # evaluate the power flow balance
julia> round.(pflow(stack); digits=6) # evaluate the power flow balance
14-element Vector{Float64}:
-1.63
-0.85
0.0
0.9000000000000004
0.9
0.0
1.0
0.0
1.2499999999999998
-0.1670000000000016
0.04200000000000159
-0.28349999999999653
0.17099999999999937
-0.22749999999999915
0.2590000000000039
1.25
-0.167
0.042
-0.2835
0.171
-0.2275
0.259
```
When we evaluate a [`ComposedExpressions`](@ref), ExaPF
Expand Down
6 changes: 1 addition & 5 deletions src/ExaPF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ const LS = LinearSolvers
include("Polar/polar.jl")

# CUDA extension
function __init__()
if CUDA.has_cuda()
include(joinpath(@__DIR__, "cuda_wrapper.jl"))
end
end
include("cuda_wrapper.jl")

end
85 changes: 35 additions & 50 deletions src/Polar/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,42 +374,27 @@ julia> stack = ExaPF.NetworkStack(polar);
julia> powerflow = ExaPF.PowerFlowBalance(polar) ∘ ExaPF.PolarBasis(polar);
julia> powerflow(stack)
julia> round.(powerflow(stack); digits=6)
14-element Vector{Float64}:
-1.63
-0.85
0.0
0.9000000000000004
0.9
0.0
1.0
0.0
1.2499999999999998
-0.1670000000000016
0.04200000000000159
-0.28349999999999653
0.17099999999999937
-0.22749999999999915
0.2590000000000039
1.25
-0.167
0.042
-0.2835
0.171
-0.2275
0.259
julia> run_pf(polar, stack); # solve powerflow equations
julia> powerflow(stack)
14-element Vector{Float64}:
-2.6645352591003757e-15
-2.220446049250313e-16
-3.419486915845482e-14
8.43769498715119e-15
-1.3322676295501878e-15
8.43769498715119e-15
-2.4424906541753444e-14
5.3734794391857577e-14
1.4210854715202004e-14
1.7763568394002505e-15
7.105427357601002e-15
3.552713678800501e-15
7.105427357601002e-15
2.3092638912203256e-14
julia> isapprox(powerflow(stack), zeros(14); atol=1e-8)
true
```
Expand Down Expand Up @@ -586,12 +571,12 @@ julia> run_pf(polar, stack); # solve powerflow equations
julia> power_generators = ExaPF.PowerGenerationBounds(polar) ∘ ExaPF.PolarBasis(polar);
julia> power_generators(stack)
julia> round.(power_generators(stack); digits=6)
4-element Vector{Float64}:
0.7195470158922199
0.24068957772759347
0.1446011953112496
-0.03649025534209471
0.719547
0.24069
0.144601
-0.03649
```
Expand Down Expand Up @@ -688,26 +673,26 @@ julia> run_pf(polar, stack); # solve powerflow equations
julia> line_flows = ExaPF.LineFlows(polar) ∘ ExaPF.PolarBasis(polar);
julia> line_flows(stack)
julia> round.(line_flows(stack); digits=6)
18-element Vector{Float64}:
0.5756793809060858
0.09445704301364506
0.379982836801101
0.7238315387349309
0.06016881786985958
0.5886725487812785
2.6574181040367035
0.7489430586779533
0.29535076072865407
0.560816793842092
0.11209487984261841
0.3862504895005101
0.7287262804842036
0.1171908414455606
0.5851637022788402
2.677809505685433
0.7266677622404694
0.21549662692309735
0.575679
0.094457
0.379983
0.723832
0.060169
0.588673
2.657418
0.748943
0.295351
0.560817
0.112095
0.38625
0.728726
0.117191
0.585164
2.67781
0.726668
0.215497
```
Expand Down
18 changes: 6 additions & 12 deletions src/Polar/newton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,13 @@ julia> jx = ExaPF.Jacobian(polar, powerflow, State());
julia> stack = ExaPF.NetworkStack(polar);
julia> conv = ExaPF.nlsolve!(NewtonRaphson(verbose=1), jx, stack);
#it 0: 2.64764e+00
#it 1: 2.03366e-01
#it 2: 2.94166e-03
#it 3: 8.85300e-07
#it 4: 7.52102e-14
julia> conv = ExaPF.nlsolve!(NewtonRaphson(), jx, stack);
julia> conv.has_converged
true
julia> conv.n_iterations
4
```
"""
function nlsolve!(
Expand Down Expand Up @@ -197,16 +194,13 @@ julia> polar = ExaPF.load_polar("case9");
julia> stack = ExaPF.NetworkStack(polar);
julia> conv = run_pf(polar, stack; verbose=1);
#it 0: 2.64764e+00
#it 1: 2.03366e-01
#it 2: 2.94166e-03
#it 3: 8.85300e-07
#it 4: 7.52102e-14
julia> conv = run_pf(polar, stack);
julia> conv.has_converged
true
julia> conv.n_iterations
4
```
"""
function run_pf(
Expand Down
4 changes: 2 additions & 2 deletions src/Polar/polar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ julia> const PS = ExaPF.PowerSystem;
julia> network_data = PS.load_case("case9.m");
julia> polar = PolarForm(network_data, ExaPF.CPU())
Polar formulation (instantiated on device CPU())
Polar formulation (instantiated on device CPU(false))
Network characteristics:
#buses: 9 (#slack: 1 #PV: 2 #PQ: 6)
#generators: 3
Expand Down Expand Up @@ -105,7 +105,7 @@ and PGLIB-OPF (`dir=PGLIB`).
## Examples
```jldoctest; setup=:(using ExaPF)
julia> polar = ExaPF.load_polar("case9")
Polar formulation (instantiated on device CPU())
Polar formulation (instantiated on device CPU(false))
Network characteristics:
#buses: 9 (#slack: 1 #PV: 2 #PQ: 6)
#generators: 3
Expand Down

0 comments on commit 7c2037a

Please sign in to comment.