Skip to content

Commit

Permalink
changed input to ElementCost and ElementConstraint
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeMaincon committed Jul 20, 2023
1 parent 8fe76b2 commit 3bac1e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/BasicElements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ as input to the `ElementCost` constructor.
`X`, `U` and `A` are the degrees of freedom of the element `ElementType`.
- `costargs=(;)` A named tuple of additional arguments to the cost function
- `ElementType` The named of the constructor for the relevant element
- `elementkwargs...` Additional named arguments to the `ElementCost` constructor are passed on to the `ElementType` constructor.
- `elementkwargs` A named tuple containing the named arguments of the `ElementType` constructor.
# Requestable internal variables
Expand All @@ -90,7 +90,7 @@ From the target element once can request
@once cost(eleres,X,U,A,t) = eleres.Fh^2
ele1 = addelement!(model,ElementCost,[nod1];req=@request(Fh),
cost=cost,ElementType=AnchorLine,
Λₘtop=[5.,0,0], xₘbot=[250.,0], L=290., buoyancy=-5e3)
elementkwargs=(Λₘtop=[5.,0,0], xₘbot=[250.,0], L=290., buoyancy=-5e3))
```
See also: [`SingleDofCost`](@ref), [`DofCost`](@ref), [`@request`](@ref)
Expand All @@ -101,7 +101,7 @@ struct ElementCost{Teleobj,Treq,Tcost,Tcostargs} <: AbstractElement
cost :: Tcost
costargs :: Tcostargs
end
function ElementCost(nod::Vector{Node};req,cost,costargs=(;),ElementType,elementkwargs...)
function ElementCost(nod::Vector{Node};req,cost,costargs=(;),ElementType,elementkwargs)
eleobj = ElementType(nod;elementkwargs...)
return ElementCost(eleobj,(eleres=req,),cost,costargs)
end
Expand Down Expand Up @@ -417,7 +417,7 @@ The Lagrangian multiplier introduced by this optimisation constraint is of class
`:positive` or `:off` at any time. An `:off` constraint
will set the Lagrange multiplier to zero.
- `ElementType` The named of the constructor for the relevant element
- `elementkwargs...` Additional named arguments to the `ElementCost` constructor are passed on to the `ElementType` constructor.
- `elementkwargs` A named tuple containing the named arguments of the `ElementType` constructor.
# Requestable internal variables
Expand All @@ -435,8 +435,8 @@ From the target element on can request
@once gap(eleres,X,U,A,t) = eleres.Fh^2
ele1 = addelement!(model,ElementCoonstraint,[nod1];req=@request(Fh),
gap,λinod=1,λfield=:λ,mode=equal,
ElementType=AnchorLine,Δxₘtop=[5.,0,0], xₘbot=[250.,0],
L=290., buoyancy=-5e3)
ElementType=AnchorLine,
elementkwargs=(Δxₘtop=[5.,0,0], xₘbot=[250.,0],L=290., buoyancy=-5e3))
```
See also: [`Hold`](@ref), [`DofConstraint`](@ref), [`off`](@ref), [`equal`](@ref), [`positive`](@ref), [`@request`](@ref)
Expand All @@ -451,7 +451,7 @@ struct ElementConstraint{Teleobj,λinod,λfield,Nu,Treq,Tg,Tgargs,Tmode} <: Abst
λₛ :: 𝕣
end
function ElementConstraint(nod::Vector{Node};λinod::𝕫, λfield::Symbol,
req,gap::Function,gargs=(;),mode::Function,gₛ::𝕣=1.,λₛ::𝕣=1.,ElementType,elementkwargs...)
req,gap::Function,gargs=(;),mode::Function,gₛ::𝕣=1.,λₛ::𝕣=1.,ElementType,elementkwargs)
eleobj = ElementType(nod;elementkwargs...)
Nu = getndof(typeof(eleobj),:U)
return ElementConstraint{typeof(eleobj),λinod,λfield,Nu,typeof((eleres=req,)),typeof(gap),typeof(gargs),typeof(mode)}(eleobj,(eleres=req,),gap,gargs,mode,gₛ,λₛ)
Expand Down
10 changes: 6 additions & 4 deletions src/ModelDescription.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,18 @@ addelement!(model::Model,::Type{E},nodID::AbstractVector{NodID};kwargs...) where
"""
setscale!(model;scale=nothing,Λscale=nothing)
Provides an order of magnitude for each type of dof in the model.
Provide scaling value for each type (class and field) of dof in the model.
This is usued to improve the conditioning of the incremental problems and
for convergence criteria. `scale` is a `NamedTuple` with fieldnames within
`X`, `U` and `A`. Each field is itself a `NamedTuple` with fieldnames being
dof fields, and value being the expected order of magnitude.
For example `scale = (X=(tx=10,rx=1),A=(drag=3.))` should be read as: X-dofs
of field `:tx` are in tens of meters, `:rx` are in radians, and A-dofs of
field `drag` are of the order of 3. All other degrees of freedom are expected
to be roughly of the order of 1.
of field `:tx` are scaled by 10 moters, `:rx` by radians, and A-dofs of
field `drag` by 3. All other degrees of freedom are scaled by 1.
Determining scaling coefficients that improve the condition number of
incremental matrices is a hard problem.
`Λscale` is a scalar. The scale of a Λ-dof will be deemed to be the scale of the
corresponding X-dof, times `Λscale`.
Expand Down

0 comments on commit 3bac1e7

Please sign in to comment.