Closed tkrisnguyen closed 2 months ago
Thanks for reporting this 🌊 Oh interesting, that is "unexpected". Which example in particular ?
I ran the cantilever.jl and clamped_truss.jl in the package. I have the message similar to what is shown below
Test Summary: | Pass Total Time Displacements at the right-most node | 3 3 0.0s Test.DefaultTestSet("Displacements at the right-most node", Any[], 3, false, false, true, 1.719540076606e9, 1.719540076606e9, false, "C:\Users\Julia\Downloads\JuliaDynFEM\vidu.jl")
This one is not error message. However, if I run step by step, the following commands
(; L, N, b, h, E, ρ, Px, Py) = parameters()
x_coords = range(0, L, N + 1)
nodes = [Node(xi, 0.0, 0.0) for xi in x_coords]
S = Rectangle(h, b)
frames = [Frame(nodes[j], nodes[j + 1], S) for j in 1:(length(nodes) - 1)]
mesh = Mesh(; nodes=nodes, elements=frames)
then, the error message appeared for the last command mesh = Mesh(; nodes=nodes, elements=frames)
Perharps I misunderstood at some point. Please show me where I was wrong in doing so.
Thank you.
Ah I see where the issue comes from, but I don't think tehre is a bug here. If the error you are obtaining is:
ERROR: cannot assign a value to imported variable ONSAS.mesh from module Main
Stacktrace:
[1] top-level scope
@ .../ONSAS.jl/examples/clamped_truss/clamped_truss.jl:35
then is beacuse when you first run using ONSAS
which exports mesh
. That means you are going to have defined in the main scope:
julia> Main.mesh
mesh (generic function with 2 methods)
so when you try to evaluate mesh = ....
you get:
julia> mesh = 2
ERROR: cannot assign a value to imported variable ONSAS.mesh from module Main
Stacktrace:
[1] top-level scope
@ REPL[2]:1
rebinding is not allowed. You can fix this either using import ONSAS
(a bit clunky) or just renaming the variable to avoid identifier conflicts:
m = Mesh(; nodes, elements)
I am not against renaming the variable in the script if that helps you :)
Is this what is going on here ?
Thank you for your explanation about the situation.
I still have another problem. I simpilified the example cantilever.jl a bit as given below
using Test
using ONSAS
"Return the problem parameters"
function parameters()
L = 3 # Length
b = 0.2 # Cross-section Width
h = 0.3 # Cross-section Height
ρ = 2400 # Material density
q = b * h * ρ * 9.81 # Distributed load
Px = 1e2 # Nodal load in x
Py = 1e3 # Nodal load in y
E = 210e9 # Elastic Young's modulus.
RTOL = 1e-4 # Relative tolerance for tests
N = 5 # Number of elements
NSTEPS = 10 # Number of load factors steps
(; b, h, ρ, q, Px, Py, E, RTOL, N, NSTEPS, L)
end
"Return the problem structural model"
function structure()
(; L, N, b, h, E, ρ, Px, Py) = parameters()
# -------------
# Mesh
# -------------
x_coords = range(0, L, N + 1)
nodes = [Node(xi, 0.0, 0.0) for xi in x_coords]
S = Rectangle(h, b)
frames = [Frame(nodes[j], nodes[j + 1], S) for j in 1:(length(nodes) - 1)]
mesh = Mesh(; nodes=nodes, elements=frames)
set_dofs!(mesh, :u, 3)
set_dofs!(mesh, :θ, 3)
# ------------------------
# Materials
# ------------------------
i = IsotropicLinearElastic(E, 0.3)
materials = StructuralMaterial(i => frames)
# -------------------------------
# Boundary conditions
# -------------------------------
bc1 = FixedDof(:u, [1, 2, 3])
bc2 = FixedDof(:θ, [1, 2, 3])
bc3 = GlobalLoad(:u, t -> [Px, -Py, 0])
boundary_conditions = StructuralBoundaryCondition(bc1 => [nodes[1]], bc2 => [nodes[1]],
bc3 => [nodes[end]])
Structure(mesh, materials, boundary_conditions)
end
"Return the problem solution"
function solve()
s = structure()
# -------------------------------
# Structural Analysis
# -------------------------------
(; NSTEPS) = parameters()
sa = NonLinearStaticAnalysis(s; NSTEPS=NSTEPS)
# -------------------------------
# Numerical solution
# -------------------------------
solve!(sa, NewtonRaphson())
end;
sol = solve()
Then, when I run it, I have got the following error message:
ERROR: type StaticState has no field iter_state
Please help me to fix this.
Thank you
True, this is an actual issue in the Base.show()
which only prints the solution in the REPL. However, the solution object sol
is correct. Feel free to open a new issue with a minimal reproducible example, and we can discuss it there.
In running some example in the package, when I run the code
mesh = Mesh(; nodes, elements)
it raises the following error message
Please show me the way to fix it.
Thank you