phillipstanleymarbell / Noisy-lang-compiler

Noisy language compiler
MIT License
17 stars 1 forks source link

Assertion fails in newtonEigenLibraryInterfaceGetPiGroups. #530

Open btsouts opened 3 years ago

btsouts commented 3 years ago

Describe the bug For a specific input (provided below) the assertion sanityCheckForNoNegativeOnes fails in line 500 of the newtonEigenLibraryInterfaceGetPiGroups function of newton-eigenLibraryInterface.cpp source file.

calcPresInvariant.nt -- Newton specification that triggers the error

include "NewtonBaseSignals.nt"
voltage : signal =
{
    name = "Volt" English;
    symbol = V;
    derivation = power / current;
}
perKelvinDimension : signal =
{
    derivation = temperature**(-1);
}
pascalPerVoltDimension : signal =
{
    derivation = pressure / voltage;
}
perPascalSquaredDimension : signal =
{
    derivation = pressure**(-2);
}
unitless : signal =
{
    name        = "none" English;
    symbol      = x;
    derivation  = dimensionless;
}
calcPresInvariant: invariant(
   var2 : pressure,
   var3 : pressure,
   calib_par_p4 : pressure,
   calib_par_p5 : pressure,
   calib_par_p6 : pressure,
   calib_par_p7 : pressure,
   calc_pres : pressure,
   unitHavingConstant3 : pressure,
   calib_t_fine : temperature,
   var1 : unitless,
   calib_par_p1 : unitless,
   calib_par_p8 : unitless,
   calib_par_p2 : unitless,
   calib_par_p3 : unitless, 
   unitHavingConstant1 : perKelvinDimension,
   unitHavingConstant2 : pascalPerVoltDimension,
   calib_par_p9 : perPascalSquaredDimension,
   calib_par_p10 : perPascalSquaredDimension,
   pres_adc : voltage
                ) =
{
    var2 ~ var1 * var1 * calib_par_p6,
    var2 ~ var2 + var1 * calib_par_p5,
    var2 ~ var2 + calib_par_p4,
    var1 ~ calib_par_p3 * var1 * var1 + calib_par_p2 * var1,   
    var1 ~ (1.0 + var1) * calib_par_p1,
    calc_pres ~ (calc_pres - var2) / var1,
    var1 ~ calib_par_p9 * calc_pres * calc_pres,
    var2 ~ calc_pres * calib_par_p8,        
    var3 ~ calc_pres * calc_pres * calc_pres * calib_par_p10,
    #
    #   This is the original expression implied by the Bosch code:
    #
    #   var1 ~ calib_t_fine – 64000.0;  
    #
    #   This is the required expression to make it dimensionally-consistent
    #   (we can ignore the additional implicit constant needed to make '64000'
    #   into unitless)
    #
    var1 ~ calib_t_fine * unitHavingConstant1,
    #
    #   This is the original expression implied by the Bosch code:
    #
    #   calc_pres ~ 1048576.0 - pres_adc;   
    #
    #   This is the required expression to make it dimensionally-consistent
    #   (we can ignore the additional implicit constant needed to make '1048576'
    #   into a pressure)
    #
    calc_pres ~ pres_adc * unitHavingConstant2,
    #
    #   This is the original expression implied by the Bosch code:
    #
    #   calc_pres ~ calc_pres + var1 + var2 + var3 + calib_par_p7;  
    #
    #   This is the required expression to make it dimensionally-consistent
    #
    calc_pres ~ calc_pres + var1 * unitHavingConstant3 + var2 + var3 + calib_par_p7
}

To Reproduce Steps to reproduce the behavior:

  1. E.g., ./newton-linux-EN -P -v 2 ../../applications/newton/invariants/calcPresInvariant.nt
  2. See error.
phillipstanleymarbell commented 3 years ago

Will look into this next...