| 569 | } |
| 570 | |
| 571 | bool Simulation::Prepare() |
| 572 | { |
| 573 | ConfigInfo *cfg = m_case->GetConfiguration(); |
| 574 | if ( !cfg ) |
| 575 | { |
| 576 | m_errors.Add("no valid configuration for this case"); |
| 577 | return false; |
| 578 | } |
| 579 | |
| 580 | m_simlist = cfg->Simulations; |
| 581 | |
| 582 | m_outputList.clear(); |
| 583 | m_outputLabels.clear(); |
| 584 | m_outputUnits.clear(); |
| 585 | m_uiHints.clear(); |
| 586 | |
| 587 | size_t nHybrids = cfg->Technology.size(); |
| 588 | |
| 589 | for (size_t ndx_hybrid = 0; ndx_hybrid < nHybrids; ndx_hybrid++) { |
| 590 | |
| 591 | // transfer all the values except for ones that have been 'overriden' |
| 592 | for (VarTableBase::const_iterator it = m_case->Values(ndx_hybrid).begin(); |
| 593 | it != m_case->Values(ndx_hybrid).end(); |
| 594 | ++it) |
| 595 | if (0 == m_inputs[ndx_hybrid].Get(it->first)) |
| 596 | m_inputs[ndx_hybrid].Set(it->first, *(it->second)); |
| 597 | |
| 598 | // recalculate all the equations |
| 599 | CaseEvaluator eval(m_case, m_inputs[ndx_hybrid], m_case->Equations(ndx_hybrid));// update m_inputs for hybrids |
| 600 | int n = eval.CalculateAll(ndx_hybrid); |
| 601 | |
| 602 | if (n < 0) |
| 603 | { |
| 604 | wxArrayString& errs = eval.GetErrors(); |
| 605 | for (size_t i = 0; i < errs.size(); i++) |
| 606 | m_errors.Add(errs[i]); |
| 607 | |
| 608 | return false; |
| 609 | } |
| 610 | |
| 611 | //wxLogStatus("Simulation preparation time: %d copy, %d eval", (int)time_copy, (int)time_eval); |
| 612 | } |
| 613 | return true; |
| 614 | } |
| 615 | |
| 616 | static void dump_variable( FILE *fp, ssc_data_t p_data, const char *name ) |
| 617 | { // .17g to .17g for full double precision. |
no test coverage detected