microsoft / svirl

Svirl is GPU-accelerated solver of complex Ginzburg-Landau equations for superconductivity. It consists of time-dependent solver to describe vortex dynamics and free energy minimizer to accurately find static configurations.
MIT License
21 stars 11 forks source link

Passing vector potential through external_vector_potential isn't working #5

Open Shiva-Konakanchi opened 3 years ago

Shiva-Konakanchi commented 3 years ago
import numpy as np
from svirl import GLSolver
import seaborn as sns
import matplotlib.pyplot as plt

gl = GLSolver(
    dx = 0.5, dy = 0.5,
    Lx = 64, Ly = 64,
    order_parameter = 'random',
    random_seed = 4,
    homogeneous_external_field = 0.05,
    external_field = 0.00,
    gl_parameter = 5.0,  # np.inf
    normal_conductivity = 200.0,
    dtype = np.float64,
)

aax = gl.vars.vector_potential[0]       # store the vector potential for uniform field for future use
aay = gl.vars.vector_potential[1]

gl.solve.td(dt=0.01, Nt=10000)            # Now do the time evolution
gl.solve.cg(n_iter = 1000)

heat = sns.heatmap(gl.observables.superfluid_density, cmap="CMRmap_r", vmin=0, vmax=1)
heat.invert_yaxis()
plt.savefig('1.png')

Produces this output: 1

However, passing A produces different output as shown below:

ginz = GLSolver(                            
    dx = 0.5, dy = 0.5,
    Lx = 64, Ly = 64,
    order_parameter = 'random',
    random_seed = 4,
    homogeneous_external_field = 0.00,
    external_field = 0.00,
    gl_parameter = 5.0,  # np.inf
    normal_conductivity = 200.0,
    dtype = np.float64,
)

ginz.params.external_vector_potential = (aax, aay) # aax and aay are obtained from the piece of code above

ginz.solve.td(dt=0.01, Nt=10000)            # Do the same time evolution as before
ginz.solve.cg(n_iter = 1000)

heat = sns.heatmap(ginz.observables.superfluid_density, cmap="CMRmap_r", vmin=0, vmax=1)
heat.invert_yaxis()
plt.savefig('2.png')

2

shriram-jagan commented 3 years ago

Shiva, I can reproduce this issue. I think internally we are setting 'vpei' in params.py based on the supplied vector potential, but I'm guessing we are not taking it into account when we invoke the kernels.

Shiva-Konakanchi commented 3 years ago

Hi Shriram, thanks for taking a look. I agree, somehow '_vpei' isn't being used in the evolution kernels. Also, another hint in this direction is that if I use 'external_field' to specify the value of the external field in the GLSolver object instead of 'uniform_external_field', that value isn't being used in calculations either. Note that the documentation says that for now 'external_field' only accepts a number (although it is designed for other things in the future).