JuliaFEM / JuliaFEM.jl

The JuliaFEM software library is a framework that allows for the distributed processing of large Finite Element Models across clusters of computers using simple programming models. It is designed to scale up from single servers to thousands of machines, each offering local computation and storage.
http://juliafem.github.io/JuliaFEM.jl/latest/
MIT License
250 stars 66 forks source link

where do I find NLsolve? #181

Closed francispoulin closed 4 years ago

francispoulin commented 6 years ago

I am trying to run this tutorial and it uses NLsolve but I can't seem to load it when I try

Pkg.add("NLsolve")

Is this something I can find elsewhere/

https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/docs/tutorials/2015-05-23-one-element-solution.ipynb

u``` sing NLsolve

function solve()

free_dofs = [3, 4, 5, 6]
u = zeros(2, 4)
F = zeros(2, 4)
F[2, 3] = -2.0

function f(u_)
    u[free_dofs] = u_
    T = f_int(X, u, dNdξ, λ, μ)
    R = T-F
    return R[free_dofs]
end

# Go!
sol = nlsolve(not_in_place(f), zeros(4), store_trace=true, show_trace=true)
println(sol)
u[free_dofs] = sol.zero
return u

end

u = solve()

francispoulin commented 6 years ago

Sorrry, my mistake. I tried using NLsolve and that worked fine, as did defining the function. What it didn't seem to like was the u = solve().

The error I get is the following.


Iter     f(x) inf-norm    Step 2-norm 
------   --------------   --------------
BoundsError: attempt to access 1-element Array{Array{Float64,2},1} at index [2]

Stacktrace:
 [1] dNdξ(::Array{Array{Float64,2},1}) at ./In[2]:5
 [2] J at ./In[3]:6 [inlined]
 [3] f_int(::Array{Array{Float64,2},1}, ::Array{Float64,2}, ::#dNdξ, ::Float64, ::Float64, ::Int64) at ./In[3]:23
 [4] (::#f#3{Array{Int64,1},Array{Float64,2},Array{Float64,2}})(::Array{Float64,1}) at ./In[6]:10
 [5] (::NLsolve.#f!#19{#f#3{Array{Int64,1},Array{Float64,2},Array{Float64,2}}})(::Array{Float64,1}, ::Array{Float64,1}) at /home/fpoulin/.julia/v0.6/NLsolve/src/utils.jl:41
 [6] (::NLsolve.#fg!#3{Symbol,NLsolve.#f!#19{#f#3{Array{Int64,1},Array{Float64,2},Array{Float64,2}}}})(::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,2}) at /home/fpoulin/.julia/v0.6/NLsolve/src/differentiable_functions.jl:21
 [7] trust_region_(::NLsolve.DifferentiableMultivariateFunction, ::Array{Float64,1}, ::Float64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Float64, ::Bool) at /home/fpoulin/.julia/v0.6/NLsolve/src/trust_region.jl:105
 [8] #nlsolve#11(::Symbol, ::Float64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Function, ::Float64, ::Bool, ::Int64, ::Float64, ::NLsolve.#nlsolve, ::NLsolve.DifferentiableMultivariateFunction, ::Array{Float64,1}) at /home/fpoulin/.julia/v0.6/NLsolve/src/nlsolve_func_defs.jl:26
 [9] (::NLsolve.#kw##nlsolve)(::Array{Any,1}, ::NLsolve.#nlsolve, ::NLsolve.DifferentiableMultivariateFunction, ::Array{Float64,1}) at ./<missing>:0
 [10] #nlsolve#13(::Symbol, ::Float64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Function, ::Float64, ::Bool, ::Int64, ::Float64, ::Bool, ::NLsolve.#nlsolve, ::NLsolve.#f!#19{#f#3{Array{Int64,1},Array{Float64,2},Array{Float64,2}}}, ::Array{Float64,1}) at /home/fpoulin/.julia/v0.6/NLsolve/src/nlsolve_func_defs.jl:80
 [11] (::NLsolve.#kw##nlsolve)(::Array{Any,1}, ::NLsolve.#nlsolve, ::Function, ::Array{Float64,1}) at ./<missing>:0
 [12] solve() at ./In[6]:16
 [13] include_string(::String, ::String) at ./loading.jl:515