丁二烯Hubbard模型的计算程序

因为没有给定参数,所以参数t和u全都用字符串代替,而且之后的解矩阵运算也没办法进行。

如果给定参数而不是用字符串表示,那么整个程序的效率会更高,而且之后可以继续写具体的矩阵运算过程。

#include <iostream>
#include <bitset>
#include <string>
#include <fstream>

using namespace std;

const int atoms = 4;
const int configurations = (atoms * (atoms - 1)) * (atoms * (atoms - 1)) / 4;

bitset<2 * atoms> waves[configurations];

int main()
{
	//定义输出文件
	//组态数据
	ofstream configwaves("configurations.out", ofstream::out | ofstream::trunc);
	//矩阵元数据
	ofstream matrix("Hamiltonian.out", ofstream::out | ofstream::trunc);
	
	//组态计算
	configwaves << "atoms = " << atoms << endl;
	configwaves << "configurations = " << configurations << endl;
	configwaves << "-----------------------------------------" << endl;
	
	//定义必要的变量
	int index = 0;
	bitset<2 * atoms> iwave;
	
	//生成Sz=0的所有组态
	//注意bitset输出之后是从后向前读的 
	for(int alpha_i = 0; alpha_i != 2 * (atoms - 1); alpha_i += 2) {
		iwave.set(alpha_i);
		for(int alpha_j = alpha_i + 2; alpha_j != 2 * atoms; alpha_j += 2) {
			iwave.set(alpha_j);
			for(int beta_i = 0; beta_i != 2 * (atoms - 1); beta_i += 2) {
			 	iwave.set(beta_i + 1);
			 	for(int beta_j = beta_i + 2; beta_j != 2 * atoms; beta_j += 2) {
			 		iwave.set(beta_j + 1);
			 		waves[index] = iwave;
			 		//为了可读性,输出便于阅读的组态
			 		configwaves << "index = " << index << endl; 
			 		if(alpha_i <= beta_i) {
			 			
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值