diff --git a/src/BasicElements.jl b/src/BasicElements.jl index 54473ea..441e653 100644 --- a/src/BasicElements.jl +++ b/src/BasicElements.jl @@ -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 @@ -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) @@ -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 @@ -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 @@ -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) @@ -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ₛ,λₛ) diff --git a/src/ModelDescription.jl b/src/ModelDescription.jl index 9b5a483..a8d9557 100644 --- a/src/ModelDescription.jl +++ b/src/ModelDescription.jl @@ -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`.