Changing the Mass Flow Rate in a Transient Injection

This section provides an example of changing the mass flow rate in a transient injection.

By default, each parcel in Simcenter STAR-CCM+ represents the same amount of mass. The mass of a parcel is the product of the mass of an individual particle (ρ(43)πr3) and the parcel count. The parcel count is the number of particles contained in the parcel. The parcel count is a floating point number and can also be considered the probability of finding a particle with that mass and diameter at that spatial location.

It is straightforward to change the amount of mass in each parcel as a function of diameter with user code. In this example, the mass flow rate of each parcel increases linearly with diameter.

To pass an argument to a subroutine, the argument must be registered with a call to the library routine ufarg():


     subroutine uflib()
     use StarRealMod
     implicit none

  c Register user functions

     external linearDiameter
     external parcelMdot

     call uffunc(linearDiameter,
     &     "ParcelProfile",
     &     "Linear Diameter")

     call uffunc(parcelMdot,
     &     "ParcelProfile",
     &     "Parcel Mass Flow")

     call ufarg(parcelMdot,
     &     "Parcel",
     &     "$ParticleDiameter",
     & CoordRealSize)

     return
     end

To set a linear diameter distribution, modify the rosinRammlerDiameter.f routine by replacing the line that sets the result. In this example, the minimum diameter is set to 1 micron and the maximum is set to 100 microns. These diameters can be set as parameters. The linear distribution can be coded as:


      delta = (maxdiam-mindiam)/(size-1)
      do i = 1, size
        result(i) = mindiam+(i-1)*delta
      enddo

As the example routine below sets the mass flow rate for each parcel in the injection, you must set the mass flow rate condition to Per Parcel Stream. This setting is valid only if the injector is on a single partition— it does not work in parallel if the partition cuts through the injector.


      subroutine parcelMdot(result,size,D)

      use StarRealMod

      implicit none
      integer, intent(in) :: size
      real(StarReal), intent(out) :: result(size)
      real(CoordReal), intent(in) :: D(*)

  c parcel mass is count*rho*volume, so for an exponent of
  c -3 parcel mass is constant (default behavior)
  c -2 parcel mass increases with diameter linearly
  c -1 parcel mass increases with diameter quadratically
  c etc.

      real(StarReal), parameter :: expon = -2.0

      real(StarReal) sum, ratio, mdot
      integer i 
  c a constant mass flow rate for all particles
      mdot = 1.0e-3*size 
  c set the Parcel Count
      sum = 0.0
      do i = 1, size
       result(i) = D(i)**expon
       sum = sum + result(i)*D(i)**3
      end do

  c scale for flow rate per parcel
      if (sum > 0.0) then
       ratio = mdot/sum
       do i = 1, size
         result(i) = ratio*result(i)*D(i)**3
       enddo
     endif

     return
     end

An XY plot of the parcel mass as a function of particle diameter shows the default behavior of Simcenter STAR-CCM+ (Phase 1) and the results of the user code (Phase 2) with the parcel mass increasing linearly with diameter.