TBTK
BackwardDifference.h
Go to the documentation of this file.
1 /* Copyright 2018 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_BACKWARD_DIFFERENCE
24 #define COM_DAFER45_TBTK_BACKWARD_DIFFERENCE
25 
27 
28 namespace TBTK{
29 
32 public:
41  unsigned int subindex,
42  const Index &index,
43  double dx = 1.
44  );
45 };
46 
48  unsigned int subindex,
49  const Index &index,
50  double dx
51 ){
52  TBTKAssert(
53  subindex < index.getSize(),
54  "BackwardDifference::BackwardDifference()",
55  "Invalid subindex. The subindex '" << subindex << "' is larger"
56  << " than the size of the Index '" << index.getSize() << "'.",
57  ""
58  );
59  TBTKAssert(
60  index[subindex] > 0,
61  "BackwardDifference::BackwardDifference()",
62  "Invalid subindex value. Unable to add a backward difference"
63  " for subindex '" << subindex << "' at '" << index.toString()
64  << "' since the backward difference would contain a negative"
65  << " subindex.",
66  "Modify the domain of the differential equation to ensure that"
67  << " no negative subindices are needed."
68  );
69 
70  Index backward = index;
71  backward[subindex]--;
72  pushBack(HoppingAmplitude(1/dx, index, backward));
73  pushBack(HoppingAmplitude(-1/dx, index, index));
74 }
75 
76 }; //End of namespace TBTK
77 
78 #endif
List of HoppingAmplitudes .
Definition: HoppingAmplitudeList.h:34
BackwardDifference(unsigned int subindex, const Index &index, double dx=1.)
Definition: BackwardDifference.h:47
Hopping amplitude from state &#39;from&#39; to state &#39;to&#39;.
Definition: HoppingAmplitude.h:49
HoppingAmplitudeList corresponding to a backward difference.
Definition: BackwardDifference.h:31
Flexible physical index.
Definition: Index.h:70
Definition: ModelFactory.h:35
unsigned int getSize() const
Definition: Index.h:342
void pushBack(const HoppingAmplitude &hoppingAmplitude)
Definition: HoppingAmplitudeList.h:85
List of HoppingAmplitudes .
std::string toString() const
Definition: Index.h:265