Skip to content

Commit

Permalink
Reorganize some
Browse files Browse the repository at this point in the history
  • Loading branch information
Maginor committed Sep 9, 2024
1 parent 89b5a89 commit 92dd6ca
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 601 deletions.
258 changes: 129 additions & 129 deletions example_notebooks/basic_julia.ipynb

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions mobius_jl/mobius.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ end

function copy_str(str::Cstring)::String
# This is super weird, there should be an inbuilt function for converting Cstring->String, but I can't find it.
# It is a bit hacky that we hijack the internal memory of the String and write to it, but it works I guess.
len = @ccall strlen(str::Cstring)::Csize_t
result = " "^len
@ccall memcpy(Base.unsafe_convert(Cstring, result)::Cstring, str::Cstring, len::Csize_t)::Ptr{Cvoid}
Expand All @@ -200,7 +201,9 @@ function get_dates(var_ref::Var_Ref)::Vector{DateTime}
start_d = " "^32
ccall(get_start_date_h, Cstring, (Ptr{Cvoid}, Cint, Cstring),
var_ref.data, var_ref.var_id.type, start_d)

#TODO: We have to detect if the string contains timestamp or not

start_d_str = first(start_d, 10)
start_date = DateTime(Date(start_d_str))

Expand All @@ -219,8 +222,11 @@ end

function make_index(index::Any)::Mobius_Index_Value
if typeof(index) == String
# NOTE: The unsafe_convert is safe since the value only needs to stay in memory until the end of this
# function call
# NOTE: The unsafe_convert is actually in this case safe.
# The value only needs to stay in memory until the end of the
# scope that calls make_indexes, and the String will have been
# constructed in a higher scope than that. Just don't export
# make_indexes for use outside this module, and it will be fine.
return Mobius_Index_Value(Base.unsafe_convert(Cstring, index), -1)
elseif isinteger(index)
return Mobius_Index_Value(C_NULL, index)
Expand Down
10 changes: 5 additions & 5 deletions models/modules/easylake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ Authors: François Clayer, Magnus D. Norling
f^(1/(theta+2)) => [m]
}

# This formula is integral(A(z)*T(z)dz, 0, z_e) where T(z) is the temperature profile in the hypolimnion, set in this model to be
# T(z) = ((T_e - T_b)*(z/z_0)^2 + T_b
# where T_e is epilimnion temperature and T_b is bottom temperature
# Can be symbolically integrated e.g. in sympy:
# This formula is the integral(A(z)*T(z)dz, 0, z_e) where T(z) is the temperature profile in the hypolimnion, set in this model to be
# T(z) = ((T_e - T_b)*(z/z_0)^2 + T_b,
# T_e is epilimnion temperature and T_b is bottom temperature
# It can be symbolically integrated e.g. in sympy:
# integrate((((T_e - T_b)/z_e**2)*z**2 + T_b)*((z/z_0)**(theta+1)), (z, 0, z_e))
hypo_temperature_integral : function(A_0 : [m 2], T_e : [deg_c], T_b : [deg_c], z_e : [m], z_0 : [m], theta : []) {
(2*T_b + (theta+2)*T_e)*A_0*((z_e^3)*(z_e/z_0)^(theta+1))/((theta^2 + 6*theta + 8)*z_e^2)
(2*T_b + (theta+2)*T_e)*A_0*z_e*(z_e/z_0)^(theta+1)/(theta^2 + 6*theta + 8)
}

var(epi.water, [m 3], "Epilimnion volume") @initial { shape_section_V(A_surf, z_outflow, z_outflow, z_outflow-th, theta) }
Expand Down
127 changes: 0 additions & 127 deletions test/.ipynb_checkpoints/test_lv-checkpoint.ipynb

This file was deleted.

1 change: 0 additions & 1 deletion test/compile.bat

This file was deleted.

3 changes: 0 additions & 3 deletions test/config.txt

This file was deleted.

81 changes: 0 additions & 81 deletions test/prelim_test.cpp

This file was deleted.

252 changes: 0 additions & 252 deletions test/python_test.ipynb

This file was deleted.

1 change: 0 additions & 1 deletion test/setupvc.bat

This file was deleted.

0 comments on commit 92dd6ca

Please sign in to comment.