plot_theta_sz2.py 2.02 KB
Newer Older
1 2 3 4
import odeg as od
import matplotlib.pyplot as plt
import numpy as np
from time import time
5
from numba import njit
6 7 8 9 10 11 12 13 14 15
plt.rcParams['figure.dpi'] = 300
plt.rcParams['savefig.dpi'] = 300

# plots fxc and hxc over theta

if __name__ == '__main__':
    
    cfg = {
        'r0': 1,
        'rs': 2,
16
        'p_max': 5,
17 18
        'pos_charge': 5,
        'theta': np.arange(1e-4, 2.01, 1e-2),
19
        # 'mu_tol': 1e-6,
20
        'path': "../results",
21 22 23 24 25 26 27
        }
    
    r0_grid = np.array([.5, 1.])
    rs_grid = np.array([2., 4., 8.])
    
    fig_shape = (np.size(rs_grid), np.size(r0_grid))
    fig, axes = plt.subplots(*fig_shape, sharex = True, figsize = (7, 6))
28
    data = np.zeros((*fig_shape, cfg['theta'].size))
29 30 31 32 33 34 35 36
    
    for rs_ind, rs in enumerate(rs_grid):
        for r0_ind, r0 in enumerate(r0_grid):
            start = time()
            
            cfg['rs'] = rs
            cfg['r0'] = r0
            
37
            data[rs_ind, r0_ind, :] = od.fctExp(od.sz2Fct, **cfg)
38
            
39
            line, = axes[rs_ind, r0_ind].plot(cfg['theta'], data[rs_ind, r0_ind, :])
40 41 42 43 44 45 46
            
            print(f"rs:{rs}, r0:{r0}, time: {time()-start}")
            
            
    
    for ax in axes[-1]:
        ax.set_xlabel(r"$\Theta$")
47 48 49
    
    for ax in axes[:, 0]:
        ax.set_ylabel(r"$\langle \hat S_z ^2 \rangle$")
50 51 52 53 54 55 56 57 58
        
    # following 10 lines are copied from https://stackoverflow.com/a/25814386

    for ax, r0 in zip(axes[0], r0_grid):
        ax.annotate(r"$r_0 = $" + str(r0), xy=(0.5, 1), xytext=(0, 20),
                    xycoords='axes fraction', textcoords='offset points',
                    size='large', ha='center', va='baseline')
    
    for ax, rs in zip(axes[:,0], rs_grid):
59
        ax.annotate(r"$r_{\mathrm{s}} = $" + str(rs), xy=(0, 0.5), xytext=(-60, 0),
60 61 62 63
                    xycoords='axes fraction', textcoords='offset points',
                    size='large', ha='right', va='center')
            
    
64
    # fig.legend(loc = 'right')
65 66 67 68 69 70
    fig.tight_layout()
    fig.subplots_adjust(left=0.15, top=0.95)