Ejemplo n.º 1
0
        public static void Init(int[] volSize, int[] volRes, float hbar, float dt) // vol_size::NTuple{ 3}, vol_res::NTuple{3}, hbar, dt)
        {
            properties = new SpaceProperties(volSize, volRes, hbar, dt);
            ISFKernels.Init(properties);

            psi1 = new CudaDeviceVariable <cuFloatComplex>(properties.num);
            psi2 = new CudaDeviceVariable <cuFloatComplex>(properties.num);

            FFT.init(properties.resx, properties.resy, properties.resz);

            _ix = Enumerable.Range(0, properties.resx).ToArray();
            _iy = Enumerable.Range(0, properties.resy).ToArray();
            _iz = Enumerable.Range(0, properties.resz).ToArray();
            var ii = Matlab.ndgrid(_ix, _iy, _iz);

            _iix = ii.x;
            _iiy = ii.y;
            _iiz = ii.z;

            properties.px = new float[_iix.GetLength(0), _iix.GetLength(1), _iix.GetLength(2)];
            properties.py = new float[_iiy.GetLength(0), _iiy.GetLength(1), _iiy.GetLength(2)];
            properties.pz = new float[_iiz.GetLength(0), _iiz.GetLength(1), _iiz.GetLength(2)];
            for (int i = 0; i < properties.resx; i++)
            {
                for (int j = 0; j < properties.resy; j++)
                {
                    for (int k = 0; k < properties.resz; k++)
                    {
                        properties.px[i, j, k] = (_iix[i, j, k]) * properties.dx;
                        properties.py[i, j, k] = (_iiy[i, j, k]) * properties.dy;
                        properties.pz[i, j, k] = (_iiz[i, j, k]) * properties.dz;
                    }
                }
            }

            _sx = _iix.Select3D((e, i, j, k) => (float)Math.Sin((float)Math.PI * e / properties.resx) / properties.dx);
            _sy = _iiy.Select3D((e, i, j, k) => (float)Math.Sin((float)Math.PI * e / properties.resy) / properties.dy);
            _sz = _iiz.Select3D((e, i, j, k) => (float)Math.Sin((float)Math.PI * e / properties.resz) / properties.dz);

            cuFloatComplex[,,] tmpFac = _iix.Select3D((e, i, j, k) =>
            {
                return(new cuFloatComplex((float)(-0.25 / (Math.Pow(_sx[i, j, k], 2) + Math.Pow(_sy[i, j, k], 2) + Math.Pow(_sz[i, j, k], 2))), 0));
            });
            tmpFac[0, 0, 0] = new cuFloatComplex(0, 0);
            _fac            = new CudaDeviceVariable <cuFloatComplex>(properties.num);
            _fac.CopyToDevice(tmpFac);

            var tmpMask = new cuFloatComplex[properties.resx, properties.resy, properties.resz];

            build_schroedinger(tmpMask);
            _mask = new CudaDeviceVariable <cuFloatComplex>(properties.num);
            _mask.CopyToDevice(tmpMask);
        }