pystran.model module#

Define the functions for defining and manipulating a model.

pystran.model.add_beam_member(m, mid, connectivity, sect)[source]#

Add a beam member to the model.

Parameters:
  • m – Model.

  • mid – The member identifier, which must be unique, but can be anything that is a legal dictionary key (integer, string, …).

  • connectivity – The list (or a tuple) of the joint identifiers.

  • sect – Section of appropriate type (2d or 3d beam section).

Returns:

Newly created member.

Return type:

dict

See also

section.beam_2d_section(), section.beam_3d_section()

Add degree-of-freedom links between all joints in the list jids in the direction dof.

Parameters:
  • m – The model.

  • jids – The list of joint identifiers.

  • dof – The degree of freedom at which the joints are to be linked.

Return type:

None

See also

None

pystran.model.add_joint(m, jid, coordinates, dof=None)[source]#

Add a joint to the model.

Parameters:
  • m – Model.

  • jid – The joint identifier, which must be unique, but can be anything that is a legal dictionary key (integer, string, …),

  • coordinates – The list (or a tuple) of coordinates of the joint; the input is converted to an array.

  • dof – Optional: the degrees of freedom of the joint as a list (or a tuple). If provided, do not use number_dofs() later on.

Returns:

Newly created joint.

Return type:

dict

pystran.model.add_load(j, dof, value)[source]#

Add a load to a joint.

Parameters:
  • j – The joint (obtained from the model as m["joints"][jid]).

  • dof – The degree of freedom (0, 1, …).

  • value – The signed magnitude of the load.

Return type:

None

See also

None

pystran.model.add_mass(j, dof, value)[source]#

Add a mass to a joint.

Parameters:
  • j – The joint (obtained from the model as m["joints"][jid]).

  • dof – The degree of freedom (0, 1, …). Refer to the module freedoms.

  • value – The magnitude of the added mass.

Return type:

None

See also

None

Add a rigid link member to the model.

Parameters:
  • m – Model.

  • mid – The member identifier, which must be unique, but can be anything that is a legal dictionary key (integer, string, …),

  • connectivity – The list (or a tuple) of the joint identifiers; the first is the master (its motion determines the motion of the subordinate), the second is the subordinate (its motion follows that of the master).

  • sect – Section of appropriate type (i.e. rigid link section).

Returns:

Newly created member.

Return type:

dict

See also

rigid_link_section()

pystran.model.add_spring_member(m, mid, connectivity, sect)[source]#

Add a spring member to the model.

Parameters:
  • m – Model.

  • mid – The member identifier, which must be unique, but can be anything that is a legal dictionary key (integer, string, …),

  • connectivity – The list (or a tuple) of the joint identifiers.

  • sect – Section of appropriate type (i.e. a spring section).

Returns:

Newly created member.

Return type:

dict

See also

spring_section()

pystran.model.add_support(j, dof, value=0.0)[source]#

Add a support to a joint.

Parameters:
  • j – The joint (obtained from the model as m["joints"][jid]).

  • dof – The degree of freedom (0, 1, …). Refer to the module freedoms.

  • value – The signed magnitude of the support motion (default is zero).

Return type:

None

See also

None

pystran.model.add_truss_member(m, mid, connectivity, sect)[source]#

Add a truss member to the model.

Parameters:
  • m – Model.

  • mid – The member identifier, which must be unique, but can be anything that is a legal dictionary key (integer, string, …).

  • connectivity – The list (or a tuple) of the joint identifiers.

  • sect – Section of appropriate type (i.e. a truss section).

Returns:

Newly created member.

Return type:

dict

pystran.model.bounding_box(m)[source]#

Compute the bounding box of the model.

Parameters:

m – The model.

Returns:

Array of the lower and upper ranges (i.e. the bounding box that encloses all the joints).

Return type:

array

pystran.model.characteristic_dimension(m)[source]#

Compute the characteristic dimension of the model.

This is the average of the dimensions of the bounding box.

Parameters:

m – The model.

Returns:

Characteristic dimension.

Return type:

float

pystran.model.create(dim=2)[source]#

Create a new model.

Parameters:

dim – Supply the dimension of the model (2 or 3).

Return type:

dict

pystran.model.free_body_check(m)[source]#

Check the balance of the structure as a free body.

All the active forces and moments together with the reactions at all the supports should sum to zero.

statics_reactions() must be called before this function as this calculation relies on the presence of reactions at the joints.

Parameters:

m – The model.

Returns:

Array of resultant forces and moments.

Return type:

array

pystran.model.ndof_per_joint(m)[source]#

How many degrees of freedom are there per joint?

Parameters:

m – The model.

Returns:

