Changeset 13952


Ignore:
Timestamp:
Nov 5, 2019 10:29:51 AM (9 days ago)
Author:
Christian Andersson
Message:

Updated runtime to handle domain checks. Related to ticket:5868

Location:
branches/dev-cw-2658
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-cw-2658/Python/src/tests_jmodelica/files/Modelica/OperatorTests.mo

    r9348 r13952  
    11package OperatorTests "Some tests for operators"
     2
     3model DomainChecks
     4    Real x1 = abs(time);
     5    Real x2 = cos(time);
     6    Real x3 = sin(time);
     7    Real x4 = tan(time);
     8    Real x5 = acos(time);
     9    Real x6 = asin(time);
     10    Real x7 = atan(time);
     11    Real x8 = log(time);
     12    Real x9 = log10(time);
     13    Real x10= exp(time);
     14    Real x11= time^10;
     15    Real x12= sqrt(time);
     16    Real x13= sinh(time);
     17    Real x14= cosh(time);
     18    Real x15= tanh(time);
     19    Real x16= atan2(time, 2*time);
     20    Real x17= time / x16;
     21    Real x18= sign(time);
     22    Real x19= max(time, x16);
     23    Real x20= min(time, x16);
     24    Real x21= div(time, 2*time);
     25
     26    function operators
     27        input Real t;
     28        output Real[16] o;
     29    algorithm
     30        o[1] := cos(t);
     31        o[2] := sin(t);
     32        o[3] := acos(t);
     33        o[4] := asin(t);
     34        o[5] := atan(t);
     35        o[6] := log(t);
     36        o[7] := log10(t);
     37        o[8] := exp(t);
     38        o[9] := t^10;
     39        o[10]:= sqrt(time);
     40        o[11]:= cosh(time);
     41        o[12]:= sinh(time);
     42        o[13]:= tanh(time);
     43        o[14]:= atan2(time, 2*time);
     44        o[15]:= t / o[1];
     45        o[16]:= div(time, 2*time);
     46    end operators;
     47   
     48    Real o[16] = operators(time);
     49end DomainChecks;
    250
    351model HomotopyTest
  • branches/dev-cw-2658/Python/src/tests_jmodelica/general/test_operators.py

    r11351 r13952  
    2222from pymodelica.compiler_exceptions import CompilerError
    2323
     24class TestDomainChecks(SimulationTest):
     25    @testattr(stddist_full = True)
     26    def test_domain_checks1(self):
     27        #Test that the compilation is succesful
     28        SimulationTest.setup_class_base('OperatorTests.mo',
     29            'OperatorTests.DomainChecks', options={"mathematical_domain_checks":True})
     30
     31    @testattr(stddist_full = True)
     32    def test_domain_checks2(self):
     33        #Test that the compilation is succesful
     34        SimulationTest.setup_class_base('OperatorTests.mo',
     35            'OperatorTests.DomainChecks', options={"mathematical_domain_checks":False})
     36
    2437class TestHomotopy(SimulationTest):
    2538    """
  • branches/dev-cw-2658/RuntimeLibrary/src/jmi/jmi_math.h

    r10859 r13952  
    4444void jmi_log_func_or_eq(jmi_t *jmi, const char cathegory_name[], const char func_name[], const char msg[], const char val[]);
    4545
     46/* Macros used together with the domain check option */
     47#define JMI_DIVIDE_FUNCTION(name, num, den, msg) ((jmi_real_t)(num)/(jmi_real_t)(den))
     48#define JMI_DIVIDE_EQUATION(jmi, num, den, msg)  ((jmi_real_t)(num)/(jmi_real_t)(den))
     49#define JMI_EXP_EQUATION(jmi, x, msg)            (exp((jmi_real_t)(x)))
     50#define JMI_EXP_FUNCTION(name, x, msg)           (exp((jmi_real_t)(x)))
     51#define JMI_TAN_EQUATION(jmi, x, msg)            (tan((jmi_real_t)(x)))
     52#define JMI_TAN_FUNCTION(name, x, msg)           (tan((jmi_real_t)(x)))
     53#define JMI_ATAN_EQUATION(jmi, x, msg)           (atan((jmi_real_t)(x)))
     54#define JMI_ATAN_FUNCTION(name, x, msg)          (atan((jmi_real_t)(x)))
     55#define JMI_TANH_EQUATION(jmi, x, msg)           (tanh((jmi_real_t)(x)))
     56#define JMI_TANH_FUNCTION(name, x, msg)          (tanh((jmi_real_t)(x)))
     57#define JMI_COS_EQUATION(jmi, x, msg)            (cos((jmi_real_t)(x)))
     58#define JMI_COS_FUNCTION(name, x, msg)           (cos((jmi_real_t)(x)))
     59#define JMI_ACOS_EQUATION(jmi, x, msg)           (acos((jmi_real_t)(x)))
     60#define JMI_ACOS_FUNCTION(name, x, msg)          (acos((jmi_real_t)(x)))
     61#define JMI_COSH_EQUATION(jmi, x, msg)           (cosh((jmi_real_t)(x)))
     62#define JMI_COSH_FUNCTION(name, x, msg)          (cosh((jmi_real_t)(x)))
     63#define JMI_SIN_EQUATION(jmi, x, msg)            (sin((jmi_real_t)(x)))
     64#define JMI_SIN_FUNCTION(name, x, msg)           (sin((jmi_real_t)(x)))
     65#define JMI_ASIN_EQUATION(jmi, x, msg)           (asin((jmi_real_t)(x)))
     66#define JMI_ASIN_FUNCTION(name, x, msg)          (asin((jmi_real_t)(x)))
     67#define JMI_SINH_EQUATION(jmi, x, msg)           (sinh((jmi_real_t)(x)))
     68#define JMI_SINH_FUNCTION(name, x, msg)          (sinh((jmi_real_t)(x)))
     69#define JMI_SQRT_EQUATION(jmi, x, msg)           (sqrt((jmi_real_t)(x)))
     70#define JMI_SQRT_FUNCTION(name, x, msg)          (sqrt((jmi_real_t)(x)))
     71#define JMI_LOG_EQUATION(jmi, x, msg)            (log((jmi_real_t)(x)))
     72#define JMI_LOG_FUNCTION(name, x, msg)           (log((jmi_real_t)(x)))
     73#define JMI_LOG10_EQUATION(jmi, x, msg)          (log10((jmi_real_t)(x)))
     74#define JMI_LOG10_FUNCTION(name, x, msg)         (log10((jmi_real_t)(x)))
     75#define JMI_ATAN2_EQUATION(jmi, x, y, msg)       (atan2((jmi_real_t)(x), (jmi_real_t)(y)))
     76#define JMI_ATAN2_FUNCTION(name, x, y, msg)      (atan2((jmi_real_t)(x), (jmi_real_t)(y)))
     77#define JMI_POW_EQUATION(jmi, x, y, msg)         (pow((jmi_real_t)(x), (jmi_real_t)(y)))
     78#define JMI_POW_FUNCTION(name, x, y, msg)        (pow((jmi_real_t)(x), (jmi_real_t)(y)))
     79
     80jmi_real_t jmi_pow(jmi_t *jmi, const char func_name[], jmi_real_t x, jmi_real_t y, const char msg[]);
     81
    4682/**
    4783 * Function for checking if a vector contains NAN values. Returns the
Note: See TracChangeset for help on using the changeset viewer.