NEML2 2.0.0
Loading...
Searching...
No Matches
CrystalGeometry.h
1// Copyright 2024, UChicago Argonne, LLC
2// All Rights Reserved
3// Software Name: NEML2 -- the New Engineering material Model Library, version 2
4// By: Argonne National Laboratory
5// OPEN SOURCE LICENSE (MIT)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23// THE SOFTWARE.
24
25#pragma once
26
27#include "neml2/models/Data.h"
28#include "neml2/tensors/indexing.h"
29
30namespace neml2
31{
32class Scalar;
33class Vec;
34class R2;
35class SR2;
36class WR2;
37class MillerIndex;
38
39namespace crystallography
40{
41
47class CrystalGeometry : public Data
48{
49public:
52
54 CrystalGeometry(const OptionSet & options);
55
57 CrystalGeometry(const OptionSet & options,
58 const R2 & cclass,
59 const Vec & lattice_vectors,
60 const MillerIndex & slip_directions,
61 const MillerIndex & slip_planes);
62
64 Vec a1() const;
66 Vec a2() const;
68 Vec a3() const;
69
71 Vec b1() const;
73 Vec b2() const;
75 Vec b3() const;
76
78 Size nslip() const;
80 Size nslip_groups() const;
82 Size nslip_in_group(Size i) const;
83
85 const Vec & cartesian_slip_directions() const { return _cartesian_slip_directions; };
87 const Vec & cartesian_slip_planes() const { return _cartesian_slip_planes; };
89 const Scalar & burgers() const { return _burgers; };
90
92 const R2 & A() const { return _A; };
94 const SR2 & M() const { return _M; };
96 const WR2 & W() const { return _W; };
97
99 const R2 & symmetry_operators() const { return _sym_ops; };
100
102 // The slice happens along the last intermediate axis
103 template <class Derived,
104 typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<Derived>, Derived>>>
105 Derived slip_slice(const Derived & tensor, Size grp) const;
106
107private:
109 CrystalGeometry(const OptionSet & options, Factory * factory);
110
112 CrystalGeometry(const OptionSet & options,
113 const R2 & cclass,
114 const Vec & lattice_vectors,
115 std::tuple<Vec, Vec, Scalar, std::vector<Size>> slip_data);
116
118 static Vec make_reciprocal_lattice(const Vec & lattice_vectors);
119
121 static std::tuple<Vec, Vec, Scalar, std::vector<Size>>
122 setup_schmid_tensors(const Vec & A,
123 const R2 & cls,
124 const MillerIndex & slip_directions,
125 const MillerIndex & slip_planes);
126
127private:
129 const R2 & _sym_ops;
131 const Vec & _lattice_vectors;
133 const Vec & _reciprocal_lattice_vectors;
135 const MillerIndex & _slip_directions;
137 const MillerIndex & _slip_planes;
138
140 const Vec & _cartesian_slip_directions;
142 const Vec & _cartesian_slip_planes;
144 const Scalar & _burgers;
146 const std::vector<Size> _slip_offsets;
147
149 const R2 & _A;
151 const SR2 & _M;
153 const WR2 & _W;
154};
155
156template <class Derived, typename>
157Derived
158CrystalGeometry::slip_slice(const Derived & tensor, Size grp) const
159{
160 if (grp >= nslip_groups())
161 throw NEMLException("Invalid slip group index");
162 return tensor.intmd_slice(-1, indexing::Slice(_slip_offsets[grp], _slip_offsets[grp + 1]));
163}
164
165} // namespace crystallography
166} // namespace neml2
Definition Data.h:40
Definition Factory.h:65
Represention of a crystal direction or plane a Miller Index.
Definition MillerIndex.h:38
Factory * factory() const
Get the factory that created this object.
Definition NEML2Object.h:92
Definition errors.h:34
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:51
Base class for second order tensor.
Definition R2.h:49
The symmetric second order tensor.
Definition SR2.h:46
Scalar.
Definition Scalar.h:38
3-vector.
Definition Vec.h:43
A skew-symmetric second order tensor, represented as an axial vector.
Definition WR2.h:43
Defines the geometry of a crystal system This includes a basic definition of the crystal lattice,...
Definition CrystalGeometry.h:48
Vec b3() const
accessor for the third reciprocal lattice vector
Definition CrystalGeometry.cxx:155
const R2 & symmetry_operators() const
Accessor for the crystal class symmetry operators.
Definition CrystalGeometry.h:99
const R2 & A() const
Accessor for the full Schmid tensors.
Definition CrystalGeometry.h:92
const Vec & cartesian_slip_directions() const
Accessor for the slip directions.
Definition CrystalGeometry.h:85
const WR2 & W() const
Accessor for the skew-symmetric Schmid tensors.
Definition CrystalGeometry.h:96
Vec a1() const
accessor for the first lattice vector
Definition CrystalGeometry.cxx:125
const SR2 & M() const
Accessor for the symmetric Schmid tensors.
Definition CrystalGeometry.h:94
const Scalar & burgers() const
Accessor for the burgers vector.
Definition CrystalGeometry.h:89
const Vec & cartesian_slip_planes() const
Accessor for the slip planes.
Definition CrystalGeometry.h:87
CrystalGeometry(const OptionSet &options)
Setup from parameter set.
Definition CrystalGeometry.cxx:74
Derived slip_slice(const Derived &tensor, Size grp) const
Slice a Tensor to provide only the batch associated with a slip system.
Definition CrystalGeometry.h:158
Size nslip() const
Total number of slip systems.
Definition CrystalGeometry.cxx:161
Vec a3() const
accessor for the third lattice vector
Definition CrystalGeometry.cxx:137
Size nslip_in_group(Size i) const
Number of slip systems in a given group.
Definition CrystalGeometry.cxx:174
Vec b2() const
accessor for the second reciprocal lattice vector
Definition CrystalGeometry.cxx:149
Size nslip_groups() const
Number of slip groups.
Definition CrystalGeometry.cxx:167
static OptionSet expected_options()
Input options.
Definition CrystalGeometry.cxx:51
Vec a2() const
accessor for the second lattice vector
Definition CrystalGeometry.cxx:131
Vec b1() const
accessor for the first reciprocal lattice vector
Definition CrystalGeometry.cxx:143
Definition DiagnosticsInterface.cxx:30
int64_t Size
Definition types.h:65