示例#1
0
  def test_substep(self):
    T0 = lambda x: np.sin(2*np.pi*(x-self.r-self.t)/self.t)

    T_outer = 250

    Tout = receiver.ConvectiveBC(self.r, self.h, self.nz,
        self.times, np.ones((self.ntime+1,self.nz))*T_outer)
    self.tube.set_bc(Tout, "outer")

    Tleft = receiver.FixedTempBC(self.r-self.t, self.h, self.nt, self.nz,
        self.times, np.zeros(self.ttimes.shape))
    self.tube.set_bc(Tleft, "inner")

    self.solver.solve(self.tube, self.material, self.fluid,
        T0 = T0, substep = 10)

    T = self.tube.results['temperature'][-1]

    ri = self.r - self.t

    C1 = self.hcoef * T_outer / (self.k/self.r + self.hcoef * np.log(self.r) - self.hcoef * np.log(ri))
    C2 = -C1 * np.log(ri)

    Texact = C1 * np.log(self.rs) + C2

    self.assertTrue(np.allclose(T,Texact, rtol = 1.0e-2))
示例#2
0
  def setUp(self):
    self.k = 15.0
    self.a = 5.0
    self.hcoef = 1.0

    self.solver = thermal.FiniteDifferenceImplicitThermalSolver()
    self.material = materials.ConstantThermalMaterial("Test", self.k, self.a)
    self.fluid = materials.ConstantFluidMaterial({"Test": self.hcoef})

    self.t = 0.2
    self.r = 2.0
    self.h = 1.0

    self.nr = 5

    self.nt = 10
    self.nz = 5

    self.tmax = 10.0
    self.ntime = 10

    self.tube = receiver.Tube(self.r, self.t, self.h, self.nr, self.nt, self.nz, 0)

    self.times = np.linspace(0, self.tmax, self.ntime+1)
    self.tube.set_times(self.times)

    self.T_inner = 100

    Tin = receiver.ConvectiveBC(self.r-self.t, self.h, self.nz,
        self.times, np.ones((self.ntime+1,self.nz))*self.T_inner)
    self.tube.set_bc(Tin, "inner")

    Tright = receiver.HeatFluxBC(self.r, self.h, self.nt, self.nz,
        self.times, np.zeros((self.ntime+1,self.nt,self.nz)))
    self.tube.set_bc(Tright, "outer")
示例#3
0
  def test_convection_left(self):
    T0 = lambda x: np.sin(2*np.pi*(x-self.r-self.t)/self.t)

    T_inner = 25

    Tin = receiver.ConvectiveBC(self.r-self.t, self.h, self.nz,
        self.times, np.ones((self.ntime+1,self.nz))*T_inner)
    self.tube.set_bc(Tin, "inner")

    Tright = receiver.FixedTempBC(self.r, self.h, self.nt, self.nz,
        self.times, np.zeros(self.ttimes.shape))
    self.tube.set_bc(Tright, "outer")

    self.solver.solve(self.tube, self.material, self.fluid,
        T0 = T0)

    T = self.tube.results['temperature'][-1]

    ri = self.r - self.t

    C1 = T_inner * self.hcoef / (self.hcoef*np.log(ri) - self.hcoef*np.log(self.r) - self.k/ri)
    C2 = -C1 * np.log(self.r)

    Texact = C1 * np.log(self.rs) + C2

    self.assertTrue(np.allclose(T,Texact, rtol = 1.0e-2))
示例#4
0
def valid_convective_bc(loc):
    if loc == "outer":
        r = outer_radius
    else:
        r = inner_radius
    return receiver.ConvectiveBC(r, height, nz, times,
                                 np.zeros((len(times), nz)))
示例#5
0
def make_tube(D, period):
    R = 1.0
    t = 0.1
    h = 10.0
    nr = 10
    nt = 20
    nz = 10
    T0 = 50

    tmax = period

    ntime = 10

    T0 = 300

    tube = receiver.Tube(R, t, h, nr, nt, nz, T0=T0)
    if D == 1:
        tube.make_1D(h / 2, 1)
    elif D == 2:
        tube.make_2D(h / 2)

    times = np.linspace(0, tmax, ntime)

    tube.set_times(times)

    Tf_0 = 300
    Tf_m = 600

    def fluid_T(t):
        if t < tmax / 2.0:
            return Tf_0 + (Tf_m - Tf_0) / (tmax / 2.0) * t
        else:
            return Tf_m - (Tf_m - Tf_0) / (tmax / 2.0) * (t - tmax / 2.0)

    ftemps = np.array([fluid_T(t) * np.ones((nz, )) for t in times])

    inner_convection = receiver.ConvectiveBC(R - t, h, nz, times, ftemps)
    tube.set_bc(inner_convection, "inner")

    hflux = receiver.HeatFluxBC(R, h, nt, nz, times,
                                np.zeros((ntime, nt, nz)) + 2.0)
    tube.set_bc(hflux, "outer")

    solver = thermal.FiniteDifferenceImplicitThermalSolver()

    tmat = materials.ConstantThermalMaterial("dummy", 20.0e-3, 4.8)
    fmat = materials.ConstantFluidMaterial({"dummy": 8.1e-3})

    solver.solve(tube, tmat, fmat)

    return tube
示例#6
0
 def test_wrong_size(self):
     with self.assertRaises(ValueError):
         bc = receiver.ConvectiveBC(inner_radius, height, nz, times,
                                    np.zeros((1, )))
示例#7
0
  # Time increments throughout the 24 hour day
  times = np.linspace(0,24,24*2+1)

  # Various meshes needed to define the boundary conditions
  # 1) A mesh over the times and height (for the fluid temperatures)
  time_h, z_h = np.meshgrid(times, np.linspace(0,height,nz), indexing='ij')
  # 2) A surface mesh over the outer surface (for the flux)
  time_s, theta_s, z_s = np.meshgrid(times, np.linspace(0,2*np.pi,nt+1)[:nt],
      np.linspace(0,height,nz), indexing = 'ij')

  # Setup each tube in turn and assign it to the correct panel
  # Tube 0
  tube_0 = receiver.Tube(r_outer, thickness, height, nr, nt, nz, T0 = T_base)
  tube_0.set_times(times)
  tube_0.set_bc(receiver.ConvectiveBC(r_outer-thickness,
    height, nz, times, fluid_temp(time_h,z_h)), "inner")
  tube_0.set_bc(receiver.HeatFluxBC(r_outer, height,
    nt, nz, times, h_flux(time_s, theta_s, z_s) * h_tube_0), "outer")
  tube_0.set_pressure_bc(receiver.PressureBC(times, pressure(times)))

  # Tube 1
  tube_1 = receiver.Tube(r_outer, thickness, height, nr, nt, nz, T0 = T_base)
  tube_1.set_times(times)
  tube_1.set_bc(receiver.ConvectiveBC(r_outer-thickness,
    height, nz, times, fluid_temp(time_h,z_h)), "inner")
  tube_1.set_bc(receiver.HeatFluxBC(r_outer, height,
    nt, nz, times, h_flux(time_s, theta_s, z_s) * h_tube_1), "outer")
  tube_1.set_pressure_bc(receiver.PressureBC(times, pressure(times)))

  # Tube 2
  tube_2 = receiver.Tube(r_outer, thickness, height, nr, nt, nz, T0 = T_base)