-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application breaks when UpdatePT is called in loop after using SetFraction #35
Comments
I dont get any error running the same code, so it is hard to tell what is wrong. |
No, I don't have any problem running other SharpFluids code. |
I just updated SharpFluids version to 3.0.259 and it doesn't produce the error with the above code anymore. However, it will have problem if I increase the number of loops. For example, I add 3 more loops below (I'm using .NET 6) ` Fluid Meg = new Fluid(FluidList.MixEthyleneGlycolAQ); Meg.SetFraction(0.2); Meg.SetFraction(0.3); Meg.SetFraction(0.4); Meg.SetFraction(0.5); |
The above code seems to work ok with .NET 5. So I think the problem only exist in .NET 6 |
This issue has been resolved. The issue was that, if you were using 64-bit operating system, disposing of DoubleVector did not check the environment, and assumed 32-but version in every system. |
I'm trying to build an app to get specific heat, density and dynamic viscosity of a mixture based on temperature, pressure and fraction. The way I do it is first SetFraction then call UpdatePT in a loop. However, the application always enter break mode after UpdatePT is called for a number of time.
Here's some simple code that I use to debug the problem:
`
using EngineeringUnits;
using EngineeringUnits.Units;
using SharpFluids;
Fluid Meg = new Fluid(FluidList.MixEthyleneGlycolAQ);
Meg.SetFraction(0.1);
for (var i = 0; i <= 100; i++)
{
Meg.UpdatePT(Pressure.FromAtmospheres(1), Temperature.FromDegreesCelsius(i));
Console.WriteLine("Specific Heat of MEG at " + i + " °C and fraction 0.1: " + Meg.Cp.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramKelvin));
Console.WriteLine("Density of MEG at " + i + " °C and fraction 0.1: " + Meg.Density.KilogramsPerCubicMeter);
Console.WriteLine("Dynamic Viscosity of MEG at " + i + " °C and fraction 0.1: " + Meg.DynamicViscosity.MillipascalSeconds);
}
Meg.SetFraction(0.2);
for (var i = 0; i <= 100; i++)
{
Meg.UpdatePT(Pressure.FromAtmospheres(1), Temperature.FromDegreesCelsius(i));
Console.WriteLine("Specific Heat of MEG at " + i + " °C and fraction 0.2: " + Meg.Cp.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramKelvin));
Console.WriteLine("Density of MEG at " + i + " °C and fraction 0.2: " + Meg.Density.KilogramsPerCubicMeter);
Console.WriteLine("Dynamic Viscosity of MEG at " + i + " °C and fraction 0.2: " + Meg.DynamicViscosity.MillipascalSeconds);
}
`
The error is:
`
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'CoolPropPINVOKE' threw an exception.
Source=SharpFluids
StackTrace:
at CoolPropPINVOKE.delete_DoubleVector(HandleRef jarg1)
at DoubleVector.Dispose()
at DoubleVector.Finalize()
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
Inner Exception 2:
BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B)
`
It seems that the application will enter break mode when the second loop reach ~51st time. Even if I use a different fluid, the result is still the same.
Am I doing something wrong or is it a bug?
The text was updated successfully, but these errors were encountered: