예제 #1
0
//-----------------------------------------------------------------------------------------------
// Initializes the model, sets up constraints
//-----------------------------------------------------------------------------------------------
void DecoupledModel::initialize()
{

    // initializing all wells, setting up constraints for production wells
    for(int i = 0; i < numberOfWells(); ++i)
    {
        // initializing the well
        well(i)->initialize();

        // casting the well to production well, setting up constraints if cast is ok
        ProductionWell *prod_well = dynamic_cast<ProductionWell*>(well(i));
        if(prod_well != 0) prod_well->setupConstraints();
    }

    // initializing the pipes
    for(int i = 0; i < numberOfPipes(); ++i)
    {
        pipe(i)->initialize(masterSchedule());
    }

    // setting up the constraints for the capacities
    for(int i = 0; i < numberOfCapacities(); ++i)
    {
        capacity(i)->setupConstraints(masterSchedule());
    }

    // setting up the rate input variables
    initializeVarsAndCons();

    // initializing the user defined constraints
    for(int i = 0; i < numberOfUserDefinedConstraints(); ++i) userDefinedConstraint(i)->initialize();

}
예제 #2
0
//-----------------------------------------------------------------------------------------------
// Collects all the integer variables
//-----------------------------------------------------------------------------------------------
QVector<shared_ptr<IntVariable> >& DecoupledModel::integerVariables(bool force_refresh)
{

    if(m_vars_integer.size() == 0 || force_refresh)
    {
        if(force_refresh) m_vars_integer.resize(0);

        // collecting the install time variables for the separators
        for(int i = 0; i < numberOfPipes(); ++i)     // looping through all the pipes
        {
            // checking if this is a separator
            Separator *s = dynamic_cast<Separator*>(pipe(i));

            if(s != 0)
            {
                if(s->installTime()->isVariable()) m_vars_integer.push_back(s->installTime());  // adding install time if it is a variable
            }

        }       

        // collecting the install time variables for the wells
        for(int i = 0 ; i < numberOfWells(); ++i)
        {
            // checking if the well has an install time variable
            if(well(i)->hasInstallTime())
            {
                if(well(i)->installTime()->isVariable()) m_vars_integer.push_back(well(i)->installTime());  // adding install time if it is a variable
            }
        }


    }
    return m_vars_integer;
}
예제 #3
0
//-----------------------------------------------------------------------------------------------
// updates the streams in the material balance constraints
//-----------------------------------------------------------------------------------------------
void DecoupledModel::updateMaterialBalanceStreams()
{
    // emptying the streams in the mbcs
    for(int i = 0; i < m_mb_cons.size(); ++i) m_mb_cons.at(i)->emptyStream();

    // updating the streams in the mbc, starting from the production wells, and working its way up the system
    for(int i = 0; i < numberOfWells(); ++i)
    {
        // trying to cast to production well
        ProductionWell *prod_well = dynamic_cast<ProductionWell*>(well(i));

        if(prod_well != 0)  // this is a production well
        {
            // adding the streams from this well to the upstream pipes connected to it
            addToMaterialBalanceStreamsUpstream(prod_well);

            // looping through the outlet connections of the well, doing the same
            for(int j = 0; j < prod_well->numberOfPipeConnections(); ++j)
            {
                // checking if it is a midpipe or separator
                MidPipe *p_mid = dynamic_cast<MidPipe*>(prod_well->pipeConnection(j)->pipe());
                Separator *p_sep = dynamic_cast<Separator*>(prod_well->pipeConnection(j)->pipe());
                if(p_mid != 0) addToMaterialBalanceStreamsUpstream(p_mid, prod_well, prod_well->pipeConnection(i)->variable()->value());
                else if(p_sep != 0) addToMaterialBalanceStreamsUpstream(p_sep, prod_well, prod_well->pipeConnection(i)->variable()->value());


            } // pipe connection
        } // production well
    } // well


}
예제 #4
0
//-----------------------------------------------------------------------------------------------
// Collects all the real variables
//-----------------------------------------------------------------------------------------------
QVector<shared_ptr<RealVariable> >& DecoupledModel::realVariables(bool force_refresh)
{
    if(m_vars_real.size() == 0 || force_refresh)
    {
        if(force_refresh) m_vars_real.resize(0);

        // getting the control variables for the wells
        for(int i = 0; i < numberOfWells(); ++i)     // looping through all the wells
        {
            Well *w = well(i);

            for(int j = 0; j < w->numberOfControls(); j++)  // looping through each element in the wells schedule
            {
                // checking if this shcedule entry is a variable
                if(w->control(j)->controlVar()->isVariable()) m_vars_real.push_back(w->control(j)->controlVar());
            }

            // checking if this is a production well, and if it has gas lift controls
            ProductionWell *prod_well = dynamic_cast<ProductionWell*>(w);
            if(prod_well != 0)
            {
                for(int j = 0; j < prod_well->numberOfGasLiftControls(); ++j)
                {
                    if(prod_well->gasLiftControl(j)->controlVar()->isVariable()) m_vars_real.push_back(prod_well->gasLiftControl(j)->controlVar());
                }
            }


        }

        // getting the remove fraction and capacity variables for the separators
        for(int i = 0; i < numberOfPipes(); ++i)    // looping through the pipes, finding the separators
        {
            Separator *s = dynamic_cast<Separator*>(pipe(i));

            if(s != 0)  // this is a separator
            {
                if(s->removeFraction()->isVariable()) m_vars_real.push_back(s->removeFraction());
                if(s->removeCapacity()->isVariable()) m_vars_real.push_back(s->removeCapacity());
            }
        }


        // getting the input rate variables
        for(int i = 0; i < m_rate_vars.size(); ++i)
        {
            m_vars_real.push_back(m_rate_vars.at(i)->oilVariable());
            m_vars_real.push_back(m_rate_vars.at(i)->gasVariable());
            m_vars_real.push_back(m_rate_vars.at(i)->waterVariable());
        }

    }

    return m_vars_real;
}
예제 #5
0
int main(){
	TestResult tr;
	TestRegistry::runAllTests(tr);

	StructuredScript::Storage::GlobalStorage globalStorage;
	StructuredScript::IGlobalStorage::globalStorage = &globalStorage;

	globalStorage.init();
	globalStorage.path("Includes");

	std::string input;
	StructuredScript::Parser::Parser parser;
	StructuredScript::ExceptionManager xManager;

	while (true){
		std::cout << "> ";
		std::getline(std::cin, input);

		StructuredScript::Scanner::Scanner scanner;
		StructuredScript::Scanner::StringCharacterWell well(input);

		auto node = parser.parse(well, scanner, &xManager);
		if (xManager.has()){
			if (xManager.hasBreak())
				std::cout << "'break' found outside loop!\n";
			else if (xManager.hasContinue())
				std::cout << "'continue' found outside loop!\n";
			else if (xManager.hasReturn())
				std::cout << "'return' found outside function!\n";
			else
				std::cout << xManager.get()->str(nullptr, nullptr, nullptr) << "\n";

			xManager.clear();
			continue;
		}

		node->evaluate(&globalStorage, &xManager, nullptr);
		if (xManager.has()){
			if (xManager.hasBreak())
				std::cout << "'break' found outside loop!\n";
			else if (xManager.hasContinue())
				std::cout << "'continue' found outside loop!\n";
			else if (xManager.hasReturn())
				std::cout << "'return' found outside function!\n";
			else
				std::cout << xManager.get()->str(nullptr, nullptr, nullptr) << "\n";

			xManager.clear();
		}
	}

	return 0;
}
예제 #6
0
파일: eclxx_smspec.cpp 프로젝트: chflo/ert
void test_smspec_wg() {
    std::string kw( "WWCT" );
    std::string wg( "OP1" );
    std::string gr( "WG1" );

    ERT::smspec_node well( ECL_SMSPEC_WELL_VAR, wg, kw );
    ERT::smspec_node group( ECL_SMSPEC_GROUP_VAR, gr, kw );

    test_assert_true(well.wgname() == wg);
    test_assert_true(well.type() == ECL_SMSPEC_WELL_VAR );

    test_assert_true(group.wgname() == gr);
    test_assert_true(group.type() == ECL_SMSPEC_GROUP_VAR );
}
예제 #7
0
//-----------------------------------------------------------------------------------------------
// Collects all the binary variables
//-----------------------------------------------------------------------------------------------
QVector<shared_ptr<BinaryVariable> >& DecoupledModel::binaryVariables(bool force_refresh)
{

    if(m_vars_binary.size() == 0 || force_refresh)
    {
        if(force_refresh) m_vars_binary.resize(0);

        // finding well routnig variables
        for(int i = 0; i < numberOfWells(); i++)
        {
            // checking if this is a production well
            ProductionWell* prod_well = dynamic_cast<ProductionWell*>(well(i));

            if(prod_well != 0)
            {
                // looping through the pipe connections
                for(int j = 0; j < prod_well->numberOfPipeConnections(); j++)
                {
                    if(prod_well->pipeConnection(j)->variable()->isVariable()) m_vars_binary.push_back(prod_well->pipeConnection(j)->variable());
                }
            }

        }



        // finding pipe routing variables
        for(int j = 0; j < numberOfPipes(); ++j)
        {

            MidPipe *p_mid = dynamic_cast<MidPipe*>(pipe(j));     // end pipes do not have routing

            if(p_mid != 0)
            {
                // looping through the outlet connections
                for(int j = 0; j < p_mid->numberOfOutletConnections(); j++)
                {
                    if(p_mid->outletConnection(j)->variable()->isVariable()) m_vars_binary.push_back(p_mid->outletConnection(j)->variable());
                }

            }
        }
    }


    return m_vars_binary;
}
예제 #8
0
void test_smspec_wg() {
    std::string wkw( "WWCT" );
    std::string gkw( "GWCT" );
    std::string wg( "OP1" );
    std::string gr( "WG1" );

    ERT::smspec_node well( ECL_SMSPEC_WELL_VAR, wg, wkw );
    ERT::smspec_node group( ECL_SMSPEC_GROUP_VAR, gr, gkw );

    test_assert_string_equal(well.key1() , "WWCT:OP1");
    test_assert_string_equal(well.keyword() , "WWCT");
    test_assert_true(well.wgname() == wg);
    test_assert_true(well.type() == ECL_SMSPEC_WELL_VAR );

    test_assert_string_equal(group.key1(), "GWCT:WG1");
    test_assert_string_equal(group.keyword() , "GWCT");
    test_assert_true(group.wgname() == gr);
    test_assert_true(group.type() == ECL_SMSPEC_GROUP_VAR );
}
예제 #9
0
//-----------------------------------------------------------------------------------------------
// Collects all the constraints
//-----------------------------------------------------------------------------------------------
QVector<shared_ptr<Constraint> >& DecoupledModel::constraints(bool force_refresh)
{
    // TODO: the part of this function that is common between Coupled and Decoupled model should be put back into the Model class

    if(m_cons.size() == 0 || force_refresh)
    {
        if(force_refresh) m_cons.resize(0);

        // getting the well bhp constraints
        for(int i = 0; i < numberOfWells(); ++i)
        {
            // checking if this is a production well
            ProductionWell* prod_well = dynamic_cast<ProductionWell*>(well(i));

            if(prod_well != 0)
            {
                for(int i = 0; i < prod_well->numberOfBhpConstraints(); ++i) m_cons.push_back(prod_well->bhpConstraint(i));
            }
        }

        // getting the well pipe connection constraints
        for(int i = 0; i < numberOfWells(); ++i)
        {
            // checking if this is a production well
            ProductionWell* prod_well = dynamic_cast<ProductionWell*>(well(i));

            if(prod_well != 0)
            {
                if(prod_well->pipeConnectionConstraint() != 0) m_cons.push_back(prod_well->pipeConnectionConstraint());
            }
        }

        // getting the mid pipe connection constraints
        for(int i = 0; i < numberOfPipes(); ++i)
        {
            // checking if this is a mid pipe
            MidPipe *p_mid = dynamic_cast<MidPipe*>(pipe(i));

            if(p_mid != 0) m_cons.push_back(p_mid->outletConnectionConstraint());
        }



        // getting the separator capacity constraints
        for(int i = 0; i < numberOfCapacities(); ++i)
        {
            Capacity *sep = capacity(i);

            m_cons += sep->gasConstraints();
            m_cons += sep->oilConstraints();
            m_cons += sep->waterConstraints();
            m_cons += sep->liquidConstraints();

        }

        // getting the material balance constraints
        for(int i = 0; i < m_mb_cons.size(); ++i)
        {
            MaterialBalanceConstraint *mbc = m_mb_cons.at(i);

            m_cons.push_back(mbc->oilConstraint());
            m_cons.push_back(mbc->gasConstraint());
            m_cons.push_back(mbc->waterConstraint());

        }

        // getting the user defined constraints
        for(int i = 0; i < numberOfUserDefinedConstraints(); ++i)
        {
            m_cons.push_back(userDefinedConstraint(i)->constraint());
        }
    }


    return m_cons;
}
예제 #10
0
void qcolor_well(struct qcolor c1, struct qcolor *output) {
    output->r = well(c1.r);
    output->g = well(c1.g);
    output->b = well(c1.b);
}