0

I work on a code written by someone else which unfortunately I have no access to.

The code is written mostly in C#, but the calculation algorithms are in C++. At a certain part of the code, some instances are created to receive input values from excel, for example:

// initialize input & output structures.  
var fluxIn = new RSEInterop.FluxInput(thermoInfo);
var MF_Input1 = new RSEInterop.FlashInput(thermoInfo);

Data is read:

// read input data 
fluxIn.PressureInlet = Convert.ToDouble(range[rows[MassFluxTool.inputPressure], SheetConstants.DATA_COLUMN]) * 1e5;
 MF_Input1.Target1 = fluxIn.PressureInlet;
 MF_Input1.ReturnDerivatives = false;

 int compStart = rows[MassFluxTool.massFrac];
 for (int i = 0; i < thermoInfo.ComponentCount; i++)
     {
     fluxIn.set_MassFractions(i, Convert.ToDouble(range[compStart + i, SheetConstants.DATA_COLUMN]));
     MF_Input1.set_Composition(i, Convert.ToDouble(range[compStart + i, SheetConstants.DATA_COLUMN]));
     }

The calculation is then performed for several different "scenarios" (or models):

for (int i = 0; i < RSEObjectModel.SystemCommon.FluxModels.Count; i++)
                {

The first iteration works fine:

fluxIn.EnthalpyInlet = RSEInterop.FlashCalls.PXFlash(MF_Input1).get_enthalpy(0);
fluxOut = RSEInterop.MassFlux.get_mass_flux(fluxIn, thermoInfo);

But in the second loop, an Exception is thrown on this function quoted before. The exception appears here:

    FlashInput::~FlashInput() 
    {
        delete[] composition;
    }

As if after "using" the instance once, it gets deleted internally and I cannot simply change its value anymore and use it again.

I hope the promblem is clear enough and appreciate any explanation / solution.

  • Your question lacks [mcve], but my crystal ball suggests that you didn't follow [the Rule of Three](https://stackoverflow.com/questions/4172722/what-is-the-rule-of-three). – Yksisarvinen Sep 09 '21 at 10:35

0 Answers0