Changeset 13791
 Timestamp:
 Oct 21, 2019 4:44:36 PM (3 weeks ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/dev5819/Python/src/tests_jmodelica/simulation/test_assimulo_interface_fmi.py
r13600 r13791 99 99 #Assert that sparse handling has no impact on the number of steps 100 100 assert res1.solver.statistics["nsteps"] == res2.solver.statistics["nsteps"] 101 nose.tools.assert_almost_equal(res1.final("J1.w"), res2.final("J1.w"), 3)101 N.testing.assert_almost_equal(res1.final("J1.w"), res2.final("J1.w"), 3) 102 102 103 103 @testattr(stddist_base = True) … … 329 329 model = load_fmu("TimeEvents_TestSampling9.fmu") 330 330 model.initialize() 331 res = model.simulate(0,1, options={"initialize":False}) ;331 res = model.simulate(0,1, options={"initialize":False}) 332 332 assert res.solver.statistics["ntimeevents"] == 10 333 333 … … 338 338 opts["solver"] = "CVode" 339 339 opts["CVode_options"]["rtol"] = 1e4 340 res = model.simulate(0,1, options=opts) ;341 nose.tools.assert_almost_equal(model.get("s"), 2.8)340 res = model.simulate(0,1, options=opts) 341 N.testing.assert_almost_equal(model.get("s"), 2.8) 342 342 assert res.solver.statistics["ntimeevents"] == 2 343 343 … … 592 592 opts["CVode_options"]["rtol"] = 1e4 593 593 res = model.simulate(0,1, options=opts); 594 nose.tools.assert_almost_equal(model.get("s"), 2.8)594 N.testing.assert_almost_equal(model.get("s"), 2.8) 595 595 assert res.solver.statistics["ntimeevents"] == 2 596 596 … … 616 616 var = res["freeMotionScalarInit.angle_2"] 617 617 618 nose.tools.assert_almost_equal(abs(max(var)), 0.00, 2)619 nose.tools.assert_almost_equal(abs(min(var)), 2.54, 2)618 N.testing.assert_almost_equal(abs(max(var)), 0.00, 2) 619 N.testing.assert_almost_equal(abs(min(var)), 2.54, 2) 620 620 621 621 class Test_Events: … … 644 644 res = model.simulate() 645 645 646 nose.tools.assert_almost_equal(res.final("s"), 1.0)646 N.testing.assert_almost_equal(res.final("s"), 1.0) 647 647 648 648 @testattr(stddist_full = True) … … 668 668 model.initialize() 669 669 670 nose.tools.assert_almost_equal(model.get("mode"), 0.0)671 nose.tools.assert_almost_equal(model.get("sa"), 0.0)670 N.testing.assert_almost_equal(model.get("mode"), 0.0) 671 N.testing.assert_almost_equal(model.get("sa"), 0.0) 672 672 673 673 @testattr(stddist_base = True) … … 676 676 res = model.simulate() 677 677 678 nose.tools.assert_almost_equal(res["x[1]"][1], 0)679 nose.tools.assert_almost_equal(res["x[2]"][1], 0)680 nose.tools.assert_almost_equal(res["x[3]"][1], 0)681 nose.tools.assert_almost_equal(res["x[4]"][1], 0.406)682 nose.tools.assert_almost_equal(res["x[5]"][1], 0.406)683 nose.tools.assert_almost_equal(res["x[6]"][1], 0.406)684 nose.tools.assert_almost_equal(res["x[7]"][1], 0.94)678 N.testing.assert_almost_equal(res["x[1]"][1], 0) 679 N.testing.assert_almost_equal(res["x[2]"][1], 0) 680 N.testing.assert_almost_equal(res["x[3]"][1], 0) 681 N.testing.assert_almost_equal(res["x[4]"][1], 0.406) 682 N.testing.assert_almost_equal(res["x[5]"][1], 0.406) 683 N.testing.assert_almost_equal(res["x[6]"][1], 0.406) 684 N.testing.assert_almost_equal(res["x[7]"][1], 0.94) 685 685 686 686 @testattr(stddist_base = True) … … 689 689 res = model.simulate(final_time=2.0) 690 690 691 nose.tools.assert_almost_equal(res["y"][0], 1.0)692 nose.tools.assert_almost_equal(res["w"][0], 0.0)693 nose.tools.assert_almost_equal(res["x"][1], 2.0)694 nose.tools.assert_almost_equal(res["y"][1],1.58385,4)695 nose.tools.assert_almost_equal(res["z"][1], 0.0)696 nose.tools.assert_almost_equal(res["w"][1], 1.0)691 N.testing.assert_almost_equal(res["y"][0], 1.0) 692 N.testing.assert_almost_equal(res["w"][0], 0.0) 693 N.testing.assert_almost_equal(res["x"][1], 2.0) 694 N.testing.assert_almost_equal(res["y"][1],1.58385,4) 695 N.testing.assert_almost_equal(res["z"][1], 0.0) 696 N.testing.assert_almost_equal(res["w"][1], 1.0) 697 697 698 698 @testattr(stddist_base = True) … … 701 701 model.initialize(tolerance=1e1) 702 702 703 nose.tools.assert_almost_equal(model.get("x"), 1e6)703 N.testing.assert_almost_equal(model.get("x"), 1e6) 704 704 705 705 @testattr(stddist_full = True) … … 707 707 model = load_fmu("EventIter_InitialPhasing1.fmu") 708 708 res = model.simulate(final_time=0.1) 709 nose.tools.assert_almost_equal(res["b1"][0], 0.0)710 nose.tools.assert_almost_equal(res["b2"][0], 1.0)709 N.testing.assert_almost_equal(res["b1"][0], 0.0) 710 N.testing.assert_almost_equal(res["b2"][0], 1.0) 711 711 712 712 @testattr(stddist_base=True) … … 714 714 model = load_fmu("EventIter_EventIterDiscreteReals.fmu") 715 715 res = model.simulate(final_time=1.0) 716 nose.tools.assert_almost_equal(res["T1"][0], 0.0)717 nose.tools.assert_almost_equal(res["start"][0], 1.0)718 nose.tools.assert_almost_equal(res["T2"][0], 0.0)716 N.testing.assert_almost_equal(res["T1"][0], 0.0) 717 N.testing.assert_almost_equal(res["start"][0], 1.0) 718 N.testing.assert_almost_equal(res["T2"][0], 0.0) 719 719 720 720 class Test_Relations: … … 741 741 res = model.simulate(final_time=3.5, input=input_object,options=opts) 742 742 743 nose.tools.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)744 nose.tools.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)743 N.testing.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2) 744 N.testing.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2) 745 745 nose.tools.assert_not_almost_equal(N.interp(0.25,res["time"],res["y"]),0.5,places=2) 746 746 nose.tools.assert_not_almost_equal(N.interp(2.75,res["time"],res["y"]),0.5,places=2) 747 747 nose.tools.assert_not_almost_equal(N.interp(0.75,res["time"],res["x"]),0.5,places=2) 748 748 nose.tools.assert_not_almost_equal(N.interp(2.25,res["time"],res["x"]),0.5,places=2) 749 nose.tools.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)749 N.testing.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2) 750 750 751 751 @testattr(stddist_full = True) … … 756 756 res = model.simulate(final_time=3.5, input=input_object,options=opts) 757 757 758 nose.tools.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)759 nose.tools.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)758 N.testing.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2) 759 N.testing.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2) 760 760 nose.tools.assert_not_almost_equal(N.interp(0.25,res["time"],res["y"]),0.5,places=2) 761 761 nose.tools.assert_not_almost_equal(N.interp(2.75,res["time"],res["y"]),0.5,places=2) 762 762 nose.tools.assert_not_almost_equal(N.interp(0.75,res["time"],res["x"]),0.5,places=2) 763 763 nose.tools.assert_not_almost_equal(N.interp(2.25,res["time"],res["x"]),0.5,places=2) 764 nose.tools.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)764 N.testing.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2) 765 765 766 766 @testattr(stddist_full = True) … … 771 771 res = model.simulate(final_time=3.5, input=input_object,options=opts) 772 772 773 nose.tools.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)774 nose.tools.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)773 N.testing.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2) 774 N.testing.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2) 775 775 nose.tools.assert_not_almost_equal(N.interp(0.25,res["time"],res["y"]),0.5,places=2) 776 776 nose.tools.assert_not_almost_equal(N.interp(2.75,res["time"],res["y"]),0.5,places=2) 777 777 nose.tools.assert_not_almost_equal(N.interp(0.75,res["time"],res["x"]),0.5,places=2) 778 778 nose.tools.assert_not_almost_equal(N.interp(2.25,res["time"],res["x"]),0.5,places=2) 779 nose.tools.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)779 N.testing.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2) 780 780 781 781 @testattr(stddist_full = True) … … 786 786 res = model.simulate(final_time=3.5, input=input_object,options=opts) 787 787 788 nose.tools.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)789 nose.tools.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)788 N.testing.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2) 789 N.testing.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2) 790 790 nose.tools.assert_not_almost_equal(N.interp(0.25,res["time"],res["y"]),0.5,places=2) 791 791 nose.tools.assert_not_almost_equal(N.interp(2.75,res["time"],res["y"]),0.5,places=2) 792 792 nose.tools.assert_not_almost_equal(N.interp(0.75,res["time"],res["x"]),0.5,places=2) 793 793 nose.tools.assert_not_almost_equal(N.interp(2.25,res["time"],res["x"]),0.5,places=2) 794 nose.tools.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)794 N.testing.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2) 795 795 796 796 @testattr(stddist_full = True) … … 800 800 res = model.simulate(final_time=0.1) 801 801 802 nose.tools.assert_almost_equal(res.initial("x"),1.0,places=3)803 nose.tools.assert_almost_equal(res.initial("y"),0.0,places=3)802 N.testing.assert_almost_equal(res.initial("x"),1.0,places=3) 803 N.testing.assert_almost_equal(res.initial("y"),0.0,places=3) 804 804 805 805 @testattr(stddist_full = True) … … 809 809 res = model.simulate(final_time=0.1) 810 810 811 nose.tools.assert_almost_equal(res.initial("x"),0.0,places=3)812 nose.tools.assert_almost_equal(res.initial("y"),1.0,places=3)811 N.testing.assert_almost_equal(res.initial("x"),0.0,places=3) 812 N.testing.assert_almost_equal(res.initial("y"),1.0,places=3) 813 813 814 814 @testattr(stddist_full = True) … … 818 818 res = model.simulate(final_time=10) 819 819 820 nose.tools.assert_almost_equal(N.interp(3.00,res["time"],res["der(v1)"]),1.0,places=3)821 nose.tools.assert_almost_equal(N.interp(3.40,res["time"],res["der(v1)"]),0.0,places=3)822 nose.tools.assert_almost_equal(N.interp(8.00,res["time"],res["der(v1)"]),0.0,places=3)823 nose.tools.assert_almost_equal(N.interp(8.25,res["time"],res["der(v1)"]),1.0,places=3)824 nose.tools.assert_almost_equal(N.interp(4.00,res["time"],res["der(v2)"]),1.0,places=3)825 nose.tools.assert_almost_equal(N.interp(4.20,res["time"],res["der(v2)"]),0.0,places=3)826 nose.tools.assert_almost_equal(N.interp(7.00,res["time"],res["der(v2)"]),0.0,places=3)827 nose.tools.assert_almost_equal(N.interp(7.20,res["time"],res["der(v2)"]),1.0,places=3)820 N.testing.assert_almost_equal(N.interp(3.00,res["time"],res["der(v1)"]),1.0,places=3) 821 N.testing.assert_almost_equal(N.interp(3.40,res["time"],res["der(v1)"]),0.0,places=3) 822 N.testing.assert_almost_equal(N.interp(8.00,res["time"],res["der(v1)"]),0.0,places=3) 823 N.testing.assert_almost_equal(N.interp(8.25,res["time"],res["der(v1)"]),1.0,places=3) 824 N.testing.assert_almost_equal(N.interp(4.00,res["time"],res["der(v2)"]),1.0,places=3) 825 N.testing.assert_almost_equal(N.interp(4.20,res["time"],res["der(v2)"]),0.0,places=3) 826 N.testing.assert_almost_equal(N.interp(7.00,res["time"],res["der(v2)"]),0.0,places=3) 827 N.testing.assert_almost_equal(N.interp(7.20,res["time"],res["der(v2)"]),1.0,places=3) 828 828 829 829 class Test_NonLinear_Systems: … … 908 908 909 909 for i,iv in enumerate(ivs): 910 nose.tools.assert_almost_equal(fprime(iv) ,df[i], places=12)910 N.testing.assert_almost_equal(fprime(iv) ,df[i], places=12) 911 911 912 912 @testattr(stddist_base = True) … … 922 922 sol_neg =N.sqrt(1e7)+1.5 923 923 924 nose.tools.assert_almost_equal(run_model(sol_pos+1e16) ,sol_pos)925 nose.tools.assert_almost_equal(run_model(sol_pos1e16) ,sol_pos)926 nose.tools.assert_almost_equal(run_model(sol_pos+1e14) ,sol_pos)927 nose.tools.assert_almost_equal(run_model(sol_pos1e14) ,sol_pos)928 929 nose.tools.assert_almost_equal(run_model(sol_neg+1e16) ,sol_neg)930 nose.tools.assert_almost_equal(run_model(sol_neg1e16) ,sol_neg)931 nose.tools.assert_almost_equal(run_model(sol_neg+1e14) ,sol_neg)932 nose.tools.assert_almost_equal(run_model(sol_neg1e14) ,sol_neg)924 N.testing.assert_almost_equal(run_model(sol_pos+1e16) ,sol_pos) 925 N.testing.assert_almost_equal(run_model(sol_pos1e16) ,sol_pos) 926 N.testing.assert_almost_equal(run_model(sol_pos+1e14) ,sol_pos) 927 N.testing.assert_almost_equal(run_model(sol_pos1e14) ,sol_pos) 928 929 N.testing.assert_almost_equal(run_model(sol_neg+1e16) ,sol_neg) 930 N.testing.assert_almost_equal(run_model(sol_neg1e16) ,sol_neg) 931 N.testing.assert_almost_equal(run_model(sol_neg+1e14) ,sol_neg) 932 N.testing.assert_almost_equal(run_model(sol_neg1e14) ,sol_neg) 933 933 934 934 @testattr(stddist_base = True) … … 940 940 model.initialize() 941 941 942 nose.tools.assert_almost_equal(model.get("i"),9.9760004108556469E03)942 N.testing.assert_almost_equal(model.get("i"),9.9760004108556469E03) 943 943 944 944 @testattr(stddist_base = True) … … 951 951 model.set("i_start",i) 952 952 model.initialize() 953 nose.tools.assert_almost_equal(model.get("i"),i)953 N.testing.assert_almost_equal(model.get("i"),i) 954 954 955 955 model.reset() … … 957 957 model.set("i_start", i+i*1e15) 958 958 model.initialize() 959 nose.tools.assert_almost_equal(model.get("i"),i)959 N.testing.assert_almost_equal(model.get("i"),i) 960 960 961 961 model.reset() … … 963 963 model.set("i_start", ii*1e15) 964 964 model.initialize() 965 nose.tools.assert_almost_equal(model.get("i"),i)965 N.testing.assert_almost_equal(model.get("i"),i) 966 966 967 967 … … 1007 1007 model.initialize() 1008 1008 1009 nose.tools.assert_almost_equal(model.get("x") ,2.76929235)1009 N.testing.assert_almost_equal(model.get("x") ,2.76929235) 1010 1010 1011 1011 @testattr(stddist_base = True) … … 1015 1015 model.initialize() 1016 1016 1017 nose.tools.assert_almost_equal(model.get("x"), 0.680716920494911)1018 nose.tools.assert_almost_equal(model.get("y"), 0.0)1017 N.testing.assert_almost_equal(model.get("x"), 0.680716920494911) 1018 N.testing.assert_almost_equal(model.get("y"), 0.0) 1019 1019 1020 1020 @testattr(stddist_base = True) … … 1023 1023 model.set("_use_Brent_in_1d", False) 1024 1024 model.initialize() 1025 nose.tools.assert_almost_equal(model.get('state_a_p'), 17.78200351)1025 N.testing.assert_almost_equal(model.get('state_a_p'), 17.78200351) 1026 1026 1027 1027 @testattr(stddist_base = True) … … 1034 1034 model = load_fmu("NonLinear_EventIteration1.fmu") 1035 1035 model.initialize() 1036 nose.tools.assert_almost_equal(model.get('iter_var_1'), 872.98062403)1036 N.testing.assert_almost_equal(model.get('iter_var_1'), 872.98062403) 1037 1037 1038 1038 @testattr(stddist_base = True) … … 1040 1040 model = load_fmu("NonLinear_NonLinear6.fmu") 1041 1041 model.initialize() 1042 nose.tools.assert_almost_equal(model.get('x'), 1.0)1043 nose.tools.assert_almost_equal(model.get('z'), 1.0)1042 N.testing.assert_almost_equal(model.get('x'), 1.0) 1043 N.testing.assert_almost_equal(model.get('z'), 1.0) 1044 1044 1045 1045 @testattr(stddist_base = True) … … 1047 1047 model = load_fmu("NonLinear_NonLinear7.fmu") 1048 1048 model.initialize() 1049 nose.tools.assert_almost_equal(model.get('x'), 1.0)1050 nose.tools.assert_almost_equal(model.get('z'), 1.0)1049 N.testing.assert_almost_equal(model.get('x'), 1.0) 1050 N.testing.assert_almost_equal(model.get('z'), 1.0) 1051 1051 1052 1052 class Test_Singular_Systems: … … 1077 1077 1078 1078 res = model.simulate(final_time=2) 1079 nose.tools.assert_almost_equal(res.final('y') ,1.000000000)1079 N.testing.assert_almost_equal(res.final('y') ,1.000000000) 1080 1080 1081 1081 @testattr(stddist_base = True) … … 1085 1085 1086 1086 res = model.simulate(final_time=4) 1087 nose.tools.assert_almost_equal(res.final('y') ,1.000000000)1088 nose.tools.assert_almost_equal(res.final('w') ,2.000000000)1087 N.testing.assert_almost_equal(res.final('y') ,1.000000000) 1088 N.testing.assert_almost_equal(res.final('w') ,2.000000000) 1089 1089 1090 1090 @testattr(stddist_base = True) … … 1100 1100 x = res["x"] 1101 1101 for i in range(4): 1102 nose.tools.assert_almost_equal(x[i] ,0.000000000)1102 N.testing.assert_almost_equal(x[i] ,0.000000000) 1103 1103 for i in range(4,8): 1104 nose.tools.assert_almost_equal(x[i] ,0.0100000)1104 N.testing.assert_almost_equal(x[i] ,0.0100000) 1105 1105 1106 1106 @testattr(stddist_base = True) … … 1141 1141 model.initialize() 1142 1142 1143 nose.tools.assert_almost_equal(model.get("x") ,1.000000000)1144 nose.tools.assert_almost_equal(model.get("y") ,2.000000000)1145 nose.tools.assert_almost_equal(model.get("z") ,0.000000000)1143 N.testing.assert_almost_equal(model.get("x") ,1.000000000) 1144 N.testing.assert_almost_equal(model.get("y") ,2.000000000) 1145 N.testing.assert_almost_equal(model.get("z") ,0.000000000) 1146 1146 1147 1147 @testattr(stddist_base = True) … … 1164 1164 model.initialize() 1165 1165 1166 nose.tools.assert_almost_equal(model.get("x") ,1.000000000)1167 nose.tools.assert_almost_equal(model.get("y") ,200000.0000)1168 nose.tools.assert_almost_equal(model.get("z") ,0.000000000)1166 N.testing.assert_almost_equal(model.get("x") ,1.000000000) 1167 N.testing.assert_almost_equal(model.get("y") ,200000.0000) 1168 N.testing.assert_almost_equal(model.get("z") ,0.000000000) 1169 1169 1170 1170 @testattr(stddist_base = True) … … 1178 1178 model.initialize() 1179 1179 1180 nose.tools.assert_almost_equal(model.get("x") ,1.000000000)1181 nose.tools.assert_almost_equal(model.get("y") ,2e10)1182 nose.tools.assert_almost_equal(model.get("z") ,0.000000000)1180 N.testing.assert_almost_equal(model.get("x") ,1.000000000) 1181 N.testing.assert_almost_equal(model.get("y") ,2e10) 1182 N.testing.assert_almost_equal(model.get("z") ,0.000000000) 1183 1183 1184 1184 @testattr(stddist_base = True) … … 1189 1189 model.initialize() 1190 1190 1191 nose.tools.assert_almost_equal(model.get("x") ,5)1192 nose.tools.assert_almost_equal(model.get("y") ,0)1193 nose.tools.assert_almost_equal(model.get("z") ,0.000000000)1191 N.testing.assert_almost_equal(model.get("x") ,5) 1192 N.testing.assert_almost_equal(model.get("y") ,0) 1193 N.testing.assert_almost_equal(model.get("z") ,0.000000000) 1194 1194 1195 1195 @testattr(stddist_base = True) … … 1203 1203 res = model.simulate() 1204 1204 1205 nose.tools.assert_almost_equal(res["z"][0] ,0.000000000)1206 nose.tools.assert_almost_equal(res["z"][1] ,1.000000000)1205 N.testing.assert_almost_equal(res["z"][0] ,0.000000000) 1206 N.testing.assert_almost_equal(res["z"][1] ,1.000000000) 1207 1207 1208 1208 @testattr(stddist_base = True) … … 1217 1217 model = load_fmu("Singular_ZeroColumnJacobian.fmu"); 1218 1218 res = model.simulate(); 1219 nose.tools.assert_almost_equal(res["x"][0], 1)1219 N.testing.assert_almost_equal(res["x"][0], 1) 1220 1220 1221 1221 @testattr(stddist_base = True) … … 1223 1223 model = load_fmu("Singular_ZeroColumnJacobian2.fmu"); 1224 1224 res = model.simulate(); 1225 nose.tools.assert_almost_equal(res["x"][0], 1)1225 N.testing.assert_almost_equal(res["x"][0], 1) 1226 1226 1227 1227 class Test_FMI_ODE_CS_2: … … 1252 1252 input = ('onSwitch', step) 1253 1253 res = model.simulate(final_time=0.8, options=opts, input=input) 1254 nose.tools.assert_almost_equal(res.final("T"), 11.22494, 2)1254 N.testing.assert_almost_equal(res.final("T"), 11.22494, 2) 1255 1255 1256 1256 @testattr(stddist_base = True) … … 1268 1268 input = ('onSwitch', step) 1269 1269 res = model.simulate(final_time=0.8, options=opts, input=input) 1270 nose.tools.assert_almost_equal(res.final("T"), 20.67587, 2)1270 N.testing.assert_almost_equal(res.final("T"), 20.67587, 2) 1271 1271 1272 1272 @testattr(stddist_full = True) … … 1296 1296 res = model.simulate(final_time=1,options=opts) 1297 1297 1298 nose.tools.assert_almost_equal(res.final("x"), 3.89, 2)1298 N.testing.assert_almost_equal(res.final("x"), 3.89, 2) 1299 1299 1300 1300 class Test_FMI_ODE_CS: … … 1337 1337 res = model.simulate(final_time=1,options=opts) 1338 1338 1339 nose.tools.assert_almost_equal(res.final("x"), 3.89, 2)1339 N.testing.assert_almost_equal(res.final("x"), 3.89, 2) 1340 1340 1341 1341 @testattr(stddist_full = True) … … 1380 1380 res = model.simulate(input=input_object) 1381 1381 1382 nose.tools.assert_almost_equal(res.final('onSwitch') ,1.000000000)1382 N.testing.assert_almost_equal(res.final('onSwitch') ,1.000000000) 1383 1383 1384 1384 model.reset() … … 1397 1397 res = model.simulate(input=input_object) 1398 1398 1399 nose.tools.assert_almost_equal(res.final('y') ,1.000000000)1400 nose.tools.assert_almost_equal(res.final('u') ,1.000000000)1399 N.testing.assert_almost_equal(res.final('y') ,1.000000000) 1400 N.testing.assert_almost_equal(res.final('u') ,1.000000000) 1401 1401 1402 1402 model.reset() … … 1406 1406 res = model.simulate(input=input_object) 1407 1407 1408 nose.tools.assert_almost_equal(res.final('y') ,1.000000000)1409 nose.tools.assert_almost_equal(res.final('u') ,1.000000000)1408 N.testing.assert_almost_equal(res.final('y') ,1.000000000) 1409 N.testing.assert_almost_equal(res.final('u') ,1.000000000) 1410 1410 1411 1411 @testattr(stddist_full = True) … … 1487 1487 res = model.simulate(final_time=10) 1488 1488 1489 nose.tools.assert_almost_equal(res.initial('x') ,1.000000000)1490 nose.tools.assert_almost_equal(res.final('x'),2.000000000)1491 nose.tools.assert_almost_equal(res.initial('y') ,1.000000000)1492 nose.tools.assert_almost_equal(res.final('y'),1.000000000)1493 nose.tools.assert_almost_equal(res.initial('z') ,1.000000000)1494 nose.tools.assert_almost_equal(res.final('z'),4.000000000)1489 N.testing.assert_almost_equal(res.initial('x') ,1.000000000) 1490 N.testing.assert_almost_equal(res.final('x'),2.000000000) 1491 N.testing.assert_almost_equal(res.initial('y') ,1.000000000) 1492 N.testing.assert_almost_equal(res.final('y'),1.000000000) 1493 N.testing.assert_almost_equal(res.initial('z') ,1.000000000) 1494 N.testing.assert_almost_equal(res.final('z'),4.000000000) 1495 1495 1496 1496 @testattr(stddist_full = True) … … 1503 1503 res = model.simulate(final_time=10) 1504 1504 1505 nose.tools.assert_almost_equal(res.initial('x') ,1.000000000)1506 nose.tools.assert_almost_equal(res.final('x'),1.000000000)1505 N.testing.assert_almost_equal(res.initial('x') ,1.000000000) 1506 N.testing.assert_almost_equal(res.final('x'),1.000000000) 1507 1507 1508 1508 @testattr(stddist_full = True) … … 1515 1515 res = model.simulate(final_time=10, options={"solver": "Radau5ODE"}) 1516 1516 1517 nose.tools.assert_almost_equal(res.initial('x') ,1.000000000)1518 nose.tools.assert_almost_equal(res.final('x'),2.000000000)1519 nose.tools.assert_almost_equal(res.initial('y') ,1.000000000)1520 nose.tools.assert_almost_equal(res.final('y'),1.000000000)1521 nose.tools.assert_almost_equal(res.initial('z') ,1.000000000)1522 nose.tools.assert_almost_equal(res.final('z'),4.000000000)1517 N.testing.assert_almost_equal(res.initial('x') ,1.000000000) 1518 N.testing.assert_almost_equal(res.final('x'),2.000000000) 1519 N.testing.assert_almost_equal(res.initial('y') ,1.000000000) 1520 N.testing.assert_almost_equal(res.final('y'),1.000000000) 1521 N.testing.assert_almost_equal(res.initial('z') ,1.000000000) 1522 N.testing.assert_almost_equal(res.final('z'),4.000000000) 1523 1523 1524 1524 class Test_FMI_ODE: … … 1689 1689 res = model.simulate(final_time=10) 1690 1690 1691 nose.tools.assert_almost_equal(res.initial('x') ,1.000000000)1692 nose.tools.assert_almost_equal(res.final('x'),2.000000000)1693 nose.tools.assert_almost_equal(res.initial('y') ,1.000000000)1694 nose.tools.assert_almost_equal(res.final('y'),1.000000000)1695 nose.tools.assert_almost_equal(res.initial('z') ,1.000000000)1696 nose.tools.assert_almost_equal(res.final('z'),4.000000000)1691 N.testing.assert_almost_equal(res.initial('x') ,1.000000000) 1692 N.testing.assert_almost_equal(res.final('x'),2.000000000) 1693 N.testing.assert_almost_equal(res.initial('y') ,1.000000000) 1694 N.testing.assert_almost_equal(res.final('y'),1.000000000) 1695 N.testing.assert_almost_equal(res.initial('z') ,1.000000000) 1696 N.testing.assert_almost_equal(res.final('z'),4.000000000) 1697 1697 1698 1698 @testattr(stddist_full = True) … … 1705 1705 res = model.simulate(final_time=10) 1706 1706 1707 nose.tools.assert_almost_equal(res.initial('x') ,1.000000000)1708 nose.tools.assert_almost_equal(res.final('x'),1.000000000)1707 N.testing.assert_almost_equal(res.initial('x') ,1.000000000) 1708 N.testing.assert_almost_equal(res.final('x'),1.000000000) 1709 1709 1710 1710 @testattr(stddist_full = True) … … 1771 1771 #sol = self._bounceSim._sol_real 1772 1772 1773 # nose.tools.assert_almost_equal(sol[0][0],1.000000000)1774 # nose.tools.assert_almost_equal(sol[0][1],0.000000000)1775 # nose.tools.assert_almost_equal(sol[0][2],0.000000000)1776 # nose.tools.assert_almost_equal(sol[0][3],9.81000000)1773 #N.testing.assert_almost_equal(sol[0][0],1.000000000) 1774 #N.testing.assert_almost_equal(sol[0][1],0.000000000) 1775 #N.testing.assert_almost_equal(sol[0][2],0.000000000) 1776 #N.testing.assert_almost_equal(sol[0][3],9.81000000) 1777 1777 1778 1778 @testattr(stddist_full = True) … … 1786 1786 rhs = self._bounceSim.rhs(t,y) 1787 1787 1788 nose.tools.assert_almost_equal(rhs[0],1.00000000)1789 nose.tools.assert_almost_equal(rhs[1],9.8100000)1788 N.testing.assert_almost_equal(rhs[0],1.00000000) 1789 N.testing.assert_almost_equal(rhs[1],9.8100000) 1790 1790 1791 1791 … … 1800 1800 event = self._bounceSim.g(t,y,None) 1801 1801 1802 nose.tools.assert_almost_equal(event[0],1.00000000)1802 N.testing.assert_almost_equal(event[0],1.00000000) 1803 1803 1804 1804 y = N.array([0.5,1.0]) 1805 1805 event = self._bounceSim.g(t,y,None) 1806 1806 1807 nose.tools.assert_almost_equal(event[0],0.50000000)1807 N.testing.assert_almost_equal(event[0],0.50000000) 1808 1808 1809 1809 … … 1839 1839 self._bounceSim.handle_event(solver, None) 1840 1840 1841 nose.tools.assert_almost_equal(solver.y[0],1.00000000)1842 nose.tools.assert_almost_equal(solver.y[1],0.70000000)1841 N.testing.assert_almost_equal(solver.y[0],1.00000000) 1842 N.testing.assert_almost_equal(solver.y[1],0.70000000) 1843 1843 1844 1844 #Further testing of the handle_event function is needed. … … 1868 1868 res = model.simulate(final_time=10, options=opts) 1869 1869 1870 nose.tools.assert_almost_equal(res.initial('x'), 1.000000, 4)1871 nose.tools.assert_almost_equal(res.initial('y'), 0.000000, 4)1872 nose.tools.assert_almost_equal(res.final('x'), 0.27510283167449501, 4)1873 nose.tools.assert_almost_equal(res.final('y'), 0.96141480746068897, 4)1870 N.testing.assert_almost_equal(res.initial('x'), 1.000000, 4) 1871 N.testing.assert_almost_equal(res.initial('y'), 0.000000, 4) 1872 N.testing.assert_almost_equal(res.final('x'), 0.27510283167449501, 4) 1873 N.testing.assert_almost_equal(res.final('y'), 0.96141480746068897, 4) 1874 1874 1875 1875 @testattr(windows_base = True) … … 1927 1927 solver = res.solver 1928 1928 1929 nose.tools.assert_almost_equal(solver.t, 1.856045, places=3)1929 N.testing.assert_almost_equal(solver.t, 1.856045, places=3) 1930 1930 1931 1931 @testattr(windows_full = True) … … 1939 1939 solver = res.solver 1940 1940 1941 nose.tools.assert_almost_equal(solver.t, 1.856045, places=3)1941 N.testing.assert_almost_equal(solver.t, 1.856045, places=3) 1942 1942 1943 1943 @testattr(noncompliantfmi = True) … … 1974 1974 sim_res = model.simulate(final_time=10) 1975 1975 1976 nose.tools.assert_almost_equal(sim_res.initial('x'), 2.00000, 4)1977 nose.tools.assert_almost_equal(sim_res.final('x'), 10.000000, 4)1978 nose.tools.assert_almost_equal(sim_res.final('y'), 3.0000000, 4)1979 nose.tools.assert_almost_equal(sim_res.final('z'), 2.0000000, 4)1976 N.testing.assert_almost_equal(sim_res.initial('x'), 2.00000, 4) 1977 N.testing.assert_almost_equal(sim_res.final('x'), 10.000000, 4) 1978 N.testing.assert_almost_equal(sim_res.final('y'), 3.0000000, 4) 1979 N.testing.assert_almost_equal(sim_res.final('z'), 2.0000000, 4) 1980 1980 1981 1981 fmu_name = compile_fmu('EventIter.EventStartIter', os.path.join(path_to_mos,'EventIter.mo')) … … 1985 1985 sim_res = model.simulate(final_time=10) 1986 1986 1987 nose.tools.assert_almost_equal(sim_res.initial('x'), 1.00000, 4)1988 nose.tools.assert_almost_equal(sim_res.initial('y'), 1.00000, 4)1989 nose.tools.assert_almost_equal(sim_res.initial('z'), 1.00000, 4)1990 nose.tools.assert_almost_equal(sim_res.final('x'), 2.000000, 4)1991 nose.tools.assert_almost_equal(sim_res.final('y'), 1.0000000, 4)1992 nose.tools.assert_almost_equal(sim_res.final('z'), 4.0000000, 4)1987 N.testing.assert_almost_equal(sim_res.initial('x'), 1.00000, 4) 1988 N.testing.assert_almost_equal(sim_res.initial('y'), 1.00000, 4) 1989 N.testing.assert_almost_equal(sim_res.initial('z'), 1.00000, 4) 1990 N.testing.assert_almost_equal(sim_res.final('x'), 2.000000, 4) 1991 N.testing.assert_almost_equal(sim_res.final('y'), 1.0000000, 4) 1992 N.testing.assert_almost_equal(sim_res.final('z'), 4.0000000, 4) 1993 1993 1994 1994 @testattr(stddist_base = True) … … 2004 2004 res = bounce.simulate(start_time=2.,final_time=5.,options=opts) 2005 2005 2006 nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)2007 nose.tools.assert_almost_equal(res.final('h'),0.98048862,4)2008 nose.tools.assert_almost_equal(res.final('time'),5.000000,5)2006 N.testing.assert_almost_equal(res.initial('h'),1.000000,5) 2007 N.testing.assert_almost_equal(res.final('h'),0.98048862,4) 2008 N.testing.assert_almost_equal(res.final('time'),5.000000,5) 2009 2009 2010 2010 … … 2022 2022 res = bounce.simulate(final_time=3., options=opts) 2023 2023 2024 nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)2025 nose.tools.assert_almost_equal(res.final('h'),0.9804523,5)2026 nose.tools.assert_almost_equal(res.final('time'),3.000000,5)2024 N.testing.assert_almost_equal(res.initial('h'),1.000000,5) 2025 N.testing.assert_almost_equal(res.final('h'),0.9804523,5) 2026 N.testing.assert_almost_equal(res.final('time'),3.000000,5) 2027 2027 2028 2028 #Writing after … … 2035 2035 res = bounce.simulate(final_time=3., options=opt) 2036 2036 2037 nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)2038 nose.tools.assert_almost_equal(res.final('h'),0.9804523,5)2039 nose.tools.assert_almost_equal(res.final('time'),3.000000,5)2037 N.testing.assert_almost_equal(res.initial('h'),1.000000,5) 2038 N.testing.assert_almost_equal(res.final('h'),0.9804523,5) 2039 N.testing.assert_almost_equal(res.final('time'),3.000000,5) 2040 2040 2041 2041 #Test with predefined FMUModel … … 2044 2044 res = model.simulate(final_time=3.,options=opts) 2045 2045 2046 nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)2047 nose.tools.assert_almost_equal(res.final('h'),0.9804523,5)2048 nose.tools.assert_almost_equal(res.final('time'),3.000000,5)2046 N.testing.assert_almost_equal(res.initial('h'),1.000000,5) 2047 N.testing.assert_almost_equal(res.final('h'),0.9804523,5) 2048 N.testing.assert_almost_equal(res.final('time'),3.000000,5) 2049 2049 2050 2050 … … 2061 2061 res = bounce.simulate(final_time=3., options=opts) 2062 2062 2063 nose.tools.assert_almost_equal(res.solver.rtol, 1e4, 6)2063 N.testing.assert_almost_equal(res.solver.rtol, 1e4, 6) 2064 2064 assert res.solver.iter == 'Newton' 2065 2065 2066 nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)2067 nose.tools.assert_almost_equal(res.final('h'),0.9804523,5)2068 nose.tools.assert_almost_equal(res.final('time'),3.000000,5)2066 N.testing.assert_almost_equal(res.initial('h'),1.000000,5) 2067 N.testing.assert_almost_equal(res.final('h'),0.9804523,5) 2068 N.testing.assert_almost_equal(res.final('time'),3.000000,5) 2069 2069 2070 2070 #Writing continuous … … 2074 2074 options={'initialize':True,'CVode_options':{'iter':'FixedPoint','rtol':1e6,'atol':1e6}}) 2075 2075 2076 nose.tools.assert_almost_equal(res.solver.rtol, 0.00000100, 7)2076 N.testing.assert_almost_equal(res.solver.rtol, 0.00000100, 7) 2077 2077 assert res.solver.iter == 'FixedPoint' 2078 2078 2079 nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)2080 nose.tools.assert_almost_equal(res.final('h'),0.98018113,5)2081 nose.tools.assert_almost_equal(res.final('time'),3.000000,5)2079 N.testing.assert_almost_equal(res.initial('h'),1.000000,5) 2080 N.testing.assert_almost_equal(res.final('h'),0.98018113,5) 2081 N.testing.assert_almost_equal(res.final('time'),3.000000,5) 2082 2082 2083 2083 @testattr(stddist_base = True) … … 2095 2095 res = bounce.simulate(final_time=3., options=opts) 2096 2096 2097 nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)2098 nose.tools.assert_almost_equal(res.final('h'),0.9804523,5)2097 N.testing.assert_almost_equal(res.initial('h'),1.000000,5) 2098 N.testing.assert_almost_equal(res.final('h'),0.9804523,5) 2099 2099 2100 2100 bounce.reset() 2101 2101 #bounce.initialize() 2102 2102 2103 nose.tools.assert_almost_equal(bounce.get('h'), 1.00000,5)2103 N.testing.assert_almost_equal(bounce.get('h'), 1.00000,5) 2104 2104 2105 2105 res = bounce.simulate(final_time=3.,options=opts) 2106 2106 2107 nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)2108 nose.tools.assert_almost_equal(res.final('h'),0.9804523,5)2109 2107 N.testing.assert_almost_equal(res.initial('h'),1.000000,5) 2108 N.testing.assert_almost_equal(res.final('h'),0.9804523,5) 2109
Note: See TracChangeset
for help on using the changeset viewer.