Пример #1
0
Rootdens_G_P::Rootdens_G_P (const BlockModel& al)
    : Rootdens (al),
      DensRtTip (al.number ("DensRtTip")),
      MinDens (al.number ("MinDens")),
      a (-42.42e42),
      L0 (-42.42e42)
{ }
Пример #2
0
BlockGraph::BlockGraph(Project *project)
{
    // First look for all input blocks
    QPtrList<BlockNode> inputBlocks;
    for (QPtrListIterator<AbstractModel> it(*project->blocks()); it != 0;
         ++it) {

        BlockModel* block = dynamic_cast<BlockModel*>(*it);
        if (block != 0)  {
            if (!block->hasInputPins() && !block->hasEpisodicPins()) {
                addInputBlock(block);
            }
        }
    }

    // iterate through all pins
    QValueList<PinNode*> pins = nodeByPin_.values();
    for (QValueList<PinNode*>::Iterator it2 = pins.begin(); it2 != pins.end();
         ++it2) {

        QPtrList<PinNode> neighbours = (*it2)->neighbours();
        for (QPtrListIterator<PinNode> it3(neighbours); it3 != 0;
             ++it3) {

            if ((*it2)->parent() != (*it3)->parent()) {
                QPtrList<PinNode> seen;
                addBlockNeighbour(*it2, *it3, seen);
            }
        }
    }
}
Пример #3
0
 // Create & Destroy.
 PetPM (const BlockModel& al)
   : Pet (al),
     net_radiation (Librarian::build_stock<NetRadiation> (al.metalib (),
                                                          al.msg (),
                                                          "brunt", objid)),
     rb (al.number ("rb"))
   { }
Пример #4
0
 explicit ReactionBoundrel (const BlockModel& al)
   : Reaction (al),
     immobile (al.name ("immobile")),
     bound (al.name ("bound", Attribute::None ())),
     colloid (al.name ("colloid")),
     release (0.0)
 { }
Пример #5
0
 PhotoGL (const BlockModel& al)
   : Photo (al),
     Qeff (al.number ("Qeff")),
     Fm (al.number ("Fm")),
     TempEff (al.plf ("TempEff")),
     DSEff (al.plf ("DSEff")),
     DAPEff (al.plf ("DAPEff"))
 { }
Пример #6
0
 NumberSource (const BlockModel& al)
   : Number (al),
     source (Librarian::build_item<Source> (al, "source")),
     begin (al.check ("begin") ? new Time (al.submodel ("begin")) : NULL),
     end (al.check ("end") ? new Time (al.submodel ("end")) : NULL),
     state (uninitialized),
     val (-42.42e42)
 { }
Пример #7
0
Rootdens_AP::Rootdens_AP (const BlockModel& al)
  : Rootdens (al),
    a_DS (al.plf ("a_DS")),
    q (al.number ("q")),
    a (-42.42e42),
    L0 (-42.42e42)
  
{ }
Пример #8
0
PhotoFarquhar::PhotoFarquhar (const BlockModel& al)
  : Photo (al),
    Xn (al.number ("Xn")),
    Gamma25 (al.number ("Gamma25")),
    Ea_Gamma (al.number ("Ea_Gamma")),
    rubiscoNdist (Librarian::build_item<RubiscoNdist> (al, "N-dist")),
    Stomatacon (Librarian::build_item<StomataCon> (al, "Stomatacon"))
{ }
Пример #9
0
 ConditionMMDD (const BlockModel& al)
   : Condition (al),
     month (al.integer ("month")),
     day (al.integer ("day")),
     hour (al.integer ("hour")),
     minute (al.integer ("minute")),
     second (al.integer ("second"))
 { }
Пример #10
0
 EquilibriumGoal_A (const BlockModel& al)
   : Equilibrium (al),
     goal_A_expr (Librarian::build_item<Number> (al, "goal_A")),
     min_B_expr (Librarian::build_item<Number> (al, "min_B")),
     A_solute (al.flag ("A_solute")),
     B_solute (al.flag ("B_solute")),
     debug_cell (al.integer ("debug_cell"))
 { }
Пример #11
0
ChemistryMulti::ChemistryMulti (const BlockModel& al)
  : Chemistry (al),
    combine (Librarian::build_vector<Chemistry> (al, "combine")),
    ignore (al.name_sequence ("ignore")),
    max_sink_total (al.number ("max_sink_total")),
    max_sink_solute (al.number ("max_sink_solute")),
    max_sink_secondary (al.number ("max_sink_secondary")),
    min_sink_total (al.number ("min_sink_total")),
    chemicals (find_chemicals (combine))
{ }
Пример #12
0
 ActionWaitDays (const BlockModel& al)
   : Action (al),
     days (al.integer ("days")),
     hours (al.integer ("hours")),
     activated (al.check ("end_time")),
     end_time (1, 1, 1, 1)
 { 
   if (activated)
     end_time = Time (al.submodel ("end_time"));
 }
Пример #13
0
HydraulicM_vGp::HydraulicM_vGp (const BlockModel& al)
  : Hydraulic (al),
    alpha (al.number ("alpha")),
    a (-alpha),
    n (al.number ("n")),
    m (1 - 1 / n),
    l (al.number ("l")),
    M_ (),
    h_m (al.number ("h_m")),
    f (al.number ("f")),
    p_m_matrix (pow (1.0 / (-h_m * 1.0 + 1.0), f))
{ }
Пример #14
0
 ActionRepeat (const BlockModel& al)
   : Action (al),
     metalib (al.metalib ()),
     modified_frame (Action::frame (), FrameModel::parent_link),
     repeat (&al.model ("repeat").clone ()),
     action (al.check ("do") 
             ? Librarian::build_item<Action> (al, "do")
             : Librarian::build_item<Action> (al, "repeat"))
 { 
   if (!modified_frame.check ("do"))
     modified_frame.set ("do", *repeat);
 }
Пример #15
0
 ProgramRS2WG (const BlockModel& al)
   : Program (al),
     path (al.path ()),
     rshourly_origin (al.integer ("rshourly_origin"), 1, 1, 0),
     wgcycle_begin (al.integer ("wgcycle_begin"), 1, 1, 0),
     wgcycle_end (al.integer ("wgcycle_begin") + al.integer ("wgcycle_length"),
                  1, 1, 0),
     rshourly_file (al.name ("rshourly_file")),
     rsdaily_file (al.name ("rsdaily_file")),
     dwfhourly_file (al.name ("dwfhourly_file")),
     hint_file (al.name ("hint_file")),
     hlim (al.number_sequence ("hlim"))
 { }
Пример #16
0
ReactionDenit::ReactionDenit (const BlockModel& al)
  : Reaction (al),
    K (al.number ("K")),
    K_fast (al.number ("K_fast", K)),
    alpha (al.number ("alpha")),
    alpha_fast (al.number ("alpha_fast", alpha)),
    heat_factor (al.check ("heat_factor") 
                 ? al.plf ("heat_factor") 
                 : PLF::empty ()),
    water_factor (al.plf ("water_factor")),
    water_factor_fast (al.check ("water_factor_fast" )
                       ? al.plf ("water_factor_fast")
                       : water_factor),
    redox_height (al.number ("redox_height", 1.0))
{ }
Пример #17
0
  Model* construct (const Block& context, const symbol key, 
                    const FrameModel& frame) const
  {
    BlockModel block (context, frame, key);

    if (!frame.check (context))
      return NULL;

    try
      { return builder.make (block); }
    catch (const std::string& err)
      { block.error ("Build failed: " + err); }
    catch (const char *const err)
      { block.error ("Build failure: " + std::string (err)); }
    return NULL;
  }
Пример #18
0
Horizon::Horizon (const BlockModel& al)
  : ModelDerived (al.type_name ()),
    impl (new Implementation (al)),
    fast_clay (-42.42e42),
    fast_humus (-42.42e42),
    hydraulic (Librarian::build_item<Hydraulic> (al, "hydraulic")),
    tortuosity (Librarian::build_item<Tortuosity> (al, "tortuosity"))
{ }
Пример #19
0
std::unique_ptr<Volume>
Volume::build_obsolete (const BlockModel& al)
{
  Volume *const vol = Librarian::build_item<Volume> (al, "volume");
  daisy_assert (vol);
  if (al.check ("from"))
    {
      const double from = al.number ("from");
      if (from < 0)
        vol->limit_top (from);
    }
  if (al.check ("to"))
    {
      const double to = al.number ("to");
      if (to < 0)
        vol->limit_bottom (to);
    }
  return std::unique_ptr<Volume> (vol);
}
Пример #20
0
LogTable::LogTable (const BlockModel& al)
  : LogSelect (al),
    const_entries (entries.begin (), entries.end ()),
    destination (al, const_entries)
{ 
  if (!al.ok ())
    return;

  for (unsigned int i = 0; i < entries.size (); i++)
    entries[i]->add_dest (&destination);
}
Пример #21
0
 ActionSow (const BlockModel& al)
   : Action (al),
     metalib (al.metalib ()),
     crop (&al.model ("crop").clone ()),
     // Use 'plant_distance' if set, otherwise use 'row_width'.
     row_width (al.number ("plant_distance", al.number ("row_width"))),
     // Use 'plant_distance' if set, otherwise use 'row_width'.
     row_pos (al.number ("plant_position", al.number ("row_position"))),
     seed (al.number ("seed", -42.42e42))
 { }
Пример #22
0
SummaryBalance::SummaryBalance (const BlockModel& al)
  : Summary (al),
    description (al.frame ().description ()),
    file (al.name ("where", "")),
    precision (al.integer ("precision")),
    require_top (al.flag ("require_top")),
    input (al.name_sequence ("input")),
    output (al.name_sequence ("output")),
    content (al.name_sequence ("content")),
    fetch (input, output, content)
{ }
Пример #23
0
 ProgramGP2D (const BlockModel& al)
   : Program (al),
     metalib (al.metalib ()),
     geo (submodel<GeometryRect> (al, "Geometry")),
     row_width (al.number ("row_width")),
     row_position (al.number ("row_position")),
     soil_depth (al.number ("soil_depth")),
     crop_depth (al.number ("crop_depth")),
     crop_width (al.number ("crop_width")),
     WRoot (al.number ("WRoot")),
     DS (al.number ("DS"))
 { }
Пример #24
0
DrainLateral::DrainLateral (const BlockModel& al)
  : Drain (al),
    eq_depth (Librarian::build_item<Draineqd> (al, "eq_depth")),
    L (al.number ("L")),
    rad (al.number ("rad")),
    x (al.number ("x", L / 2.0)),
    pipe_position (al.number ("pipe_position")),
    pipe_outlet (al.check ("pipe_outlet")
                 ? Librarian::build_item<Depth> (al, "pipe_outlet")
                 : Depth::create (pipe_position)),
    K_to_pipes_ (al.number ("K_to_pipes", -1.0)),
    pipe_level (pipe_position),
    height (al.number ("height", pipe_position))
{ }
Пример #25
0
  rubiscoNdist_expr (const BlockModel& al)
    : RubiscoNdist (al),
      f_photo (al.number ("f_photo")),
      expr (Librarian::build_item<Number> (al, "value")),
      scope (__FUNCTION__)
  {
    scope.add_item (new ExchangeNumber (LAI_symbol, Attribute::None(),
					"Leaf area index"));
    scope.add_item (new ExchangeNumber (distance_from_top_symbol, "cm",
					"Distance from top of canopy"));
    scope.add_item (new ExchangeNumber (relative_LAI_symbol, Attribute::None(),
					"Relative leaf area index"));
    scope.add_item (new ExchangeNumber (relative_distance_from_top_symbol, Attribute::None(),
					"Relative distance from top of canopy"));
    scope.add_item (new ExchangeNumber (DS_symbol, Attribute::None(),
					"Development stage"));
    scope.done ();
    expr->initialize (al.units (), scope, al.msg());
    if (!expr->check_dim (al.units (), scope, Attribute::Fraction (), al.msg()))
      al.error("Invalid expression of rubisco expr");
  }
Пример #26
0
void LibraryWindow::addDefaultItems()
{
    BlockModel *model;

    // cpu
    model = new CpuModel("CPU", tr("Default CPU"));
    model->addPin(new PinModel(model, "in1", 0, 32, PinModel::INPUT, 1));
    model->addPin(new PinModel(model, "out1", 0, 32, PinModel::OUTPUT, 1));
    model->addPin(new PinModel(model, "clk", 0, 32, PinModel::EPISODIC, 1));
    model->addPin(new PinModel(model, "reset", 0, 32, PinModel::EPISODIC, 2));
    add(model);

    // core
    model = new BlockModel("Core",tr("Default core"));
    model->addPin(new PinModel(model, "in1", 0, 32, PinModel::INPUT, 1));
    model->addPin(new PinModel(model, "out1", 0, 32, PinModel::OUTPUT, 1));
    add(model);

    // input
    model = new BlockModel("Input", tr("Default input block"));
    model->setType("I/O");
    model->setHasEpisodicPins(false);
    model->setHasInputPins(false);
    model->setRuntime(1);
    model->addPin(new PinModel(model, "out1", 0, 32, PinModel::OUTPUT, 1));
    model->addPin(new PinModel(model, "out2", 32, 32, PinModel::OUTPUT, 2));
    model->addPin(new PinModel(model, "out3", 64, 32, PinModel::OUTPUT, 3));
    add(model);

    // output
    model = new BlockModel("Output", tr("Default output block"));
    model->setType("I/O");
    model->setHasEpisodicPins(false);
    model->setHasOutputPins(false);
    model->setRuntime(1);
    model->addPin(new PinModel(model, "in1", 0, 32, PinModel::INPUT, 1));
    model->addPin(new PinModel(model, "in2", 32, 32, PinModel::INPUT, 2));
    model->addPin(new PinModel(model, "in3", 64, 32, PinModel::INPUT, 3));
    add(model);

    // mux
    MuxModel *muxModel = new MuxModel("Mux", tr("Multiplexer / Demultiplexer"));
    PinModel *in1 = new PinModel(muxModel, "in1", 0, 32, PinModel::INPUT, 1);
    PinModel *in2 = new PinModel(muxModel, "in2", 32, 32, PinModel::INPUT, 2);
    PinModel *out1 = new PinModel(muxModel, "out1", 0, 64, PinModel::OUTPUT, 1);
    muxModel->addPin(in1);
    muxModel->addPin(in2);
    muxModel->addPin(out1);
    muxModel->addMuxMapping(new MuxMapping(in1, out1, 0, 32, 0, 32));
    muxModel->addMuxMapping(new MuxMapping(in2, out1, 0, 32, 32, 64));
    add(muxModel);

    modified_ = false;
}
Пример #27
0
Mactrans::Mactrans (const BlockModel& al)
  : name (al.type_name ())
{ }
Пример #28
0
UZRectConst::UZRectConst (const BlockModel& al)
  : UZRect (al),
    q_x (al.number ("q_x")),
    q_z (al.number ("q_z"))
{ }
Пример #29
0
int IntersectByMaster(CCdCore* ccd, double rowFraction) {

    int result = -1;
    unsigned int masterLen = (ccd) ? ccd->GetSequenceStringByRow(0).length() : 0;
    if (masterLen == 0) return result;

    int slaveStart;
    int nAlignedIBM = 0;
    unsigned int i, j, nBlocks;
    unsigned int nRows = ccd->GetNumRows();

    //  If there is already a consistent block model, do nothing.
    MultipleAlignment* ma = new MultipleAlignment(ccd);
    if (ma && ma->isBlockAligned()) {
        delete ma;
        return 0;
    }
    delete ma;


    BlockIntersector blockIntersector(masterLen);
    BlockModel* intersectedBlockModel;
    //BlockModel* simpleIntersectedBlockModel;
    BlockModelPair* bmp;
    vector<BlockModelPair*> blockModelPairs;
    set<int> forcedCTerminiInIntersection;

    list< CRef< CSeq_align > >& cdSeqAligns = ccd->GetSeqAligns();
    list< CRef< CSeq_align > >::iterator cdSeqAlignIt = cdSeqAligns.begin(), cdSeqAlignEnd = cdSeqAligns.end();

    for (i = 0; cdSeqAlignIt != cdSeqAlignEnd; ++cdSeqAlignIt, ++i) {
        bmp = new BlockModelPair(*cdSeqAlignIt);

        //  We assume # of blocks and all block lengths are same on master and slave.
        if (bmp && bmp->isValid()) {

            blockModelPairs.push_back(bmp);
            blockIntersector.addOneAlignment(bmp->getMaster());

            //  Find places the intersection can't merge blocks (i.e., where there are
            //  gaps in the slave across a block boundary, but not in the master).
            BlockModel& slave = bmp->getSlave();
            nBlocks = slave.getBlocks().size();
            for (j = 0; j < nBlocks - 1; ++j) {  //  '-1' as I don't care about end of the C-terminal block
                if (slave.getGapToCTerminal(j) > 0 && bmp->getMaster().getGapToCTerminal(j) == 0) {
                    forcedCTerminiInIntersection.insert(bmp->getMaster().getBlock(j).getEnd());
                }
            }
        }
    }

    //  There was a problem creating one of the BlockModelPair objects from a seq_align,
    //  or one or more seq_align was invalid.
    if (blockModelPairs.size() != cdSeqAligns.size()) {
        return result;
    }

    //simpleIntersectedBlockModel = blockIntersector.getIntersectedAlignment(forcedCTerminiInIntersection);
    intersectedBlockModel = blockIntersector.getIntersectedAlignment(forcedCTerminiInIntersection, rowFraction);
    nAlignedIBM = (intersectedBlockModel) ? intersectedBlockModel->getTotalBlockLength() : 0;
    if (nAlignedIBM == 0) {
        return result;
    }

/*
    string testStr, testStr2;
    string sint = intersectedBlockModel->toString();
    string sintsimple = simpleIntersectedBlockModel->toString();
    delete simpleIntersectedBlockModel;
    cout << "rowFraction = 1:\n" << sintsimple << endl;
    cout << "rowFraction = " << rowFraction << ":\n" << sint << endl;
*/

    //  As we have case where every block model isn't identical,
    //  change each seq-align to reflect the common set of aligned columns.
    nBlocks = intersectedBlockModel->getBlocks().size();
    for (i = 0, cdSeqAlignIt = cdSeqAligns.begin(); i < nRows - 1 ; ++i, ++cdSeqAlignIt) {

        bmp = blockModelPairs[i];  //BlockModelPair seqAlignPair(*cdSeqAlignIt);
        BlockModel* intersectedSeqAlignSlave = new BlockModel(bmp->getSlave().getSeqId(), false);

        bmp->reverse();
        for (j = 0; j < nBlocks; ++j) {
            const Block& jthMasterBlock = intersectedBlockModel->getBlock(j);
            slaveStart = bmp->mapToMaster(jthMasterBlock.getStart());

            //  since we're dealing w/ an intersection, slaveStart should always be valid
            assert(slaveStart != -1);

            Block b(slaveStart, jthMasterBlock.getLen(), jthMasterBlock.getId());
            intersectedSeqAlignSlave->addBlock(b);
        }
        *cdSeqAlignIt = intersectedSeqAlignSlave->toSeqAlign(*intersectedBlockModel);
        //testStr = intersectedSeqAlignSlave->toString();
        //testStr2 = bmp->getMaster().toString();  // original *slave* alignment

        delete bmp;
    }
    blockModelPairs.clear();
    result = nBlocks;

    delete intersectedBlockModel;

    return result;
}
Пример #30
0
Horizon::Implementation::Implementation (const BlockModel& al)
  : dry_bulk_density (al.number ("dry_bulk_density", -42.42e42)),
    SOM_C_per_N (al.number_sequence ("SOM_C_per_N")),
    C_per_N (al.number ("C_per_N", -42.42e42)),
    SOM_fractions (al.check ("SOM_fractions") 
                   ? al.number_sequence ("SOM_fractions")
                   : std::vector<double> ()),
    turnover_factor (al.number ("turnover_factor")),
    anisotropy (al.number ("anisotropy")),
    attributes (get_attributes (al.submodel_sequence ("attributes"))),
    dimensions (get_dimensions (al.submodel_sequence ("attributes"))),
    nitrification (Librarian::build_item<Nitrification> (al, "Nitrification")),
    secondary (Librarian::build_item<Secondary> (al, "secondary_domain")),
    r_pore_min (al.number ("r_pore_min")),
    primary_sorption_fraction (NAN),
    hor_heat (al.submodel ("HorHeat")),
    CEC (al.number ("CEC", -42.42e42))
{ }