 // Расчет внутренней энергии всей системы в точке
 __device__ void assign_E_current (ptr_Arrays DevArraysPtr, int local)
 {
-	HostArraysPtr.E[local] = (HostArraysPtr.m[local] * (HostArraysPtr.S_w[local] * (HostArraysPtr.ro_w[local] * HostArraysPtr.H_w[local] - HostArraysPtr.P_w[local])
-		+ HostArraysPtr.S_n[local] * (HostArraysPtr.ro_n[local] * HostArraysPtr.H_n[local] - HostArraysPtr.P_n[local])
-		+ HostArraysPtr.S_g[local] * (HostArraysPtr.ro_g[local] * HostArraysPtr.H_g[local] - HostArraysPtr.P_g[local])) 
-		+ (1. - HostArraysPtr.m[local]) * (ro_r * HostArraysPtr.H_r[local] - HostArraysPtr.P_w[local]));
-
-	test_nan(HostArraysPtr.E[local], __FILE__, __LINE__);
+	DevArraysPtr.E[local] = (DevArraysPtr.m[local] * (DevArraysPtr.S_w[local] * (DevArraysPtr.ro_w[local] * DevArraysPtr.H_w[local] - DevArraysPtr.P_w[local])
+		+ DevArraysPtr.S_n[local] * (DevArraysPtr.ro_n[local] * DevArraysPtr.H_n[local] - DevArraysPtr.P_n[local])
+		+ DevArraysPtr.S_g[local] * (DevArraysPtr.ro_g[local] * DevArraysPtr.H_g[local] - DevArraysPtr.P_g[local])) 
+		+ (1. - DevArraysPtr.m[local]) * (ro_r * DevArraysPtr.H_r[local] - DevArraysPtr.P_w[local]));
+
+	device_test_nan(DevArraysPtr.E[local], __FILE__, __LINE__);
 }
 
 // Расчет внутренней энергии всей системы в точке на следующем шаге по времени

// Расчет теплового потока в точке
__device__ double assign_T_flow (ptr_Arrays DevArraysPtr, i, j, k)
{
	if ((((i != 0) && (i != (def.locNx) - 1)) || ((def.locNx) < 2)) && (j != 0) && (j != (def.locNy) - 1) && (((k != 0) && (k != (def.locNz) - 1)) || ((def.locNz) < 2)))
	{
		double T_flow = 0;
		int local=i + j * (def.locNx) + k * (def.locNx) * (def.locNy);

		if ((def.locNx) > 2)
		{
			T_flow += (assign_lambda_eff(HostArraysPtr, local + 1, def) * HostArraysPtr.T[local + 1]
			- 2 * assign_lambda_eff(HostArraysPtr, local, def) * HostArraysPtr.T[local]
			+ assign_lambda_eff(HostArraysPtr, local - 1, def) * HostArraysPtr.T[local - 1]) / ((def.hx) * (def.hx));
		}
		if ((def.locNy) > 2)
		{
			T_flow += (assign_lambda_eff(HostArraysPtr, local + def.locNx, def) * HostArraysPtr.T[local + def.locNx]
			- 2 * assign_lambda_eff(HostArraysPtr, local, def) * HostArraysPtr.T[local]
			+ assign_lambda_eff(HostArraysPtr, local - def.locNx, def) * HostArraysPtr.T[local - def.locNx]) / ((def.hy) * (def.hy));
		}

		if ((def.locNz) > 2)
		{
			T_flow = (assign_lambda_eff(HostArraysPtr, local + (def.locNx) * (def.locNy), def) * HostArraysPtr.T[local + (def.locNx) * (def.locNy)]
			- 2 * assign_lambda_eff(HostArraysPtr, local, def) * HostArraysPtr.T[local]
			+ assign_lambda_eff(HostArraysPtr, local - (def.locNx) * (def.locNy), def) * HostArraysPtr.T[local - (def.locNx) * (def.locNy)]) / ((def.hz) * (def.hz));
		}

		test_u(T_flow, __FILE__, __LINE__);
		return T_flow;
	}
	else

	case 'g':
		if (var == 'P')
		{
			result_d_ro = (gpu_def->ro0_g / gpu_def->P_atm) * (T_0 / T);
		} 
		else if (var == 'T')
		{
			result_d_ro = gpu_def->ro0_g * (P / gpu_def->P_atm) * (-1) * (T_0 / T) / T;
		}
		else 
		{
