Skip to content

Commit

Permalink
Merge pull request #122 from ModiaSim/Release0.12.1
Browse files Browse the repository at this point in the history
Release0.12.1
  • Loading branch information
MartinOtter authored Jun 4, 2023
2 parents f083686 + c2b2df8 commit cd95187
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 1,328 deletions.
1,259 changes: 0 additions & 1,259 deletions Manifest.toml

This file was deleted.

4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
authors = ["Andrea Neumayr <[email protected]>", "Martin Otter <[email protected]>", "Gerhard Hippmann <[email protected]>"]
name = "Modia3D"
uuid = "07f2c1e0-90b0-56cf-bda7-b44b56e34eed"
version = "0.12.0"
version = "0.12.1"

[compat]
Colors = "0.12, 0.11, 0.10"
Expand All @@ -12,7 +12,7 @@ HTTP = "0.9"
JSON = "0.21"
Measurements = "2"
MeshIO = "0.4.10"
Modia = "0.10.0"
Modia = "0.12.0"
MonteCarloMeasurements = "1"
OrderedCollections = "1"
Reexport = "1.0"
Expand Down
10 changes: 10 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ julia -JModia3D_sysimage.so (otherwise)
| [8] |*[Modelling and Simulation of Physical Systems with Dynamically Changing Degrees of Freedom](https://doi.org/10.3390/electronics12030500)*| Electronics 2023, 12(3), 500 | [10.3390/electronics12030500](https://doi.org/10.3390/electronics12030500) |

## Release Notes

### Version 0.12.1

- Adapted to Modia 0.12.0 (arguments of buildFunction in ModiaInterface had been changed,
as well as function names to define/access variables of built-in components)
- Absolute position (`r_abs`) and orientation (`R_abs`) of visible shapes are stored in the result
data structure and can be plotted (see Modia3D/test/Basid/Pendulum.jl, Modia3D/test/Segmented/TwoStageRocket3D.jl)
- Manifest.toml file removed


### Version 0.12.0
- Support for variable-structure systems where variables (states) can appear and disappear during simulation
- A simulation run is partitioned into phases that are called segments or modes (multi-mode modeling)
Expand Down
26 changes: 13 additions & 13 deletions src/Composition/ForceElements/Bushing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function torqueFromMoments(largeAngles::Bool, moments::SVector{3,F}, sico::SMatr
end


function initializeForceElement(model::Modia.SimulationModel{F,TimeType}, force::Bushing{F})::Nothing where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function initializeForceElement(model::Modia.InstantiatedModel{F,TimeType}, force::Bushing{F})::Nothing where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
force.obj1.hasForceElement = true
force.obj2.hasForceElement = true

Expand All @@ -220,7 +220,7 @@ function initializeForceElement(model::Modia.SimulationModel{F,TimeType}, force:
return nothing
end

function evaluateForceElement(model::Modia.SimulationModel{F,TimeType}, force::Bushing{F}, time::TimeType) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function evaluateForceElement(model::Modia.InstantiatedModel{F,TimeType}, force::Bushing{F}, time::TimeType) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
R12 = measFrameRotation(force.obj2; frameOrig=force.obj1)
r12 = measFramePosition(force.obj2; frameOrig=force.obj1, frameCoord=force.obj1)
w12 = measFrameRotVelocity(force.obj2; frameOrig=force.obj1, frameCoord=force.obj1)
Expand All @@ -245,17 +245,17 @@ function evaluateForceElement(model::Modia.SimulationModel{F,TimeType}, force::B
applyFrameTorquePair!(force.obj2, force.obj1, t12; frameCoord=force.obj1)

if Modia.storeResults(model)
Modia.add_w_segmented_value!(model, force.translationResultIndex, r12)
Modia.add_w_segmented_value!(model, force.rotationResultIndex, ang)
Modia.add_w_segmented_value!(model, force.velocityResultIndex, v12)
Modia.add_w_segmented_value!(model, force.rotationVelocityResultIndex, angd)
Modia.add_w_segmented_value!(model, force.springForceResultIndex, fc)
Modia.add_w_segmented_value!(model, force.springTorqueResultIndex, mc)
Modia.add_w_segmented_value!(model, force.damperForceResultIndex, fd)
Modia.add_w_segmented_value!(model, force.damperTorqueResultIndex, md)
Modia.add_w_segmented_value!(model, force.torqueResultIndex, mom)
Modia.add_w_segmented_value!(model, force.forceVectorResultIndex, -f12)
Modia.add_w_segmented_value!(model, force.torqueVectorResultIndex, -t12)
Modia.copy_w_segmented_value_to_result(model, force.translationResultIndex, r12)
Modia.copy_w_segmented_value_to_result(model, force.rotationResultIndex, ang)
Modia.copy_w_segmented_value_to_result(model, force.velocityResultIndex, v12)
Modia.copy_w_segmented_value_to_result(model, force.rotationVelocityResultIndex, angd)
Modia.copy_w_segmented_value_to_result(model, force.springForceResultIndex, fc)
Modia.copy_w_segmented_value_to_result(model, force.springTorqueResultIndex, mc)
Modia.copy_w_segmented_value_to_result(model, force.damperForceResultIndex, fd)
Modia.copy_w_segmented_value_to_result(model, force.damperTorqueResultIndex, md)
Modia.copy_w_segmented_value_to_result(model, force.torqueResultIndex, mom)
Modia.copy_w_segmented_value_to_result(model, force.forceVectorResultIndex, -f12)
Modia.copy_w_segmented_value_to_result(model, force.torqueVectorResultIndex, -t12)
end

return nothing
Expand Down
18 changes: 9 additions & 9 deletions src/Composition/ForceElements/SpringDamperPtP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ end
SpringDamperPtP(; kwargs...) = SpringDamperPtP{Float64}(; kwargs...)


function initializeForceElement(model::Modia.SimulationModel{F,TimeType}, force::SpringDamperPtP{F}) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function initializeForceElement(model::Modia.InstantiatedModel{F,TimeType}, force::SpringDamperPtP{F}) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
force.obj1.hasForceElement = true
force.obj2.hasForceElement = true

Expand All @@ -98,7 +98,7 @@ function initializeForceElement(model::Modia.SimulationModel{F,TimeType}, force:
return nothing
end

function evaluateForceElement(model::Modia.SimulationModel{F,TimeType}, force::SpringDamperPtP{F}, time::TimeType) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function evaluateForceElement(model::Modia.InstantiatedModel{F,TimeType}, force::SpringDamperPtP{F}, time::TimeType) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
(pos, norm) = measFrameDistance(force.obj2; frameOrig=force.obj1)
vel = measFrameDistVelocity(force.obj2; frameOrig=force.obj1)

Expand All @@ -111,13 +111,13 @@ function evaluateForceElement(model::Modia.SimulationModel{F,TimeType}, force::S
applyFrameForcePair!(force.obj2, force.obj1, f12; frameCoord=force.obj1)

if Modia.storeResults(model)
Modia.add_w_segmented_value!(model, force.distanceResultIndex, pos)
Modia.add_w_segmented_value!(model, force.deflectionResultIndex, defl)
Modia.add_w_segmented_value!(model, force.velocityResultIndex, vel)
Modia.add_w_segmented_value!(model, force.springForceResultIndex, fc)
Modia.add_w_segmented_value!(model, force.damperForceResultIndex, fd)
Modia.add_w_segmented_value!(model, force.forceResultIndex, frc)
Modia.add_w_segmented_value!(model, force.forceVectorResultIndex, -f12)
Modia.copy_w_segmented_value_to_result(model, force.distanceResultIndex, pos)
Modia.copy_w_segmented_value_to_result(model, force.deflectionResultIndex, defl)
Modia.copy_w_segmented_value_to_result(model, force.velocityResultIndex, vel)
Modia.copy_w_segmented_value_to_result(model, force.springForceResultIndex, fc)
Modia.copy_w_segmented_value_to_result(model, force.damperForceResultIndex, fd)
Modia.copy_w_segmented_value_to_result(model, force.forceResultIndex, frc)
Modia.copy_w_segmented_value_to_result(model, force.forceVectorResultIndex, -f12)
end

return nothing
Expand Down
6 changes: 3 additions & 3 deletions src/Composition/ForceElements/WorldForce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ end
WorldForce(; kwargs...) = WorldForce{Float64}(; kwargs...)


function initializeForceElement(model::Modia.SimulationModel{F,TimeType}, force::WorldForce{F})::Nothing where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function initializeForceElement(model::Modia.InstantiatedModel{F,TimeType}, force::WorldForce{F})::Nothing where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}

force.objectApply.hasForceElement = true
if !isnothing(force.objectCoord)
Expand All @@ -56,14 +56,14 @@ function initializeForceElement(model::Modia.SimulationModel{F,TimeType}, force:
return nothing
end

function evaluateForceElement(model::Modia.SimulationModel{F,TimeType}, force::WorldForce{F}, time::TimeType) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function evaluateForceElement(model::Modia.InstantiatedModel{F,TimeType}, force::WorldForce{F}, time::TimeType) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}

forceVector = force.forceFunction(; time=time, objectApply=force.objectApply, objectCoord=force.objectCoord)

applyFrameForce!(force.objectApply, forceVector; frameCoord=force.objectCoord)

if Modia.storeResults(model)
Modia.add_w_segmented_value!(model, force.forceVectorResultIndex, forceVector)
Modia.copy_w_segmented_value_to_result(model, force.forceVectorResultIndex, forceVector)
end

return nothing
Expand Down
6 changes: 3 additions & 3 deletions src/Composition/ForceElements/WorldTorque.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ end
WorldTorque(; kwargs...) = WorldTorque{Float64}(; kwargs...)


function initializeForceElement(model::Modia.SimulationModel{F,TimeType}, force::WorldTorque{F})::Nothing where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function initializeForceElement(model::Modia.InstantiatedModel{F,TimeType}, force::WorldTorque{F})::Nothing where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}

force.objectApply.hasForceElement = true
if !isnothing(force.objectCoord)
Expand All @@ -56,14 +56,14 @@ function initializeForceElement(model::Modia.SimulationModel{F,TimeType}, force:
return nothing
end

function evaluateForceElement(model::Modia.SimulationModel{F,TimeType}, force::WorldTorque{F}, time::TimeType) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function evaluateForceElement(model::Modia.InstantiatedModel{F,TimeType}, force::WorldTorque{F}, time::TimeType) where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}

torqueVector = force.torqueFunction(; time=time, objectApply=force.objectApply, objectCoord=force.objectCoord)

applyFrameTorque!(force.objectApply, torqueVector; frameCoord=force.objectCoord)

if Modia.storeResults(model)
Modia.add_w_segmented_value!(model, force.torqueVectorResultIndex, torqueVector)
Modia.copy_w_segmented_value_to_result(model, force.torqueVectorResultIndex, torqueVector)
end

return nothing
Expand Down
2 changes: 1 addition & 1 deletion src/Composition/_module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export isFree, isNotFree, changeJointFromFreeMotionToFix!, changeJointFromFixToF

export fullName, instanceName

# export updateSimulationModel!
# export updateInstantiatedModel!

export rot123fromR, rot132fromR, Rfromrot123, Rfromrot132

Expand Down
4 changes: 2 additions & 2 deletions src/Composition/dynamicCollision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# between objs with mpr algorithm, and use them as zero-crossing functions
# (see file ...\ContactDetectionMPR\handler.jl)
# after computing all distances between colliding shapes response calculations are done
function computeContactForcesAndTorques(sim::Modia.SimulationModel, scene, world, time, file)
function computeContactForcesAndTorques(sim::Modia.InstantiatedModel, scene, world, time, file)
if typeof(scene.options.contactDetection) <: Modia3D.ContactDetectionMPR_handler
ch::Modia3D.ContactDetectionMPR_handler = scene.options.contactDetection
# Compute signed distances of all contact shapes during zero-crossing computation
Expand Down Expand Up @@ -39,7 +39,7 @@ end
# (see file ...\Composition\responseCalculation\elasticCollisionResponse.jl)
# further, at an event simulation status is updated, contact material is replaced
# and the actual contactDict is stored
function dealWithContacts!(sim::Modia.SimulationModel{F, T}, scene::Scene{F}, ch::Composition.ContactDetectionMPR_handler{M,F}, world::Composition.Object3D{F}, time::Float64, file::Nothing)::Nothing where {F <: Modia3D.VarFloatType, T, M}
function dealWithContacts!(sim::Modia.InstantiatedModel{F, T}, scene::Scene{F}, ch::Composition.ContactDetectionMPR_handler{M,F}, world::Composition.Object3D{F}, time::Float64, file::Nothing)::Nothing where {F <: Modia3D.VarFloatType, T, M}

simh::Modia.EventHandler{F,T} = sim.eventHandler
f1::SVector{3,F}=Modia3D.ZeroVector3D(F)
Expand Down
33 changes: 26 additions & 7 deletions src/Composition/dynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ end


"""
initSegment_Model3D!(partiallyInstantiatedModel::Modia.SimulationModel,
initSegment_Model3D!(partiallyInstantiatedModel::Modia.InstantiatedModel,
modelPath::String, ID, parameters::AbstractDict; log=false)
Called once before initialization of a new simulation segment to instantiate/re-initialize a Model3D model
"""
function initSegment_Model3D!(partiallyInstantiatedModel::Modia.SimulationModel{F,TimeType},
function initSegment_Model3D!(partiallyInstantiatedModel::Modia.InstantiatedModel{F,TimeType},
modelPath::String, ID, parameters::AbstractDict; log=false)::Nothing where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
TimerOutputs.@timeit partiallyInstantiatedModel.timer "Modia3D_0 initSegment_Model3D!" begin
if log
Expand Down Expand Up @@ -174,10 +174,23 @@ function initSegment_Model3D!(partiallyInstantiatedModel::Modia.SimulationModel{
zStartIndex = 0
end

# objIndices[i,1]: Index of r_abs of Object3D i
# [i,2]: Index of R_abs of Object3D i
objIndices = Matrix{Int}(undef, length(scene.updateVisuElements), 2)
for (i,obj) in enumerate(scene.updateVisuElements)
if typeof(obj.feature) == Modia3D.Composition.EmptyObject3DFeature
objIndices[i,1] = 0
objIndices[i,2] = 0
else
objIndices[i,1] = Modia.new_w_segmented_variable!(partiallyInstantiatedModel, obj.path*".r_abs", Modia3D.ZeroVector3D(F), "m")
objIndices[i,2] = Modia.new_w_segmented_variable!(partiallyInstantiatedModel, obj.path*".R_abs", Modia3D.NullRotation(F), "")
end
end

mbsBuild.mbs = MultibodyData{F,TimeType}(partiallyInstantiatedModel, modelPath, world, scene,
revoluteObjects, prismaticObjects, freeMotionObjects, hiddenJointObjects,
mbsBuild.revoluteIndices, mbsBuild.prismaticIndices, mbsBuild.freeMotionIndices,
zStartIndex, nz)
revoluteObjects, prismaticObjects, freeMotionObjects, hiddenJointObjects,
mbsBuild.revoluteIndices, mbsBuild.prismaticIndices, mbsBuild.freeMotionIndices,
objIndices, zStartIndex, nz)
parameters[:qdd_hidden] = zeros(F, length(mbsBuild.mbs.hiddenGenForces))

if log
Expand Down Expand Up @@ -215,7 +228,7 @@ Open Model3D:
- Copy der(r):=v and der(rot):= f(w) into hidden derivatives.
- Return mbs.
"""
function openModel3D!(instantiatedModel::Modia.SimulationModel{F,TimeType}, modelPath::String, x::AbstractVector, time::TimeType)::MultibodyData{F,TimeType} where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
function openModel3D!(instantiatedModel::Modia.InstantiatedModel{F,TimeType}, modelPath::String, x::AbstractVector, time::TimeType)::MultibodyData{F,TimeType} where {F <: Modia3D.VarFloatType, TimeType <: AbstractFloat}
# println("bin in openModel3D ", instantiatedModel.eventHandler.restart)
mbsBuild::MultibodyBuild{F,TimeType} = instantiatedModel.buildDict[modelPath]

Expand Down Expand Up @@ -514,11 +527,17 @@ function computeGeneralizedForces!(mbs::MultibodyData{F,TimeType}, qdd_hidden::V
TimerOutputs.@timeit instantiatedModel.timer "Modia3D_3" begin
# objects can have interactionManner (need to rename updateVisuElements)
if scene.options.useOptimizedStructure
for obj in scene.updateVisuElements
objIndices = mbs.objIndices
for (i,obj) in enumerate(scene.updateVisuElements)
parent = obj.parent
obj.r_abs = obj.r_rel Modia3D.ZeroVector3D(F) ? parent.r_abs : parent.r_abs + parent.R_abs'*obj.r_rel
obj.R_abs = obj.R_rel Modia3D.NullRotation(F) ? parent.R_abs : obj.R_rel*parent.R_abs

if objIndices[i,1] > 0
Modia.copy_w_segmented_value_to_result(instantiatedModel, objIndices[i,1], obj.r_abs)
Modia.copy_w_segmented_value_to_result(instantiatedModel, objIndices[i,2], obj.R_abs)
end

# is executed only if an internal Object3D called
if length( obj.visualizationFrame ) == 1
obj.visualizationFrame[1].r_abs = obj.r_abs
Expand Down
Loading

0 comments on commit cd95187

Please sign in to comment.