Number of the degrees of freedom per joint. Depends on the space dimension of the model and the presence or absence of beams.

Return type:

int

pystran.model.number_dofs(m)[source]#

Number degrees of freedom.

All current information about degrees of freedom will be replaced when this function is done.

After this function returns, m["nfreedof"] will be the number of free degrees of freedom, and m["ntotaldof"] will be the total number of degrees of freedom.

The degrees of freedom are numbered in the order of free and then prescribed.

Parameters:

m – The model.

Return type:

None

pystran.model.refine_member(m, mid, n)[source]#

Refine a beam member by replacing it with n new members.

The new joints are numbered starting from zero, and the joint identifier is composed of the member identifier plus the serial number of the new joint.

The new member identifiers are stored under the key "descendants" in the refined member. The refined member is removed from the list of beam members.

Parameters:
  • m – The model.

  • mid – The identifier of the member to be refined.

  • n – The number of new beam members to replace the old member with.

Return type:

None

pystran.model.remove_loads(m)[source]#

Remove all the nodal loads in the model.

Parameters:

m – The model.

pystran.model.remove_supports(m)[source]#

Remove all the nodal supports in the model.

Parameters:

m – The model.

pystran.model.set_solution(m, V)[source]#

Set the displacement solution from a vector.

Parameters:
  • m – The model.

  • V – The displacement vector. Either of length m["nfreedof"] for only the free degrees of freedom, or of length m["ntotaldof"] for the total number of degrees of freedom.

Return type:

None

See also

number_dofs()

pystran.model.solve_free_vibration(m)[source]#

Solve the free vibration of the discrete model.

The free vibration eigenvalue problem is solved for the eigenvalues and eigenvectors (can be retrieved as m["eigvals"] and m["eigvecs"]). The frequencies are computed from the eigenvalues (can be retrieved as m["frequencies"]).

The equation of free vibration is

\[K \cdot V = \omega^2 M \cdot V\]

where \(M\) is the mass matrix, \(V\) is the eigenvector, and \(\omega\) is the angular frequency.

number_dofs() must be called before this function.

Parameters:

m – The model.

Return type:

None

See also

number_dofs()

pystran.model.solve_statics(m)[source]#

Solve the static equilibrium of the discrete model.

This function solves the equation of static equilibrium

\[K \cdot U = F\]

Here \(K\) is the stiffness matrix, \(U\) is the displacement vector, and \(F\) is the vector of forces acting on the joints.

Note that the degrees of freedom can be partitioned into ‘free’ (unknown) and ‘data’ (given, i.e. prescribed).

\[\begin{split}\left[ \begin{array}{cc} K_{ff} & K_{fd} \\ K_{df} & K_{dd} \\ \end{array}\right] \cdot \left[ \begin{array}{cc} U_{f} \\ U_{d} \\ \end{array}\right] = \left[ \begin{array}{cc} L_{f} \\ L_{d} + R\\ \end{array}\right]\end{split}\]

Here \(L_f\) is the vector of active loads applied to the free degrees of freedom, and \(L_d\) is the vector of active loads applied to the data degrees of freedom. The reactions \(R\) due to supports act on the prescribed (data) degrees of freedom.

The system of equations is solved for the free degrees of freedom as

\[K_{ff} \cdot U_{f} = -K_{fd} \cdot U_{d} +L_{f}\]

Note: number_dofs() must be called before this function to number the degrees of freedom, automatically. Alternatively, the user may specify the numbers of the degrees of freedom when defining the joints: the manual way.

Parameters:

m – The model.

Return type:

None

See also

number_dofs()

pystran.model.statics_reactions(m)[source]#

Compute the reactions in the static equilibrium of the discrete model.

The partitioned system of the balance equations reads

\[\begin{split}\left[ \begin{array}{cc} K_{ff} & K_{fd} \\ K_{df} & K_{dd} \\ \end{array}\right] \cdot \left[ \begin{array}{cc} U_{f} \\ U_{d} \\ \end{array}\right] = \left[ \begin{array}{cc} L_{f} \\ L_{d} + R\\ \end{array}\right]\end{split}\]

Here \(L_f\) is the vector of active loads applied to the free degrees of freedom, and \(L_d\) is the vector of active loads applied to the data degrees of freedom. The reactions \(R\) due to supports act on the prescribed (data) degrees of freedom.

The system of equations is solved for the reactions as

\[R = K_{ff} \cdot U_{f} + K_{fd} \cdot U_{d} -L_{d}\]

once \(U_f\) has been solved for in the solve_statics() step.

The reactions are distributed to the joints, and can be retrieved from individual joint dictionaries j as j['reactions'].

Parameters:

m – The model.

Return type:

None

See also

solve_statics()