In [7]:
# Необходмые команды импорта.
import sys
sys.path.append('../../physlearn/')
sys.path.append('../../source')
import numpy as np
from numpy import linalg as LA
import tensorflow as tf
from matplotlib import pylab as plt
import numpy.random as rand
from physlearn.NeuralNet.NeuralNet import NeuralNet
from physlearn.Optimizer.NelderMead.NelderMead import NelderMead
import d1_osc
import ann_constructor
import math_util
from lagaris2d import LagarisSolver2d

from lagaris_mc import LagarisSolver_mc

from visualiser import Visualiser
from mpl_toolkits.mplot3d.axes3d import Axes3D
%matplotlib inline

def grid_vect(a,b,N):
    x = np.linspace(a, b, N, endpoint=True)
    h = x[1] - x[0]
    return np.mgrid[a:b+h:h, a:b+h:h].reshape(2,-1).T

def get_meshgrid(a,b,N):
    x = np.linspace(a, b, N, endpoint=True)
    return np.meshgrid(x,x)

n_sig = 12
a = -5
b = 5
#m_train = 35
#m_trapz = 25
#train_x = np.linspace(a, b, m_train, endpoint = True).reshape(1, m_train) 
#trapz_x = np.linspace(a, b, m_trapz, endpoint = True)
#obs_x = np.linspace(a, b, 200, endpoint = True).reshape(1, 200)

N = 6
xy = grid_vect(a,b,N)
xg,yg = get_meshgrid(a,b,N)

train_xy = np.transpose(xy)
trapz_xy = train_xy

In [8]:
lagar = LagarisSolver_mc(2)
lagar.define_psi(n_sig)
net_x = lagar.get_net_x()
dim = lagar.get_dim()
sess = lagar.get_sess()

V = tf.square(net_x)
#lagar.define_H_psi(V)

In [ ]:
first_deriative = tf.gradients(lagar.psi, lagar.net.x)[0]
H_psi = (-(tf.gradients(first_deriative, lagar.net.x)[0]) + tf.multiply(V, lagar.psi))

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [9]:
Z = lagar.calc_psi(np.transpose(xy), 1)
print(Z)
print(Z.shape)
fig = plt.figure(figsize=(14,6))
ax = fig.add_subplot(1, 2, 1, projection='3d')
xg,yg = np.meshgrid(xy[:,0], xy[:,1])
ax.plot_wireframe(xy[:,0], xy[:,1], Z)


[[6.26336505e-22 3.26751597e-15 5.71041106e-12 7.50233396e-12
  3.35936501e-15 4.33166992e-22 6.30681569e-15 4.61291755e-08
  6.90366918e-05 7.94747577e-05 3.42768309e-08 3.86057721e-15
  2.97867221e-11 2.32096013e-04 4.93870336e-01 4.43713155e-01
  1.41628449e-04 1.52021667e-11 4.28914392e-11 3.67719946e-04
  1.02657518e+00 8.22964894e-01 2.27916647e-04 2.19319971e-11
  1.42803324e-14 1.28371890e-07 3.97620624e-04 3.59796414e-04
  1.07076698e-07 1.06624834e-14 1.58605011e-21 1.49158842e-14
  4.52753830e-11 4.43174651e-11 1.33224510e-14 1.37880069e-21]]
(1, 36)
Out[9]:
<mpl_toolkits.mplot3d.art3d.Line3DCollection at 0x1a60020acf8>

In [10]:
Hpsi = lagar.calc_H_psi(np.transpose(xy), 1)
#Hpsi = Hpsi.reshape(1,Hpsi.size)
print(Hpsi)
print(Hpsi.shape)
fig = plt.figure(figsize=(14,6))
ax = fig.add_subplot(1, 2, 1, projection='3d')
xg,yg = np.meshgrid(xy[:,0], xy[:,1])
ax.plot_wireframe(xy[:,0], xy[:,1], Hpsi)


[[-1.08845757e-19 -4.42475887e-13 -5.41830461e-10 -4.08870355e-10
  -5.39494826e-14  1.16930119e-20 -5.52279743e-13 -2.92079117e-06
  -2.72956983e-03 -1.28099706e-03  3.59626820e-07  1.34769687e-13
  -7.41653637e-10 -3.75502058e-03 -3.92127949e+00  9.02650669e-01
   1.64015266e-03  3.08625137e-10  8.05534041e-10  4.00747409e-03
   3.40111771e+00 -3.21249212e+00 -2.57081520e-03 -4.08485488e-10
   4.98776884e-13  1.43325784e-06 -5.11709276e-03 -1.31163350e-02
  -6.38782119e-06 -8.75283562e-13  4.30362366e-20 -1.86343914e-13
  -2.39932753e-09 -4.11197592e-09 -1.76590058e-12 -2.37600934e-19]
 [-1.07224408e-19 -2.49927829e-13 -1.26543842e-10  1.38592331e-10
   1.21153126e-13  1.17329163e-20 -8.39685323e-13 -2.67390735e-06
  -8.02443362e-04  8.63227014e-04  3.98478843e-07 -4.95036488e-14
  -2.81546866e-09 -8.75809294e-03 -2.37012861e+00  1.80767503e+00
  -1.64093904e-03 -7.78226062e-10 -2.28471916e-09 -4.87226192e-03
   2.87019987e+00 -4.22395203e+00 -8.46712802e-03 -2.03280423e-09
  -1.82550416e-13  1.38139157e-06  4.36655521e-03 -4.92356450e-03
  -6.59224172e-06 -1.41859017e-12  4.25291875e-20  5.20423925e-13
   8.59926118e-10 -9.46212418e-10 -1.14380277e-12 -2.39694104e-19]]
(2, 36)
Out[10]:
<mpl_toolkits.mplot3d.art3d.Line3DCollection at 0x1a600260358>

In [11]:
psiHpsi = lagar.psi_H_psi_integrand(np.transpose(xy),1)
print(psiHpsi)
print(psiHpsi.shape)
fig = plt.figure(figsize=(14,6))
ax = fig.add_subplot(1, 2, 1, projection='3d')
xg,yg = np.meshgrid(xy[:,0], xy[:,1])
ax.plot_wireframe(xy[:,0], xy[:,1], psiHpsi)


[-6.81740713e-41 -1.44579703e-27 -3.09407465e-21 -3.06748195e-21
 -1.81236004e-28  5.06502678e-42 -3.48312655e-27 -1.34733688e-13
 -1.88440471e-07 -1.01806931e-07  1.23268677e-14  5.20288784e-28
 -2.20914308e-20 -8.71525305e-07 -1.93660362e+00  4.00517976e-01
  2.32292278e-07  4.69177077e-21  3.45505143e-20  1.47362816e-06
  3.49150302e+00 -2.64376824e+00 -5.85931580e-07 -8.95890253e-21
  7.12269968e-27  1.83990016e-13 -2.03466162e-06 -4.71921030e-06
 -6.83986803e-13 -9.33269647e-27  6.82576277e-41 -2.77948423e-27
 -1.08630473e-19 -1.82232349e-19 -2.35261239e-26 -3.27604331e-40]
(36,)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-11-72fdb49a1c4a> in <module>()
      5 ax = fig.add_subplot(1, 2, 1, projection='3d')
      6 xg,yg = np.meshgrid(xy[:,0], xy[:,1])
----> 7 ax.plot_wireframe(xy[:,0], xy[:,1], psiHpsi)

D:\Anaconda\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py in plot_wireframe(self, X, Y, Z, *args, **kwargs)
   1847         had_data = self.has_data()
   1848         if Z.ndim != 2:
-> 1849             raise ValueError("Argument Z must be 2-dimensional.")
   1850         # FIXME: Support masked arrays
   1851         X, Y, Z = np.broadcast_arrays(X, Y, Z)

ValueError: Argument Z must be 2-dimensional.

In [ ]:
psi_psi = lagar.psi_psi_integrand(np.transpose(xy),1)
print(psi_psi)
print(psi_psi.shape)
fig = plt.figure(figsize=(14,6))
ax = fig.add_subplot(1, 2, 1, projection='3d')
xg,yg = np.meshgrid(xy[:,0], xy[:,1])
ax.plot_wireframe(xy[:,0], xy[:,1], psi_psi)

In [ ]:


In [ ]:


In [ ]: