Esempio n. 1
0
void CLimnStream::GetPropertyValue(long Index, ULONG Phase/*=MP_All*/, double T/*=NAN*/, double P/*=NAN*/, MPropertyValue & Value)
  {
  switch (Index)
    {
    //case   idGetValue: Value=m_dGetProp;  return ;
    //case   idSetValue: Value=m_dSetProp;  return ;
    case   idCalcOre:  
      {
      double Tot=0;
      for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ )
        {
        for (int iSG = 0 ; iSG < nSGs(); iSG++ )
          Tot+=Ore(iOSz, iSG);
        }
      Value=Tot;
      return ;
      }
    case   idCalcDmd: 
      {
      double Tot=0;
      for (int iSG = 0 ; iSG < nSGs(); iSG++ )
        {
        for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ )
          {
          for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ )
            Tot+=Diamond(iDSz, iOSz, iSG);
          }
        }
      Value=Tot;
      return ;
      }
    };
  };
Esempio n. 2
0
void Grid::DiamondSquare(unsigned long seed, float rough, float height)
{
    Clear();

    std::tr1::mt19937 engine;
    engine.seed(seed);
    float d = height;

    for (int r = _widthSegs / 2; r > 0; r >>= 1) { // Divide radius in half, except 1 >> 1 becomes 0.
        std::tr1::uniform_real<float> dist(-d, d); // Before each iteration.

        for (int i = 0; i < _widthSegs; i += 2 * r)
        {
            for (int j = 0; j < _lengthSegs; j += 2 * r)
            {
                Diamond(i + r, j + r, r, dist(engine));
                Square(i + r, j, r, dist(engine));
                Square(i, j + r, r, dist(engine));
            }
        }

        d *= pow(2.0f, -1.0f + rough); // After each iteration.
    }
}
Esempio n. 3
0
void CLimnStream::Dump(LPCTSTR Where, DWORD What) 
  {
  if (0 && What)
    {
    Dbg.Lock();
    Dbg.PrintLn("Dump %s ----------------------------------------- %s : %s", m_bIsMassForm?"MassForm":"FracForm", Where, Tag);

    if (0)
      {
      Dbg.PrintLn("");
      Dbg.PrintLn("Data:");
      for (int r = 0 ; r < gs_DWCfg.RowCount(); r++ )
        {
        Dbg.Print("%3i)", r);
        for (int c= 0 ; c < gs_DWCfg.ColCount(); c++ )
          Dbg.Print(" %10.2f", m_Data[r*gs_DWCfg.ColCount() + c]);
        Dbg.PrintLn("");
        }
      Dbg.PrintLn("");
      }

    if (What)
      {
      MVector V=Vector;
      for (int i=0; i<V.Count(); i++)
        Dbg.PrintLn("M[%-25s] : %15.4f", gs_MVDefn[i].Symbol(), V.M[i]*(m_bIsMassForm?3.6:1.0));
      Dbg.PrintLn("");
      }
    if (What & 0x01)
      Dbg.PrintLn("Water  : %10.4f", Water());
    if (What & 0x02)
      Dbg.PrintLn("FeSi   : %10.4f", FeSi());

    if (What & 0x04)
      {
      Dbg.PrintLn("Ore:");
      Dbg.Indent(4);
      Dbg.Print("%10s", "Size\\SG");
      for (int iSG = 0 ; iSG < nSGs(); iSG++ )
        Dbg.Print(" %10.4f", MeanSG(iSG ));
      Dbg.PrintLn("");
      Dbg.Print("%10s", "-------");
      for (int iSG = 0 ; iSG < nSGs(); iSG++ )
        Dbg.Print(" %10s", "--------");
      Dbg.PrintLn("");
      for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ )
        {
        Dbg.Print("%+10.2f", MeanOreSize(iOSz));
        for (int iSG = 0 ; iSG < nSGs(); iSG++ )
          Dbg.Print(" %10.4f", Ore(iOSz, iSG ));
        Dbg.PrintLn("");
        }
      Dbg.Indent(-4);
      }

    if (What & 0x08)
      {
      Dbg.PrintLn("");
      Dbg.PrintLn("Diamonds:");
      for (int iSG = 0 ; iSG < nSGs(); iSG++ )
        {
        Dbg.PrintLn("SG : %s", SGText(iSG));
        Dbg.Indent(2);

        bool DoIt=false;
        for (int iOSz = 0 ; !DoIt && iOSz < nOreSizes() ; iOSz++ )
          {
          for (int iDSz = 0 ; !DoIt && iDSz< nDiamondSizes(); iDSz++ )
            DoIt=Diamond(iDSz, iOSz, iSG )>1.0e-6;
          }

        if (!DoIt)
          {
          Dbg.Print("%10s", "");
          Dbg.PrintLn("ZERO");
          }
        else
          {
          Dbg.Print("%10s", "OSz\\DSz");
          for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ )
            Dbg.Print(" %10s", DiamondSizeText(iDSz));
          Dbg.PrintLn("");
          Dbg.Print("%10s", "-------");
          for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ )
            Dbg.Print(" %10s", "--------");
          Dbg.PrintLn("");
          for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ )
            {
            Dbg.Print("%+10.2f", MeanOreSize(iOSz));
            for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ )
              Dbg.Print(" %10.4f", Diamond(iDSz, iOSz, iSG ));
            Dbg.PrintLn("");
            }
          }
        Dbg.Indent(-2);
        }
      }
    Dbg.PrintLn("-------------------------------------------------------");
    Dbg.UnLock();
    }
  };
Esempio n. 4
0
void CLimnStream::LoadFeed()
  { 
  if (!m_bCalculate || m_pFeed==NULL)
    return;
 
  MVector Vec = Vector;

  if (0)
    {
    Dbg.PrintLn("Vector @ LoadFeed");
    MVector V=Vector;
    for (int i=0; i<V.Count(); i++)
      Dbg.PrintLn("M[%-25s] : %10.4f", gs_MVDefn[i].Symbol(), V.M[i]);
    Dbg.PrintLn("");
    }

  double OreMass=0;
  for (int iSG=0; iSG<gs_DWCfg.nSGs(); iSG++)
    OreMass += Vec.M[gs_DWCfg.OreSpIds(iSG)];

  CArray <double, double> OreMasses;
  OreMasses.SetSize(gs_DWCfg.OreBlockCount());
	OreMassFromDensimetricDistribution(&gs_DWCfg, 
											               &m_pFeed->m_Densimetrics[0], 
											               &m_pFeed->m_OreSizeFeed[0], 
											               OreMass,//double totalFlow, 
											               &OreMasses[0] ) ;

  CArray <double, double> DmdDeport;
  DmdDeport.SetSize(gs_DWCfg.DataBlockCount());//DiamondBlockCount());
	DiamondDeportmentFromSGDistribution(&gs_DWCfg,
                                      &m_pFeed->m_Densimetrics[0], 
                                      &m_pFeed->m_OreSizeFeed[0], 
                                      &m_pFeed->m_DmdSGFeed[0], 
                                      &m_pFeed->m_DmdSizeFeed[0], 
                                      Vec.M[gs_DWCfg.DiamondSpId()],
                                      &DmdDeport[0]) ;

  m_Data[gs_DWCfg.iWaterLimnStreamIndex()]  = Vec.M[gs_DWCfg.WaterSpId()];
  m_Data[gs_DWCfg.iFeSiLimnStreamIndex()]   = Vec.M[gs_DWCfg.FeSiSpId()];

  //for (int iSz= 0; iSz< gs_DWCfg.nOreSizes(); iSz++ )
  //  {
  //  Dbg.Print("Densimetrics:");
  //  for (int iSG= 0 ; iSG< gs_DWCfg.nSGs(); iSG++ )
  //    Dbg.Print(" %10.4f", m_pFeed->m_Densimetrics[xlIndex(iSz, iSG, gs_DWCfg.nSGs())]);
  //  Dbg.PrintLn("");
  //  }
  //Dbg.PrintLn("");
  //for (int i= 0 ; i< m_pFeed->m_OreSizeFeed.GetCount(); i++ )
  //  Dbg.PrintLn("m_OreSizeFeed[%3i] %10.4f", i, m_pFeed->m_OreSizeFeed[i]);
  //Dbg.PrintLn("");
  //for (int i= 0 ; i< m_pFeed->m_DmdSGFeed.GetCount(); i++ )
  //  Dbg.PrintLn("m_DmdSGFeed[%3i]   %10.4f", i, m_pFeed->m_DmdSGFeed[i]);
  //Dbg.PrintLn("");
  //for (int i= 0 ; i< m_pFeed->m_DmdSizeFeed.GetCount(); i++ )
  //  Dbg.PrintLn("m_DmdSizeFeed[%3i] %10.4f", i, m_pFeed->m_DmdSizeFeed[i]);
  //Dbg.PrintLn("");

  for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ )
    {
    for (int iSG = 0 ; iSG < nSGs(); iSG++ )
      {
      Ore(iOSz, iSG) = OreMasses[xlIndex( iOSz, iSG, nSGs() )] ;
      }
    }

  for (int iDSz = 0 ; iDSz< nDiamondSizes(); iDSz++ )
    {
    for (int iOSz = 0 ; iOSz < nOreSizes() ; iOSz++ )
      {
      for (int iSG = 0 ; iSG < nSGs(); iSG++ )
        {
        Diamond(iDSz, iOSz, iSG)=DmdDeport[gs_DWCfg.iDDIndex(iDSz, iOSz, iSG)];
        }
      }
    }

  m_bIsMassForm = true;

  if (DoDbg)
    Dump("LoadFeed", DoDbg);
  
  ConvertToFracForm(Vector, false);

  if (DoDbg)
    Dump("LoadFeed", DoDbg);
  };