Skip to content

Commit 395b767

Browse files
committed
Fix resonance example
1 parent d15e225 commit 395b767

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

examples/atomistic/dynamic_spectrum/deal.py renamed to examples/atomistic/dynamic_spectrum/plot_results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def deal_plot(Hy=0):
1414
#N = 8000
1515

1616
dt = ts[1] - ts[0]
17-
print 'dt=',dt
17+
print('dt=',dt)
1818

1919
freq = np.fft.fftshift(np.fft.fftfreq(N, dt))
2020

@@ -33,7 +33,7 @@ def deal_plot(Hy=0):
3333
ix = (b*c-a*d)/(a*a+b*b)
3434

3535
ind = np.argmax(ix)
36-
print ind, freq[ind]*2*np.pi
36+
print(ind, freq[ind]*2*np.pi)
3737
w_ix = np.array([freq*2*np.pi, ix])
3838
#np.savetxt('w_ix.txt',np.transpose(w_ix))
3939

examples/atomistic/dynamic_spectrum/dyn.py renamed to examples/atomistic/dynamic_spectrum/run_simulation.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
global_nx = 174
1111
global_ny = 150
12-
global_mesh = CuboidMesh(nx=global_nx,ny=global_ny, pbc='2d')
12+
global_mesh = CuboidMesh(nx=global_nx,ny=global_ny, periodicity=[True, True, False])
1313

1414
def init_m(pos):
1515
x,y,z = pos
@@ -36,15 +36,13 @@ def init_m(pos):
3636
return m2
3737

3838
def sinc_fun(t):
39-
4039
w = 0.1
41-
4240
return np.sinc(w*t)
4341

4442
def relax_system(mesh, Hy=0):
4543

4644
sim=Sim(mesh,name='relax')
47-
sim.set_options(rtol=1e-10,atol=1e-12)
45+
sim.driver.set_tols(rtol=1e-10,atol=1e-12)
4846
sim.driver.alpha = 0.5
4947
sim.driver.gamma = 1.0
5048
sim.mu_s = 1.0
@@ -66,15 +64,15 @@ def relax_system(mesh, Hy=0):
6664
zeeman = Zeeman([0,Hy,2e-2],name='H')
6765
sim.add(zeeman)
6866

69-
sim.relax(dt=2.0, stopping_dmdt=1e-8, max_steps=10000, save_m_steps=100, save_vtk_steps=50)
67+
sim.relax(dt=2.0, stopping_dmdt=1e-7, max_steps=10000, save_m_steps=100, save_vtk_steps=50)
7068

7169
np.save('m0.npy',sim.spin)
7270

7371
def excite_system(mesh, Hy=0):
7472

7573
sim=Sim(mesh,name='dyn')
7674

77-
sim.set_options(rtol=1e-10,atol=1e-12)
75+
sim.driver.set_tols(rtol=1e-10,atol=1e-12)
7876
sim.driver.alpha = 0.04
7977
sim.driver.gamma = 1.0
8078
sim.mu_s = 1.0
@@ -99,13 +97,10 @@ def excite_system(mesh, Hy=0):
9997
dt = 5
10098
steps = 2001
10199
for i in range(steps):
102-
103100
sim.run_until(i*dt)
104-
#sim.save_m()
105-
106-
#print 'sim t=%g'%(i*dt)
101+
sim.save_m()
102+
print("step {}/{}".format(i, steps))
107103

108104
if __name__=='__main__':
109-
110105
relax_system(global_mesh)
111106
excite_system(global_mesh)

0 commit comments

Comments
 (0)