Commit acb1c120 by Francois Gygi

removed member compute_deda (moved calc to SDCellStepper). Added

symmetric matrix - vector product function.


git-svn-id: http://qboxcode.org/svn/qb/trunk@654 cba15fb0-1239-40c8-b417-11db7ca47a34
parent cffce9c0
......@@ -15,7 +15,7 @@
// UnitCell.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: UnitCell.C,v 1.17 2008-09-08 15:56:19 fgygi Exp $
// $Id: UnitCell.C,v 1.18 2008-09-15 14:56:48 fgygi Exp $
#include "UnitCell.h"
#include <iostream>
......@@ -293,6 +293,21 @@ void UnitCell::vecmult3x3(const double* x, const double* y, double *z) const
z[2] = z2;
}
////////////////////////////////////////////////////////////////////////////////
void UnitCell::vecsmult3x3(const double* xs, const double* y, double *z) const
{
// multiply a vector by a symmetric 3x3 matrix
// | z0 | | xs0 xs3 xs5 | | y0 |
// | z1 | = | xs3 xs1 xs4 | * | y1 |
// | z2 | | xs5 xs4 xs2 | | y2 |
z[0] = xs[0]*y[0]+xs[3]*y[1]+xs[5]*y[2];
z[1] = xs[3]*y[0]+xs[1]*y[1]+xs[4]*y[2];
z[2] = xs[5]*y[0]+xs[4]*y[1]+xs[2]*y[2];
}
////////////////////////////////////////////////////////////////////////////////
void UnitCell::matmult3x3(const double* x, const double* y, double *z) const
{
......@@ -357,24 +372,6 @@ void UnitCell::smatmult3x3(const double* xs, const double* y, double *z) const
z[8] = z22;
}
////////////////////////////////////////////////////////////////////////////////
void UnitCell::compute_deda(const valarray<double>& sigma,
valarray<double>& deda) const
{
// Compute energy derivatives dE/da_ij from a symmetric stress tensor
assert(sigma.size()==6);
assert(deda.size()==9);
// local copy of sigma to circumvent bug in icc compiler
valarray<double> sigma_loc(6);
sigma_loc = sigma;
// deda = - omega * sigma * A^-T
smatmult3x3(&sigma_loc[0],&amat_inv_t_[0],&deda[0]);
deda *= -volume_;
}
////////////////////////////////////////////////////////////////////////////////
ostream& operator<< ( ostream& os, const UnitCell& cell )
{
cell.print(os);
......
......@@ -15,7 +15,7 @@
// UnitCell.h
//
////////////////////////////////////////////////////////////////////////////////
// $Id: UnitCell.h,v 1.8 2008-09-08 15:56:19 fgygi Exp $
// $Id: UnitCell.h,v 1.9 2008-09-15 14:56:48 fgygi Exp $
#ifndef UNITCELL_H
#define UNITCELL_H
......@@ -66,6 +66,10 @@ class UnitCell
// 3x3 matrix vector multiply Z = X Y where X is a 3x3 matrix, Y,Z 3-vectors
void vecmult3x3(const double* x, const double* y, double *z) const;
// 3x3 sym matrix vector multiply Z = X Y where X is a sym 3x3 matrix,
// Y,Z 3-vectors
void vecsmult3x3(const double* x, const double* y, double *z) const;
// 3x3 matrix matrix multiply Z = X Y where X, Y are 3x3 matrices
void matmult3x3(const double* x, const double* y, double *z) const;
// Z = X Y where X is a symmetric 3x3 matrix and Y a general 3x3 matrix
......@@ -73,8 +77,6 @@ class UnitCell
// where xs[0] = x00, xs[1] = x11, xs[2] = x22,
// xs[3] = x10, xs[4] = x21, xs[5] = x20
void smatmult3x3(const double* xs, const double* y, double *z) const;
void compute_deda(const std::valarray<double>& sigma,
std::valarray<double>& deda) const;
bool in_ws(const D3vector& v) const;
void fold_in_ws(D3vector& v) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment