pratheeba.chandanagarajan
Subscriber
Hi, 
I am doing reactive simulations. I need to vary the concentrations of the species in a UDF. I have another UDF for reaction rate. These are hooked correctly(to my knowledge).  The UDF's compile and load without error.
 
However, on initializing, I get Node 0: Process 23300: Received signal SIGSEGV. 
 
I have checked for memory locations (UDMI). They are sufficient.
 
Please help me why I get this error.
 
This is my UDF:
#include "udf.h"
 
DEFINE_PROFILE(mass_fractions, thread, position)
{
    real t = RP_Get_Real("flow-time"); // Get current flow time
    real mass_fraction_CO = 0.0; // Initialize mass fraction of CO
    real mass_fraction_O2 = 0.0; // Initialize mass fraction of O2
    real mass_fraction_H2 = 0.0; // Initialize mass fraction of H2
    real mass_fraction_C3H6 = 0.0; // Initialize mass fraction of C3H6
    real mass_fraction_NO = 0.0; // Initialize mass fraction of NO
    real mass_fraction_CO2 = 0.0; // Initialize mass fraction of CO2
    real mass_fraction_NO2 = 0.0; // Initialize mass fraction of NO2
    real mass_fraction_H2O = 0.0; // Initialize mass fraction of H2O
    real mass_fraction_N2 = 0.0; // Initialize mass fraction of N2
    
    // Define the CO mass fraction schedule
    if (t >= 0.0 && t < 10.0) {
 
 
mass_fraction_CO = 9.7073e-5; // Constant CO mass fraction at 9.7073e-5 from 0 to 10 seconds
mass_fraction_O2 = 6.6564e-2; // Constant O2 mass fraction at 6.6564e-2 from 0 to 10 seconds
mass_fraction_H2 = 2.2881e-6; // Constant H2 mass fraction at 2.2881e-6 from 0 to 10 seconds
mass_fraction_C3H6 = 5.0963e-4; // Constant C3H6 mass fraction at 5.0963e-4 from 0 to 10 seconds
        mass_fraction_NO = 1.5601e-4; // Constant NO mass fraction at 1.5601e-4 from 0 to 10 seconds
mass_fraction_CO2 = 1.5254e-1; // Constant CO2 mass fraction at 0.003130 from 0 to 10 seconds
mass_fraction_NO2 = 0.0; // Constant NO2 mass fraction at 0.0 from 0 to 10 seconds
mass_fraction_H2O = 6.2404e-2; // Constant H2O mass fraction at 6.2404e-2 from 0 to 10 seconds
 
// Calculate the mass fraction of N2 as the difference
        // between 1 and the sum of mass fractions of other species
        mass_fraction_N2 = 1.0 - mass_fraction_CO - mass_fraction_O2 -mass_fraction_H2 - mass_fraction_CO2 - mass_fraction_C3H6 - mass_fraction_NO - mass_fraction_NO2 - mass_fraction_H2O;                          
    }
 
    else if (t >= 10.0 && t < 20.0) {
        mass_fraction_CO = 1.4561e-4; // CO mass fraction from 10 to 20 seconds
mass_fraction_O2 = 6.6566e-2; // Constant O2 mass fraction from 10 to 20 seconds
mass_fraction_H2 = 4.5764e-6; // Constant H2 mass fraction from 10 to 20 seconds
mass_fraction_C3H6 = 5.0965e-4; // Constant C3H6 mass fraction from 10 to 20 seconds
        mass_fraction_NO = 1.5601e-4; // Constant NO mass fraction from 10 to 20 seconds
mass_fraction_CO2 = 1.5255e-1; // Constant CO2 mass fraction from 10 to 20 seconds
mass_fraction_NO2 = 0.0; // Constant NO2 mass fraction from 10 to 20 seconds
mass_fraction_H2O = 6.2406e-2; // Constant H2O mass fraction from 10 to 20 seconds
 
// Calculate the mass fraction of N2 as the difference
        // between 1 and the sum of mass fractions of other species
        mass_fraction_N2 = 1.0 - mass_fraction_CO - mass_fraction_O2 -mass_fraction_H2 - mass_fraction_CO2 - mass_fraction_C3H6 - mass_fraction_NO - mass_fraction_NO2 - mass_fraction_H2O;                            
    }
 
    
    else if (t >= 20.0 && t < 40.0) {
        mass_fraction_CO = 9.7073e-5; // Constant CO mass fraction at 9.7073e-5 from 20 to 40 seconds
mass_fraction_O2 = 6.6564e-2; // Constant O2 mass fraction at 6.6564e-2 from 20 to 40 seconds
mass_fraction_H2 = 2.2881e-6; // Constant H2 mass fraction at 2.2881e-6 from 20 to 40 seconds
mass_fraction_C3H6 = 5.0963e-4; // Constant C3H6 mass fraction at 5.0963e-4 from 20 to 40 seconds
        mass_fraction_NO = 1.5601e-4; // Constant NO mass fraction at 1.5601e-4 from 20 to 40 seconds
mass_fraction_CO2 = 1.5254e-1; // Constant CO2 mass fraction at 0.003130 from 20 to 40 seconds
mass_fraction_NO2 = 0.0; // Constant NO2 mass fraction at 0.0 from 20 to 40 seconds
mass_fraction_H2O = 6.2404e-2; // Constant H2O mass fraction at 6.2404e-2 from 20 to 40 seconds
 
// Calculate the mass fraction of N2 as the difference
        // between 1 and the sum of mass fractions of other species
        mass_fraction_N2 = 1.0 - mass_fraction_CO - mass_fraction_O2 -mass_fraction_H2 - mass_fraction_CO2 - mass_fraction_C3H6 - mass_fraction_NO - mass_fraction_NO2 - mass_fraction_H2O;                          
    }
 
    else if (t >= 40.0 && t < 60.0) {
        mass_fraction_CO = 2.9124e-4; // Constant CO mass fraction from 40 to 60 seconds
mass_fraction_O2 = 6.6568e-2; // Constant O2 mass fraction from 40 to 60 seconds
mass_fraction_H2 = 6.9342e-6; // Constant H2 mass fraction from 40 to 60 seconds
mass_fraction_C3H6 = 5.0966e-4; // Constant C3H6 mass fraction from 40 to 60 seconds
        mass_fraction_NO = 1.5602e-4; // Constant NO mass fraction from 40 to 60 seconds
mass_fraction_CO2 = 1.5255e-1; // Constant CO2 mass fraction from 40 to 60 seconds
mass_fraction_NO2 = 0.0; // Constant NO2 mass fraction from 40 to 60 seconds
mass_fraction_H2O = 6.2408e-2; // Constant H2O mass fraction from 40 to 60 seconds
 
// Calculate the mass fraction of N2 as the difference
        // between 1 and the sum of mass fractions of other species
        mass_fraction_N2 = 1.0 - mass_fraction_CO - mass_fraction_O2 -mass_fraction_H2 - mass_fraction_CO2 - mass_fraction_C3H6 - mass_fraction_NO - mass_fraction_NO2 - mass_fraction_H2O;                          
    }
 
    else if (t >= 60.0 && t < 80.0) {
        mass_fraction_CO = 9.7073e-5; // Constant CO mass fraction at 9.7073e-5 from 60 to 80 seconds
mass_fraction_O2 = 6.6564e-2; // Constant O2 mass fraction at 6.6564e-2 from 60 to 80 seconds
mass_fraction_H2 = 2.2881e-6; // Constant H2 mass fraction at 2.2881e-6 from 60 to 80 seconds
mass_fraction_C3H6 = 5.0963e-4; // Constant C3H6 mass fraction at 5.0963e-4 from 60 to 80 seconds
        mass_fraction_NO = 1.5601e-4; // Constant NO mass fraction at 1.5601e-4 from 60 to 80 seconds
mass_fraction_CO2 = 1.5254e-1; // Constant CO2 mass fraction at 1.5254e-1 from 60 to 80 seconds
mass_fraction_NO2 = 0.0; // Constant NO2 mass fraction at 0.0 from 40 to 60 seconds
mass_fraction_H2O = 6.2404e-2; // Constant H2O mass fraction at 6.2404e-2 from 60 to 80 seconds
 
// Calculate the mass fraction of N2 as the difference
        // between 1 and the sum of mass fractions of other species
        mass_fraction_N2 = 1.0 - mass_fraction_CO - mass_fraction_O2 -mass_fraction_H2 - mass_fraction_CO2 - mass_fraction_C3H6 - mass_fraction_NO - mass_fraction_NO2 - mass_fraction_H2O;                          
    }
 
    else if (t >= 80.0 && t < 90.0){
        mass_fraction_CO = 4.8542E-05; // Constant CO mass fraction at 4.8542E-05 from 80 to 90 seconds
mass_fraction_O2 = 6.6571e-2; // Constant O2 mass fraction at 6.6571e-2 from 80 to 90 seconds
mass_fraction_H2 = 1.442e-6; // Constant H2 mass fraction at1.442e-6 from 80 to 90 seconds
mass_fraction_C3H6 = 1.4563e-4; // Constant C3H6 mass fraction at 1.4563e-4 from 80 to 90 seconds
        mass_fraction_NO = 1.0402e-4; // Constant NO mass fraction at 1.0402e-4 from 80 to 90 seconds
mass_fraction_CO2 = 1.5256e-1; // Constant CO2 mass fraction at 1.5256e-1 from 80 to 90 seconds
mass_fraction_NO2 = 0.0; // Constant NO2 mass fraction at 0.0 from 80 to 90 seconds
mass_fraction_H2O = 6.2411e-2; // Constant H2O mass fraction at 6.2411e-2 from 80 to 90 seconds
 
// Calculate the mass fraction of N2 as the difference
        // between 1 and the sum of mass fractions of other species
        mass_fraction_N2 = 1.0 - mass_fraction_CO - mass_fraction_O2 -mass_fraction_H2 - mass_fraction_CO2 - mass_fraction_C3H6 - mass_fraction_NO - mass_fraction_NO2 - mass_fraction_H2O;                          
    }
 
    // Set the mass fractions at the current position
face_t f;
begin_f_loop(f, thread)
{
    // Set mass fractions for each species
    F_PROFILE(f, thread, position) = mass_fraction_CO; // Set CO mass fraction
    F_PROFILE(f, thread, position+1) = mass_fraction_O2; // Set O2 mass fraction
    F_PROFILE(f, thread, position+2) = mass_fraction_CO2; // Set CO2 mass fraction
F_PROFILE(f, thread, position+3) = mass_fraction_C3H6; // Set C3H6 mass fraction
F_PROFILE(f, thread, position+4) = mass_fraction_NO; // Set NO mass fraction
F_PROFILE(f, thread, position+5) = mass_fraction_H2O; // Set H2O mass fraction
F_PROFILE(f, thread, position+6) = mass_fraction_NO2; // Set NO2 mass fraction
F_PROFILE(f, thread, position+7) = mass_fraction_H2; // Set H2 mass fraction
F_PROFILE(f, thread, position+7) = mass_fraction_N2; // Set N2 mass fraction
}
end_f_loop(f, thread)
    }
 
Thank you
Pratheeba
 
#ReactiveSimulation   #Species   #UDF