Documentation ¶
Overview ¶
Example ¶
package main import ( "bytes" "fmt" "io/ioutil" "os" "github.com/Konstantin8105/hd" "github.com/pmezard/go-difflib/difflib" ) func main() { m := hd.Model{ Points: [][2]float64{ {0.0, 0.0}, {1.0, 0.0}, }, Beams: []hd.BeamProp{ {N: [2]int{0, 1}, A: 12e-4, J: 120e-6, E: 2.0e11}, }, Pins: [][6]bool{ {false, false, false, false, false, true}, }, Supports: [][3]bool{ {true, true, true}, {false, false, false}, }, } lcs := []hd.LoadCase{ { LoadNodes: []hd.LoadNode{ {N: 1, Forces: [3]float64{0, 2.3, 0}}, {N: 1, Forces: [3]float64{-10, 0, 0}}, }, AmountLinearBuckling: 1, }, { // test for 2 cases with different positions LoadNodes: []hd.LoadNode{ {N: 1, Forces: [3]float64{-10, 0, 0}}, {N: 1, Forces: [3]float64{0, 2.3, 0}}, }, AmountLinearBuckling: 2, }, } mcs := []hd.ModalCase{ { ModalMasses: []hd.ModalMass{{N: 1, Mass: 10000}}, }, } var b bytes.Buffer if err := hd.Run(&b, &m, lcs, mcs); err != nil { fmt.Fprintf(os.Stdout, "Cannot calculate : %v", err) return } expect, err := ioutil.ReadFile("./example/testdata/model.String") if err != nil { panic(fmt.Errorf("Cannot read file : %v", err)) } if bytes.Equal(expect, b.Bytes()) { fmt.Fprintf(os.Stdout, "same") } else { fmt.Fprintln(os.Stdout, b.String()) // show a diff between files diff := difflib.UnifiedDiff{ A: difflib.SplitLines(string(expect)), B: difflib.SplitLines(string(b.Bytes())), FromFile: "Original", ToFile: "Current", Context: 30000, } text, _ := difflib.GetUnifiedDiffString(diff) fmt.Fprintf(os.Stdout, text) fmt.Fprintf(os.Stdout, "not same") } }
Output: same
Index ¶
- Constants
- Variables
- func LinearStatic(out io.Writer, m *Model, lcs ...*LoadCase) (err error)
- func Modal(out io.Writer, m *Model, mc *ModalCase) (err error)
- func Run(out io.Writer, m *Model, lcs []LoadCase, mcs []ModalCase) (err error)
- type BeamProp
- type BucklingResult
- type ErrorBeam
- type ErrorLoad
- type ErrorModal
- type ErrorPin
- type ErrorPoint
- type LoadCase
- type LoadNode
- type ModalCase
- type ModalMass
- type ModalResult
- type Model
Examples ¶
Constants ¶
View Source
const Gravity float64 = 9.80665
Gravity is Earth gravity constant, m/sq.sec.
Variables ¶
View Source
var ErrorAmountModel = goerrors.New("Model isn`t single calculation model")
ErrorAmountModel error if calculation model is not single. Calculate calculation models separetaly.
View Source
var ErrorBeamAmount = goerrors.New("Zero beams with non-zero amount of points")
ErrorBeamAmount error if calculation model have points, but haven`t beams.
Functions ¶
func LinearStatic ¶
LinearStatic run linear static analysis.
Types ¶
type BeamProp ¶
type BeamProp struct { // Start and end point index // // [0] - start of beam // [1] - end of beam // N [2]int // A cross-section area // Unit : sq. meter. A float64 // J is moment inertia // Unit : meter^4 J float64 // E is modulus of elasticity // Unit : Pa E float64 }
BeamProp is beam property
type BucklingResult ¶
type BucklingResult struct { // Buckling factor // Return data. Factor float64 // Point displacement in global system coordinate. // Return data. // // first index is point index // // [0] - X // [1] - Y // [2] - M // // Unit: relative PointDisplacementGlobal [][3]float64 }
BucklingResult is result of buckling calculation
type ErrorModal ¶
ErrorModal error in modal case data
func (ErrorModal) Error ¶
func (e ErrorModal) Error() string
type ErrorPoint ¶
ErrorPoint error in point data
func (ErrorPoint) Error ¶
func (e ErrorPoint) Error() string
type LoadCase ¶
type LoadCase struct { // LoadNodes is node loads in global system coordinate LoadNodes []LoadNode // Point displacement in global system coordinate. // Return data. // // first index is point index // // [0] - X // [1] - Y // [2] - M // // Unit: meter and rad. PointDisplacementGlobal [][3]float64 // BeamForces is beam forces in local system coordinate. // Return data. // // first index is beam index // // [0] - Fx on start point // [1] - Fy on start point // [2] - M on start point // [3] - Fx on end point // [4] - Fy on end point // [5] - M on end point // // Unit: N and N*m BeamForces [][6]float64 // Reactions is reaction loads in support points. // Return data. // // first index is point index // // [0] - Fx // [1] - Fy // [2] - M // // Unit: N and N*m Reactions [][3]float64 // Amount of calculated forms. // If Amount is zero or less zero, then no calculate. // LinearBuckling is linear buckling calculation AmountLinearBuckling uint16 // Result of linear buckling calculation LinearBucklingResult []BucklingResult }
LoadCase is summary combination of loads
type LoadNode ¶
type LoadNode struct { // N is point index N int // Forces is node loads on each direction // // [0] - X , Unit: N. Positive direction from left to right. // [1] - Y , Unit: N. Positive direction from down to top. // [2] - M , Unit: N*m. Positive direction is counter-clockwise direction. // Forces [3]float64 }
LoadNode is node load on specific point in global system coordinate
type ModalCase ¶
type ModalCase struct { // ModalMasses is modal masses ModalMasses []ModalMass // Result of modal calculation Result []ModalResult }
ModalCase is modal calculation case
type ModalResult ¶
type ModalResult struct { // Natural frequency Hz float64 // Modal displacament in global system coordinate // // first index is point index // // [0] - X direction // [1] - Y direction // [2] - M direction // // Unit: Dimensionless ModalDisplacement [][3]float64 }
ModalResult is result of modal calculation
type Model ¶
type Model struct { // Points is slice of point coordinate // // [0] - X coordinate // [1] - Y coordinate // Points [][2]float64 // Beams is slice of point index and beam property Beams []BeamProp // Pins is slice of pins for beams in local system coordinate. // Len of support must be same amount of beam. // Or if len is zero, then all DoF(degree of freedom) is rigid. // // first index is point index // // [0] - X on start point // [1] - Y on start point // [2] - M on start point // [3] - X on end point // [4] - Y on end point // [5] - M on end point // // if `true` then free degree of freedom Pins [][6]bool // Supports is slice of fixed supports. // Len of support must be same amount of Points // // first index is point index // // [0] - X // [1] - Y // [2] - M // Supports [][3]bool }
Model is structural calculation model
Click to show internal directories.
Click to hide internal directories.