이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
error in computing log values
조회 수: 33 (최근 30일)
이전 댓글 표시
F SHEFIN
2021년 12월 2일
Hi sir..My simulink model runs Good for certain values of input...but for some values it gives a complex computation error.I have used a algebraic constraint solver.
An error occurred while running the simulation and the simulation was terminated
Caused by:
- Domain error. To compute complex results from real x, use 'log(complex(x))'.
- Error in log.m (line 14) coder.internal.error('Coder:toolbox:ElFunDomainError',mfilename); Error in 'ExitMoles/OutletEnthalpy' (line 20)
댓글 수: 11
Walter Roberson
2021년 12월 2일
Either change everything downstream to expect complex, or else figure out how the signal is going complex. Do you have sqrt() of something, or log() of something, or something to a power?
Walter Roberson
2021년 12월 2일
I see log() mentioned in your title. So track down why you are trying to take log of a negative number.
F SHEFIN
2021년 12월 2일
An error occurred while running the simulation and the simulation was terminated
Caused by:
- Domain error. To compute complex results from real x, use 'log(complex(x))'.
- Error in log.m (line 14) coder.internal.error('Coder:toolbox:ElFunDomainError',mfilename); Error in 'ExitMoles/OutletEnthalpy' (line 20)
This is the error which i get initially...
when i covert all the log terms..like log(complex(x))....then i get a signal mismatch
F SHEFIN
2021년 12월 2일
Log is being taken for a positive number sir...I run the values through a algebraic constant solver....i am not sure where the value turns out to be negative for log....
Walter Roberson
2021년 12월 2일
We need to see the ExitMoles/OutletEnthalpy block. Is it a MATLAB Function Block? Is it a Mathematical Function Block ?
We will not be able to resolve this for you without seeing more of how the value is being computed that you are trying to take the log of.
F SHEFIN
2021년 12월 2일
편집: Walter Roberson
2021년 12월 2일
function [h1,h2,h3,h4,h5] = OutletEnthalpy(Tad)
CH4 = 0;
N2 = 0;
O2 = 0;
CO2 = 0;
H2O = 0;
if Tad < 1000
% CH4
a1ch4 = -1.7669e+05;
a2ch4 = 2.7862e+03;
a3ch4 = -12.0258;
a4ch4 = 0.0392;
a5ch4 = -3.6191e-05;
a6ch4 = 2.0269e-08;
a7ch4 = -4.9767e-12;
b1ch4 = -2.3313e+04;
b2ch4 = 89.0432; %#ok<NASGU>
% H of CH4
CH4 = (((-a1ch4)/Tad^2)+((a2ch4*log(Tad))/Tad)+a3ch4+((a4ch4*Tad)/2)+((a5ch4*Tad^2)/3)+((a6ch4*Tad^3)/4)+((a7ch4*Tad^4)/5)+(b1ch4/Tad))*(8.31*Tad);
else
a1ch4 = 3730042.76000000;
a2ch4 = 1034972.09600000;
a3ch4 = -2412.69856200000;
a4ch4 = 4.64611078000000;
a5ch4 = 0.00229199830700000;
a6ch4 = -6.83683048000000e-07;
a7ch4 = 9.42646893000000e-11;
b1ch4 = -4.82238053000000e-15;
b2ch4 = -121.912488900000; %#ok<NASGU>
% H of CH4
CH4 = (((-a1ch4)/Tad^2)+((a2ch4*log(Tad))/Tad)+a3ch4+((a4ch4*Tad)/2)+((a5ch4*Tad^2)/3)+((a6ch4*Tad^3)/4)+((a7ch4*Tad^4)/5)+(b1ch4/Tad))*(8.31*Tad); %HERE
end
h1 = CH4;
Here i get error in the bolded line...my simulation stops at this line...for certain values of input..
F SHEFIN
2021년 12월 2일
Yes sir it is a matlab function Block.....if possible can we connect on a call...it will be easy for me explain...or else suggest me a way to communicate my whole model to you...
Walter Roberson
2021년 12월 2일
My prediciton:
Tad is a vector rather than a scalar. And it has values that are both < 1000 and >= 1000.
Walter Roberson
2021년 12월 2일
Simulink models can be attached to posts here using the paperclip icon of the editor.
F SHEFIN
2021년 12월 2일
Sir...i have attached the model..
there are 4 inputs..actualyy...T,Ratio,Fuel,Per the output is next to the solver...
pls keep T as 100 at every trail.
For all values of Ratio @ 1 per i am getting my answer..
When ratio changes to 1 simulink doesnt compute @ 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9 ...but computes @ 1 per
when ratio changes ti 2 , simulink doesnt compute @ 0.3 to 0.9....but computes @ 0.1, 0.2,1 per.
similarly for ratio 3 and 4 some values are alone getting computed,
But when ratio is 5 i am able to compute @ all the per values.
It is not simulating for some values...i hope i was clear withe the problem. Thank you
답변 (1개)
Mathieu NOE
2021년 12월 2일
hello
the "log" error was just a consequence of an algebraic loop of OutletEnthalpy bloc : (its input is dependant of the P output)
so probably log of zero or NaN or negative Tad would trigger the error.
simply added a memory block on the P input signal of the OutletEnthalpy bloc and seems the simulation runs fine now (as far I can tell)
댓글 수: 13
F SHEFIN
2021년 12월 2일
Sir...the function of the solver is to give a value at which the values of P and R are equal.That value at which P = R is my answer(output)(tad) sir. Now when i am adding a memory block...i am getting the input as my final answer. But the simulation is running...can u suggest any other to overcome this error without disturbing the function of the solver.
Mathieu NOE
2021년 12월 2일
ok - i didn't pay too much attention to this point
so I did a few manual checks to see if the solver would have a chance to find the solution
so I put a constant Tad input to the OutletEnthalpy block and looked at the error (P - R)
I had to go very high with Tad to see a start of reduction of the (negative) error
at Tad = 990 I still have a large negative error
at Tad = 1000, the error jumps to a very big positive error
so there must be a discontinuity in the simulation that prevents the solver to find the solution
the question is why the OutletEnthalpy block would jump from large negative to large positive P values when Tad crosses the threshold (1000)
F SHEFIN
2021년 12월 2일
Sir pls..Check the value of Per...@ 1 as value of Per...you will not see that big positive error...whereas when you reduce per to 0.9,0.8...upto 0.1 you will see that error. it gives a positive value due to the change in mole values(N1,N2,N3,N4,N5).
F SHEFIN
2021년 12월 2일
I think the presence of memory block can be avoided..coz..it will step back and give the input value as our answer. It disturbs the function of solver....
Mathieu NOE
2021년 12월 2일
ok I removed the memory block
the simulation seems to work for a few Per values (either low 0 to 0.2 ) or high (0.9 and 1)
In between those two areas we get an error
now I wanted to test the continuity of the laws that are coded in the OutletEnthalpy block
if I look at the first equations for CH4 and plot it for the two case (Tad<1000 or >=1000) , there is a significant discontinuity at tad = 1000 - and that worries me. Shouldn't be the two laws coincident at Tad = 1000 ?
% test CH4
Tad = 1:10:1000;
% CH4
a1ch4 = -1.7669e+05;
a2ch4 = 2.7862e+03;
a3ch4 = -12.0258;
a4ch4 = 0.0392;
a5ch4 = -3.6191e-05;
a6ch4 = 2.0269e-08;
a7ch4 = -4.9767e-12;
b1ch4 = -2.3313e+04;
b2ch4 = 89.0432; %#ok<NASGU>
% H of CH4
CH4 = (((-a1ch4)./Tad.^2)+((a2ch4*log(Tad))./Tad)+a3ch4+((a4ch4*Tad)/2)+((a5ch4*Tad.^2)/3)+((a6ch4*Tad.^3)/4)+((a7ch4*Tad.^4)/5)+(b1ch4./Tad)).*(8.31.*Tad);
plot(Tad,CH4);hold on
Tad = 1001:10:2000;
a1ch4 = 3730042.76000000;
a2ch4 = 1034972.09600000;
a3ch4 = -2412.69856200000;
a4ch4 = 4.64611078000000;
a5ch4 = 0.00229199830700000;
a6ch4 = -6.83683048000000e-07;
a7ch4 = 9.42646893000000e-11;
b1ch4 = -4.82238053000000e-15;
b2ch4 = -121.912488900000; %#ok<NASGU>
% H of CH4
CH4 = (((-a1ch4)./Tad.^2)+((a2ch4*log(Tad))./Tad)+a3ch4+((a4ch4.*Tad)/2)+((a5ch4*Tad.^2)/3)+((a6ch4*Tad.^3)/4)+((a7ch4*Tad.^4)/5)+(b1ch4./Tad)).*(8.31.*Tad);
plot(Tad,CH4);hold off
F SHEFIN
2021년 12월 2일
Yes Sir...but the two formulas are same , only the values of variables alone change....So i assume that the trend of graph depends on the initial input and predefined values...I am not able to decode the discontinuities reason....
Mathieu NOE
2021년 12월 3일
hello again
yes I see the equation is the same and the constants are completely different - I'm very surprised ....
may I ask where did you find those values ? publication ? just curious ...
F SHEFIN
2021년 12월 6일
Look at pg 91 sir..under CH4...for less than 1000 there will be constant values and for above 1000 there will be values
F SHEFIN
2021년 12월 6일
Sir @Mathieu NOE Tq for ur patient help...i got the reason for the discontinuity..its because the coefficient values should be same in both the user defined functions..i.e (InletEnthalpy and OutletEnthalpy),they were not same, so we got the error..Now after changing...its perfectly working...Thank you for your help. And @Walter Roberson Tq for your initial suggestions.
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)