Skip to content

Commit

Permalink
Update 2015-3-12-DFT_code_for_atoms.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Qian committed Dec 23, 2016
1 parent a9157bd commit 578bb49
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions physics/2015-3-12-DFT_code_for_atoms.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
---
layout: post
title: 基于密度泛函理论(DFT),使用matlab求解原子状态
tags:
- quantum mechanics
---
# 基于密度泛函理论(DFT),使用matlab求解原子状态

* 使用自洽场方法求解 Kohn-Sham 方程

Expand Down Expand Up @@ -64,7 +59,7 @@ $$

主程序:

{% highlight matlab %}
```matlab
%For double occupation
N = 4; % num of enectrons
g = 50 % num of lattices
Expand Down Expand Up @@ -124,11 +119,11 @@ for iter = 1:5 %Do the main loop not for ever
end
%scatter3(X(1:10:g3),Y(1:10:g3),Z(1:10:g3),n(1:10:g3)*1000);
scatter3(X,Y,Z,n*4); //show electron density
{% endhighlight %}
```

用Davidson method 求解本征值和本征向量:

{% highlight matlab %}
```matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Usage: Get lowest eigenvalue and cooresponding Evetor by Davidson's method
Expand All @@ -153,8 +148,7 @@ for i=1:iter %"for loop": for faster convergent
PSI = PSI(:,1:(N/2));
E = E(1:(N/2)); %Pick lowest N/2 eigen vectors and values
end

{% endhighlight %}
```

## 结果

Expand Down Expand Up @@ -183,4 +177,4 @@ Total energy: -10.793

<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</script>

0 comments on commit 578bb49

Please sign in to comment.