Type Library¶
This library contains classes related to basic types used in SAMSON, in particular for mathematical operations.
See also
SAMSON API: sbdtypelibrary
This module is already imported in the Python Scripting Element as follows
from samson.DataModel import Type
Random number generator¶
This class implements the Mersenne Twister generator from the paper: M. Matsumoto and T. Nishimura, “Mersenne Twister: A 623-dimensionally equidistributed uniform pseudorandom number generator”, ACM Trans. on Modeling and Computer Simulation Vol. 8, No. 1, January pp.3-30 (1998).
rand = sam.DataModel.Type.random()
# Generates a random number on [0,1]-real-interval
rand.randDouble1()
Note that the default constructor of samson.DataModel.Type.random
has a fixed seed. This is useful when debugging code,
since it allows for reproducible results. For a “production run”, though, a samson.DataModel.Type.random
object should be seeded with a random number,
for example using samson.Facade.SAMSON.getTime()
rand = sam.DataModel.Type.random(sam.Facade.SAMSON.getTime())
# create a random UUID
rand.randUUID()
See also
SAMSON API: sbdtyperandom
Physical constants¶
See also
SAMSON API: sbdtypeconstant
You can access the physical constants in the following way:
Type.constant.Pi
Type.constant.Pi * Type.constant.RadToDeg
Type.constant.kB
Three-dimensional physical vectors¶
See also
SAMSON API: sbdtypephysicalvector3
Examples:
Type.vector3() # creates a dimensionless zero vector
Type.vector3(1, 2, 3) # creates a dimensionless vector
Type.vector3([1, 2, 3]) # creates a dimensionless vector
Type.vector3(Quantity.position(1)) # creates a vector with the same components
Type.vector3(Quantity.squareTime(1))
Type.vector3(Quantity.position(1.14), Quantity.position(3.14), Quantity.position(2.7))
Convenience constructors:
These convenience constructors can be used to create the commonly used physical vectors as follows, without specifying the Quantity unit:
Type.force3(0.0) # creates a vector with the same components in force units
Type.position3(0.0, 1.0, 2.0) # creates a position vector in length units
These convenience constructors internaly call vector3 with proper Quantity unit:
Type.dimensionless3(1, 2, 3) == Type.vector3(1, 2, 3) # True
Type.position3(0.0, 1.0, 2.0) == Type.vector3(Quantity.position(0), Quantity.position(1), Quantity.position(2)) # True
Three-dimensional physical interval vectors¶
See also
SAMSON API: sbdtypephysicaliavector3
Convenience constructors: