def __init__(self,
                 name,
                 heat_transfer_coefficient = 1,
                 pressure_drop_Pa = 500,
                 a_volume_m3 = 10,
                 b_volume_m3 = 10,
                 contact_area_m2 = physics.medium_heat_exchanger_area_m2,
                 a_pipe_size_m2 = physics.medium_pipe_size_m2,
                 b_pipe_size_m2 = physics.medium_pipe_size_m2,
                 connector_lengths_m = 0.5,
                 height_m=5.0,
                 base_height_m=0):

        component.__init__(self, name)

        self.a_volume_m3 = a_volume_m3
        self.b_volume_m3 = b_volume_m3
        self.a_fluid = self._add_fluid(fluid(name+".a", self.a_volume_m3 / (height_m/2), height_m, base_height_m))
        self.b_fluid = self._add_fluid(fluid(name+".b", self.b_volume_m3 / (height_m/2), height_m, base_height_m))

        self.a_in  = self.a_fluid.add_port(port("a_in",  self.a_fluid, a_pipe_size_m2, connector_lengths_m, height_m))
        self.a_out = self.a_fluid.add_port(port("a_out", self.a_fluid, a_pipe_size_m2, connector_lengths_m, height_m))
        self.b_in   = self.b_fluid.add_port(port("b_in",   self.b_fluid,  b_pipe_size_m2,  connector_lengths_m, height_m))
        self.b_out  = self.b_fluid.add_port(port("b_out",  self.b_fluid,  b_pipe_size_m2,  connector_lengths_m, height_m))

        self.contact_area_m2 = contact_area_m2
        self.heat_transfer_coefficient = heat_transfer_coefficient
        self.pressure_drop_Pa = pressure_drop_Pa
Example #2
0
    def __init__(self, name, length_m = 1, area_m2 = physics.medium_pipe_size_m2, height_m=0):
        component.__init__(self, name)
        self.length_m = length_m
        self.area_m2 = area_m2
        self.volume_m3 = area_m2 * length_m
        self.fluid = self._add_fluid(fluid(name, self.area_m2, length_m, height_m - length_m / 2.0))

        self.in_port  = self.fluid.add_port(port("in",   self.fluid, area_m2, length_m/2.0, height_m))
        self.out_port = self.fluid.add_port(port("out",  self.fluid, area_m2, length_m/2.0, height_m))
Example #3
0
 def __init__(self,
              name,
              volume_m3,
              height_m,
              base_height_m=0,
              initial_fill_rate=0.7):
     component.__init__(self, name)
     self.fluid = self._add_fluid(
         fluid(name, volume_m3 / height_m, height_m, base_height_m,
               initial_fill_rate))
Example #4
0
    def __init__(self, name, length_m = 20.0, start_height_m = 0.0, end_height_m = 0.0, area_m2 = physics.medium_pipe_size_m2):
        component.__init__(self, name)
        self.length_m = length_m
        self.area_m2 = area_m2
        self.volume_m3 = area_m2 * length_m
        base_h = min(start_height_m, end_height_m)
        h      = max(start_height_m, end_height_m) - base_h
        # TODO: Better area for pipe, base on slope
        self.fluid = self._add_fluid(fluid(name, self.area_m2, h, base_h))

        self.in_port  = self.fluid.add_port(port("in_port", self.fluid, area_m2, length_m/2.0, start_height_m))
        self.out_port = self.fluid.add_port(port("out_port",   self.fluid, area_m2, length_m/2.0, end_height_m))
Example #5
0
    def __init__(self,
                 name,
                 heat_transfer_coefficient=1,
                 pressure_drop_Pa=500,
                 a_volume_m3=10,
                 b_volume_m3=10,
                 contact_area_m2=physics.medium_heat_exchanger_area_m2,
                 a_pipe_size_m2=physics.medium_pipe_size_m2,
                 b_pipe_size_m2=physics.medium_pipe_size_m2,
                 connector_lengths_m=0.5,
                 height_m=5.0,
                 base_height_m=0):

        component.__init__(self, name)

        self.a_volume_m3 = a_volume_m3
        self.b_volume_m3 = b_volume_m3
        self.a_fluid = self._add_fluid(
            fluid(name + ".a", self.a_volume_m3 / (height_m / 2), height_m,
                  base_height_m))
        self.b_fluid = self._add_fluid(
            fluid(name + ".b", self.b_volume_m3 / (height_m / 2), height_m,
                  base_height_m))

        self.a_in = self.a_fluid.add_port(
            port("a_in", self.a_fluid, a_pipe_size_m2, connector_lengths_m,
                 height_m))
        self.a_out = self.a_fluid.add_port(
            port("a_out", self.a_fluid, a_pipe_size_m2, connector_lengths_m,
                 height_m))
        self.b_in = self.b_fluid.add_port(
            port("b_in", self.b_fluid, b_pipe_size_m2, connector_lengths_m,
                 height_m))
        self.b_out = self.b_fluid.add_port(
            port("b_out", self.b_fluid, b_pipe_size_m2, connector_lengths_m,
                 height_m))

        self.contact_area_m2 = contact_area_m2
        self.heat_transfer_coefficient = heat_transfer_coefficient
        self.pressure_drop_Pa = pressure_drop_Pa
Example #6
0
    def __init__(self, name, max_pressure_Pa = physics.medium_pump_pressure_Pa, height_m = 1, base_height_m = 0, area_m2 = physics.medium_pipe_size_m2, pump_length_m = 2):
        component.__init__(self, name)
        self.length_m = pump_length_m
        self.area_m2 = area_m2
        self.volume_m3 = self.area_m2 * self.length_m
        self.fluid = self._add_fluid(fluid(name, self.volume_m3, height_m, base_height_m))

        self.in_port  = self.fluid.add_port(port("in",  self.fluid, area_m2, pump_length_m/2.0, height_m))
        self.out_port = self.fluid.add_port(port("out", self.fluid, area_m2, pump_length_m/2.0, height_m))

        self.max_pressure_Pa = max_pressure_Pa

        self.adjust_power(0.5)
Example #7
0
    def __init__(self,
                 name,
                 height_m=-2.0,
                 pipe_size_m2=physics.large_pipe_size_m2,
                 pipe_length_m=20.0,
                 river_temperature_C=18.0):
        component.__init__(self, name)
        self.height_m = height_m

        self.river_water = self._add_fluid(
            fluid(name, 100, 10, -5, 0.5, True, True, river_temperature_C))
        self.port = self.river_water.add_port(
            port("river", self.river_water, pipe_size_m2, pipe_length_m,
                 height_m))
Example #8
0
    def __init__(self,
                 name,
                 length_m=1,
                 area_m2=physics.medium_pipe_size_m2,
                 height_m=0):
        component.__init__(self, name)
        self.length_m = length_m
        self.area_m2 = area_m2
        self.volume_m3 = area_m2 * length_m
        self.fluid = self._add_fluid(
            fluid(name, self.area_m2, length_m, height_m - length_m / 2.0))

        self.in_port = self.fluid.add_port(
            port("in", self.fluid, area_m2, length_m / 2.0, height_m))
        self.out_port = self.fluid.add_port(
            port("out", self.fluid, area_m2, length_m / 2.0, height_m))
Example #9
0
def create_fluidSphereFall(gp, algo, psolver=None, flip_blending=None):
    # define fluid object
    fluid_geom = sphere(5, 5, 5, 3)
    fluid_obj = fluid(geometry=fluid_geom,
                      simulation_algorithm=algo,
                      grid_res=gp['grid_res'],
                      particle_res=gp['particle_res'],
                      render_type='PLY',
                      pressure_solver=psolver,
                      flip_blending=flip_blending)

    # define scene
    sim = simulation(gp['world'],
                     gp['bound_grid'],
                     gp['grid_res'], [fluid_obj],
                     render_algo='PLY')

    return sim
Example #10
0
def case_error(C):
    F = fluid(argv[1], (int)(argv[2]), (int)(argv[3]))

    F.C = C
    print '--------------'
    print 'constants: ', F.C[0], F.C[1], F.C[2], F.C[3]

    global Er
    Er = 0.0
    for i in range(2):
        t = F.timeRange
        v0 = F.v0[i]
        s0 = F.s0[i]
        vmax = F.vMax[i]
        g = F.numberOfClasses
        print "initial d and v: ", i, F.d0[i], v0

        dv = vmax / g
        v = dv + dv * arange(g)
        Ninit = F.alpha / v0 * F.V\
            * 1.0 / s0 / sqrt(2.0 * pi)\
            * exp(- (v - v0) ** 2 / 2 / s0 ** 2)

        pbe_solutions = SteadyStateSolution(
            Ninit, t, dv,
            Q=F.Q,
            gamma=F.gamma,
            beta=F.beta,
            pdf='number'
        )
        pbe_solutions.solve()

        N = pbe_solutions.solution
        m1 = sum(N[:] * v[:])
        m1Init = sum(Ninit[:] * v[:])
        norm = sum(N)
        meanV = m1 / norm
        dMean = (6.0 * meanV / pi) ** (1.0 / 3.0)
        print 'calculated, experimental d: ', dMean, F.expectedD
        print 'mass conservations: ', m1 / m1Init
        Er += sqrt((dMean - F.expectedD) ** 2) / F.expectedD
    return Er
Example #11
0
def case_error(C):
    F = fluid(argv[1], (int)(argv[2]), (int)(argv[3]))

    F.C = C
    print '--------------'
    print 'constants: ', F.C[0], F.C[1], F.C[2], F.C[3]

    global Er
    Er = 0.0
    for i in range(2):
        t = F.timeRange
        v0 = F.v0[i]
        s0 = F.s0[i]
        vmax = F.vMax[i]
        g = F.numberOfClasses
        print "initial d and v: ", i, F.d0[i], v0

        dv = vmax / g
        v = dv + dv * arange(g)
        Ninit = F.alpha / v0 * F.V\
            * 1.0 / s0 / sqrt(2.0 * pi)\
            * exp(- (v - v0) ** 2 / 2 / s0 ** 2)

        pbe_solutions = SteadyStateSolution(Ninit,
                                            t,
                                            dv,
                                            Q=F.Q,
                                            gamma=F.gamma,
                                            beta=F.beta,
                                            pdf='number')
        pbe_solutions.solve()

        N = pbe_solutions.solution
        m1 = sum(N[:] * v[:])
        m1Init = sum(Ninit[:] * v[:])
        norm = sum(N)
        meanV = m1 / norm
        dMean = (6.0 * meanV / pi)**(1.0 / 3.0)
        print 'calculated, experimental d: ', dMean, F.expectedD
        print 'mass conservations: ', m1 / m1Init
        Er += sqrt((dMean - F.expectedD)**2) / F.expectedD
    return Er
Example #12
0
    def __init__(self,
                 name,
                 length_m=20.0,
                 start_height_m=0.0,
                 end_height_m=0.0,
                 area_m2=physics.medium_pipe_size_m2):
        component.__init__(self, name)
        self.length_m = length_m
        self.area_m2 = area_m2
        self.volume_m3 = area_m2 * length_m
        base_h = min(start_height_m, end_height_m)
        h = max(start_height_m, end_height_m) - base_h
        # TODO: Better area for pipe, base on slope
        self.fluid = self._add_fluid(fluid(name, self.area_m2, h, base_h))

        self.in_port = self.fluid.add_port(
            port("in_port", self.fluid, area_m2, length_m / 2.0,
                 start_height_m))
        self.out_port = self.fluid.add_port(
            port("out_port", self.fluid, area_m2, length_m / 2.0,
                 end_height_m))
Example #13
0
    def __init__(self,
                 name,
                 max_pressure_Pa=physics.medium_pump_pressure_Pa,
                 height_m=1,
                 base_height_m=0,
                 area_m2=physics.medium_pipe_size_m2,
                 pump_length_m=2):
        component.__init__(self, name)
        self.length_m = pump_length_m
        self.area_m2 = area_m2
        self.volume_m3 = self.area_m2 * self.length_m
        self.fluid = self._add_fluid(
            fluid(name, self.volume_m3, height_m, base_height_m))

        self.in_port = self.fluid.add_port(
            port("in", self.fluid, area_m2, pump_length_m / 2.0, height_m))
        self.out_port = self.fluid.add_port(
            port("out", self.fluid, area_m2, pump_length_m / 2.0, height_m))

        self.max_pressure_Pa = max_pressure_Pa

        self.adjust_power(0.5)
Example #14
0
    def __init__(self,prefix,unit):
        const.__init__(self,prefix + 'British')

        #volume
        self.fluid = fluid.fluid(prefix + 'British.',unit)

        self.peck = 2.0*self.fluid.gallons;
        self.pecks = self.peck;
        self.pk = self.peck;
        self.bushel = 4.0*self.pecks;
        self.bushels = self.bushel;
        self.bu = self.bushel;
        self.barrel = 36.0*self.fluid.gallons;
        self.barrels = self.barrel;
        self.bbl = self.barrel;
        self.bl = self.barrel;

        #length
        self.cable_length = 100.0*unit.fathoms;
        self.cable_lengths = self.cable_length;

        #mass
        self.hundredweight = 112.0*unit.avoirdupois.pounds;
        self.cwt = self.hundredweight;
        self.quarter = self.hundredweight/4.0;
        self.quarters = self.quarter;
        self.qr = self.quarter;
        self.ton = 20.0*self.hundredweight;
        self.tons = self.ton;
        self.tn = self.ton;


        # do some trickery to get modules set to instantiated classes
        # We expect each submodule to do likewise for those not already taken
        # care of here.
        self.fluid.__name__ = fluid.__name__
        sys.modules[fluid.__name__] = self.fluid
Example #15
0
 def futhark_object():
     return fluid.fluid()
Example #16
0
            gamma=F.gamma,
            beta=F.beta,
            pdf='number'
        )
        pbe_solutions.solve()

        N = pbe_solutions.solution
        m1 = sum(N[:] * v[:])
        m1Init = sum(Ninit[:] * v[:])
        norm = sum(N)
        meanV = m1 / norm
        dMean = (6.0 * meanV / pi) ** (1.0 / 3.0)
        print 'calculated, experimental d: ', dMean, F.expectedD
        print 'mass conservations: ', m1 / m1Init
        Er += sqrt((dMean - F.expectedD) ** 2) / F.expectedD
    return Er

# -----------------------------------------------------------------


# TODO: move C0 to fluid class
F = fluid(argv[1], (int)(argv[2]), (int)(argv[3]))
C0 = np.array(F.initialC())
#C0 = 0.75 * C0

# TODO: construct list of cases
open(error_file, 'w').close()
C = fmin(case_error, C0, full_output=True, maxiter=50, callback=write_error)
print C
# TODO write a for loop over the list of cases with parallel execution
Example #17
0
 def futhark_object():
     return fluid.fluid(interactive=True)
Example #18
0
from numpy import arange, sqrt, pi
from itertools import cycle
from fluid import fluid
import numpy as np
from aux import set_plt_params, plt

F = fluid('coulaloglou', 0, 0)
F.C = np.array([0.00299, 0.0256, 6.27e-11, 1.2e14])

d0 = 3e-04
v0 = np.pi * d0 ** 3 / 6.0
s0 = v0 / 2.0
v = np.arange(v0 / 10.0, 3.0 * v0, 0.01 * v0)
N = F.alpha / v0 * F.V\
    * 1.0 / s0 / sqrt(2.0 * pi)\
    * np.exp(- (v - v0) ** 2 / 2 / s0 ** 2)

gamma = F.gamma(v)
Q = np.zeros(v.shape)
escape = np.zeros(v.shape)
one_over_theta = 0.005
for i in np.arange(Q.shape[0]):
    if i != (Q.shape[0] - 1):
        for j in arange(Q.shape[0]):
            Q[i] = N[j] * F.Q(v[i], v[j])
    escape[i] = one_over_theta

set_plt_params(relative_fig_width=0.7)
fig = plt.figure()
ax = fig.gca()
markers = cycle(['o', 's', 'v', '*', '.', ','])
Example #19
0
    def __init__(self, name, height_m=-2.0, pipe_size_m2=physics.large_pipe_size_m2, pipe_length_m=20.0, river_temperature_C=18.0):
        component.__init__(self, name)
        self.height_m = height_m

        self.river_water = self._add_fluid(fluid(name, 100, 10, -5, 0.5, True, True, river_temperature_C))
        self.port = self.river_water.add_port(port("river", self.river_water, pipe_size_m2, pipe_length_m, height_m))
Example #20
0
 def futhark_object():
     return fluid.fluid(interactive=True)
Example #21
0
from steadyStateSolver import SteadyStateSolution

# use 0:
# dinit = 0.8 * d_exp
# use 1:
# dinit = 1.2 * d_exp
n = 0

dNum = []
dExp = []

caseName = ['coulaloglou', 'angeli', 'karabelas', 'simmonsAzzopardi']
caseNs = []

for name in caseName:
    F = fluid.fluid(name, 0, 0)
    caseNs.append(F.caseNs)

caseId = 0

for case in caseNs:
    I = case.shape[0]
    for i in np.arange(I):
        for j in np.arange(case[i]):
            pbe_solutions = dict()
            F = fluid.fluid(caseName[caseId], i, j)
            Re = F.Re
            Ca = F.Ca
            St = F.St
            We = F.We()
            # -----------------------------
Example #22
0
 def __init__(self, name, volume_m3, height_m, base_height_m = 0, initial_fill_rate = 0.7):
     component.__init__(self, name)
     self.fluid = self._add_fluid(fluid(name, volume_m3/height_m, height_m, base_height_m, initial_fill_rate))
Example #23
0
                                            Q=F.Q,
                                            gamma=F.gamma,
                                            beta=F.beta,
                                            pdf='number')
        pbe_solutions.solve()

        N = pbe_solutions.solution
        m1 = sum(N[:] * v[:])
        m1Init = sum(Ninit[:] * v[:])
        norm = sum(N)
        meanV = m1 / norm
        dMean = (6.0 * meanV / pi)**(1.0 / 3.0)
        print 'calculated, experimental d: ', dMean, F.expectedD
        print 'mass conservations: ', m1 / m1Init
        Er += sqrt((dMean - F.expectedD)**2) / F.expectedD
    return Er


# -----------------------------------------------------------------

# TODO: move C0 to fluid class
F = fluid(argv[1], (int)(argv[2]), (int)(argv[3]))
C0 = np.array(F.initialC())
#C0 = 0.75 * C0

# TODO: construct list of cases
open(error_file, 'w').close()
C = fmin(case_error, C0, full_output=True, maxiter=50, callback=write_error)
print C
# TODO write a for loop over the list of cases with parallel execution