# Stiffness Matrix and mass matrix

Hi.

I would like to solve Frequency Response Analysis by my own code.

Is it possible to get stiffness and mass matrix from karamba model?

Hi @R.omae,
yes it is possible via a C# script. See GitHub - karamba3d/K3D_tests: Unit tests for the Finite Element Toolkit Karamba3D, Algorithms/NaturalVibes_tests.cs for general examples.

You can use the following method:

/// —
/// Calculate the structures natural frequencies and mode shapes.
/// —
/// “in_model”: Model to be analyzed.
/// “from_shape_ind”: index of first natural vibration mode to be calculated. Numbering starts from one.
/// “shapes_num”: number of modes to be calculated.
/// “max_iter”: maximum number of vector iterations in the Mises procedure.
/// “eps”: convergence criteria for determining the eigenvalues.
/// “disp”: displacement pattern for calculating participation factors.
/// “scaling”: type of scaling applied to the mode shapes.
/// “nat_frequencies”: frequencies of the natural vibration mode in Hz.
/// “modal_masses”: modal mass of the corresponding natural vibration mode.
/// “lumped_masses”: vectors of lumped masses of each node.
/// “participation_facs”: participation-factor in global x-, y- and z-direction.
/// “participation_facs_disp”: participation-factors with respect to displacement pattern.
/// “out_model”: model with vibration modes as load-case results.
/// returns: Calculated model.
public virtual Model NaturalVibes(
Model in_model,
int from_shape_ind,
int shapes_num,
int max_iter,
double eps,
List<double> disp,
EigenShapesScalingType scaling,
out List<double> nat_frequencies,
out List<double> modal_masses,
out List<Vector3> lumped_masses,
out List<Vector3> participation_facs,
out List<double> participation_facs_disp,
out Model out_model)

This method resides in Karamba.Factories.FactoryAlgorithms of KarambaCommon.dll.

– Clemens

Do you mean that I can solve natural vibration by “Model NaturalVibes” method, or I can get mass and stiffness matrix via “Model NaturalVibes” method?

If later is right, would you please tell me more detail how to get them ?

Thank you.

With the above method you can solve the model for the natural vibration modes and get out the lumped masses at the nodes.
– Clemens

Ok, I’ve got the point. I’ll try it.

Hi,

I would like to get the stiffness matrix for analysing its eigenvalues. Is there any solution for extracting this matrix from the model ?

Martin

Hi @martin.steinmetz,
at the moment it is not possible to get out the stiffness matrix. I could add a corresponding method to the API.
– Clemens