- From the deformation data, you can calculate the strain. For small deformations, strain can often be approximated as the gradient of the displacement field.
- With the strain, you can then use the material's constitutive model to calculate stress. For a linear elastic material, this is generally done using Hooke's law.

# Is it possible to calculate stress in matlab using M,K matrix from ANSYS?

9 views (last 30 days)

Show older comments

Hello,

Is it possible to calculate stress similar to ANSYS using stiffness, mass matrix, and mesh data exported from ANSYS in MATLAB? I have successfully obtained the final deformation using the HHT-alpha method, which is ANSYS's transient analysis algorithm with M and K matrix. Although there is a slight difference in values, I believe it's due to the error in calculating the inverse matrix. Now, I want to calculate the stress using the deformation but I'm having difficulty grasping which method to apply. Is it possible to write code entirely on my own without using the PDE toolbox to achieve stress values similar to ANSYS?

I would greatly appreciate it if you could provide me with any related code, materials, or detail methods.

##### 0 Comments

### Answers (1)

Himanshu
on 28 May 2024

Hey Daeho,

It is possible to calculate stress from deformation data in MATLAB without the PDE toolbox. The calculation of stress from deformation depends on stress, strain, and deformation in the material.

Since you mentioned that you have calculated the deformatoin, the next step would be to calculate the stress and strain.

This following example code snippet assumes you have a simple model and you're working with linear elasticity. Please adjust the parameters according to your requirements:

% Calculate D, the elasticity matrix for plane stress

E = 210e9; % Example for steel, in Pascals

nu = 0.3; % Typical for steel

D = E / (1 - nu^2) * [1, nu, 0; nu, 1, 0; 0, 0, (1 - nu) / 2];

% For each element, calculate strain and then stress

for elem = 1:size(elementNodes, 1)

% Extract nodal coordinates and displacements for the current element

nodes = elementNodes(elem, :);

elemCoords = nodeCoordinates(nodes, :);

elemD = deformation(nodes, :);

% Calculate strain for the element - simplified, depends on element type

% This step is highly dependent on your element type and mesh

% For example, for a 2D triangular element:

% B = ... % Calculate the strain-displacement matrix B

% strain = B * elemD(:);

% Calculate stress

stress = D * strain;

% Store or process the stress as needed

% ...

end

Here, E is the Young's modulus, nu is the Poisson's ratio, deformation is a matrix of nodal displacements obtained from your analysis, elementNodes is a matrix defining nodes for each element, nodeCoordinates is a matrix defining the x, y coordinates of each node.

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!