Skip to content

Commit ec92702

Browse files
committed
avoid calculating z if not needed in profile_from_z_transport
1 parent e1eae53 commit ec92702

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/physics/transport.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ function profile_from_z_transport(
1818
z_transport_grid::AbstractVector{<:Real},
1919
rho_ped::Real=0.0)
2020

21-
z = calc_z(rho, profile_old)
22-
2321
transport_indices = [argmin(abs.(rho .- rho_x)) for rho_x in transport_grid]
2422
index_ped = argmin(abs.(rho .- rho_ped))
2523
index_last = transport_indices[end]
2624
if index_ped > index_last
25+
z_old = calc_z(rho, profile_old)
2726
transport_indices = vcat(1, transport_indices, index_ped)
28-
z_transport_grid = vcat(0.0, z_transport_grid, z[index_ped])
27+
z_transport_grid = vcat(0.0, z_transport_grid, z_old[index_ped])
2928
else
3029
transport_indices = vcat(1, transport_indices)
3130
z_transport_grid = vcat(0.0, z_transport_grid)
3231
end
3332

34-
z[1:index_last] = interp1d(transport_indices, z_transport_grid).(1:index_last)
33+
z = interp1d(transport_indices, z_transport_grid).(1:index_last)
3534

3635
profile_new = similar(profile_old)
3736
profile_new[index_last:end] = @views profile_old[index_last:end]
38-
profile_new[1:index_last] = @views integ_z(rho[1:index_last], -z[1:index_last], profile_new[index_last])
37+
profile_new[1:index_last] = @views integ_z(rho[1:index_last], -z, profile_new[index_last])
3938

4039
return profile_new
4140
end

0 commit comments

Comments
 (0)