Skip to content

Commit

Permalink
Adding tests for strain functions
Browse files Browse the repository at this point in the history
  • Loading branch information
max-radin committed Oct 24, 2021
1 parent 4ce4d29 commit 0654c5f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
9 changes: 0 additions & 9 deletions strain2deformation.m

This file was deleted.

9 changes: 9 additions & 0 deletions strain_to_deformation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function [ F ] = strain_to_deformation( E )
%STRAIN_TO_DEFORMATION Construct a deformation tensor from a strain tensor.
% F = strain_to_deformation( E ) computes the rotation-free deformation
% tensor F corresponding to the Green-Lagrange strain tensor E.

[Q, D] = eig(2*E+eye(size(E)));
F = Q*D.^0.5*Q';

end
6 changes: 3 additions & 3 deletions strain_tensor_to_order_params.m → strain_to_order_params.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function [ strain_order_parameters ] = strain_tensor_to_order_params( E )
%STRAIN_TENSOR_TO_ORDER_PARAMS Convert a strain tensor to order parameters.
% e = strain_tensor_to_order_params( E ) converts a strain tensor E,
function [ strain_order_parameters ] = strain_to_order_params( E )
%STRAIN_TO_ORDER_PARAMS Convert a strain tensor to order parameters.
% e = strain_to_order_params( E ) converts a strain tensor E,
% represented by a 3x3 matrix, to a 6x1 matrix e representing the strain
% order parameters. See Phys. Rev. B 90, 224105 (2014) for details.

Expand Down
4 changes: 4 additions & 0 deletions tests/strain_to_deformation_test.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
%% Test zero strain
F = strain_to_deformation(zeros(3));
expected_F = eye(3);
assert(all(F == expected_F))
4 changes: 4 additions & 0 deletions tests/strain_to_order_params_test.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
%% Test zero strain
order_params = strain_to_order_params(zeros(3));
expected_order_params = zeros(6,1);
assert(all(order_params == expected_order_params))

0 comments on commit 0654c5f

Please sign in to comment.