unit DirectUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Spin, ComCtrls, ShellCtrls, DBCtrls, FileCtrl,
  Math, HCArrays, HCConduct, HCMaterial, HCModel, UPohMath, UPohStrConv,
  BasicUnit;

procedure SetBoundCond(var model: tHCModel);
procedure MainDirectTask(var T_comp:array of double; var T_surf:array of double; MatDtb: tMatDB; var model:tHCModel; q: array of double; n:integer; dt:double; hloubka:double);

const
  mm=0.001;
  Cel_Kel=273.15;

implementation

procedure SetBoundCond(var model: tHCModel);
begin
	// left side - q
	  fHC_SetBoundaryIntWE(model, model.bW_kind, 2);
  	fHC_SetBoundaryFloatWE(model, model.bW_v, 0);
	  fHC_SetBoundaryFloatWE(model, model.bW_t, 0);
  	fHC_SetBoundaryFloatWE(model, model.bW_e, 0);
	// rigth side - insulation
	  fHC_SetBoundaryIntWE(model, model.bE_kind, 2);
  	fHC_SetBoundaryFloatWE(model, model.bE_v, 0);
	  fHC_SetBoundaryFloatWE(model, model.bE_t, 0);
  	fHC_SetBoundaryFloatWE(model, model.bE_e, 0);
end;

procedure MainDirectTask(var T_comp:array of double; var T_surf:array of double; MatDtb: tMatDB; var model:tHCModel; q: array of double; n:integer; dt:double; hloubka:double);
var
  step, iterations:integer;
  max_err:double;
begin
  //max_err := 1.0/(time/dt);
  max_err := Max(0.0001, 0.25 * dt);
  
  step := 0;
  while(step < n) do begin
  	fHC_SetBoundaryFloatWE(model, model.bW_v, q[step]);
    iterations := fHC_HC1TimeStep(model, MatDtb, dt, 5, max_err); 
    T_comp[step]:= fHC_GetInterpValHCModel(model.vT, model, hloubka, 0, 0)-Cel_Kel;
    T_surf[step]:= fHC_GetInterpValHCModel(model.vT, model, 0, 0, 0)-Cel_Kel;
    Inc(step);
  end;
end;

end.
