View: 1995|Reply: 8
|
C programme...sapa expert yg bleh tolong...
[Copy link]
|
|
i kena buat programme dalam C..(more on engineering).Anyone yang expert bleh tolong tak...nnt i bg details skit. |
|
|
|
|
|
|
|
apa masalahnya? bagi la details. |
|
|
|
|
|
|
|
yup bg detail sikit.. nk wat camner tuh.. |
|
|
|
|
|
|
|
I have to write a programs which i have to add code to calculate /interpolate the loss density from the flux density.
Can anyone help me...
These are the sample of Pseudocode of my program (as below):
# Find the modulus flux density
Bmod = sqrt(Bx*Bx + By*By)
# Find the angle of the field in the element with respect to the x-axis
FieldAngle = atan(By/Bx)
# Find the angle of the field in the element with respect to the rolling direction
Angle = mod(FieldAngle - RollingAngle)
if ( Angle > 90 ) Angle = 180 - Angle
# Find the loss density according to the particular case
if ( 0 =< Angle < 22.5 ) then
if ( Bmod =< 1 ) then
LossLower = Case_0_Loss(0) * Bmod
LossUpper = Case_22.5_Loss(0) * Bmod
endif
if ( 1 < Bmod =< 1.7 ) then
LossLower = interpolate( Bmod, Case_0_Loss )
LossUpper = interpolate( Bmod, Case_22.5_Loss )
endif
if ( 1.7 < Bmod ) then
LossLower = extrapolate( Bmod, Case_0_Loss )
LossUpper = extrapolate( Bmod, Case_22.5_Loss )
endif
# Now interpolate the loss for the actual angle from the Lower and Upper bounds
ElementLossDensity = ( (Angle - 0)*LossUpper + (22.5 - Angle)*LossLower ) / 22.5
endif
if ( 22.5 =< Angle < 45 ) then
if ( Bmod =< 1 ) then
LossLower = Case_22.5_Loss(0) * Bmod
LossUpper = Case_45_Loss(0) * Bmod
endif
if ( 1 < Bmod =< 1.7 ) then
LossLower = interpolate( Bmod, Case_22.5_Loss )
LossUpper = interpolate( Bmod, Case_45_Loss )
endif
if ( 1.7 < Bmod ) then
LossLower = extrapolate( Bmod, Case_22.5_Loss )
LossUpper = extrapolate( Bmod, Case_45_Loss )
endif
# Now interpolate the loss for the actual angle from the Lower and Upper bounds
ElementLossDensity = ( (Angle - 22.5)*LossUpper + (45 - Angle)*LossLower ) / 22.5
endif
if ( 45 =< Angle < 67.5 ) then
if ( Bmod =< 1 ) then
LossLower = Case_45_Loss(0) * Bmod
LossUpper = Case_67.5_Loss(0) * Bmod
endif
if ( 1 < Bmod =< 1.7 ) then
LossLower = interpolate( Bmod, Case_45_Loss )
LossUpper = interpolate( Bmod, Case_67.5_Loss )
endif
if ( 1.7 < Bmod ) then
LossLower = extrapolate( Bmod, Case_45_Loss )
LossUpper = extrapolate( Bmod, Case_67.5_Loss )
endif
# Now interpolate the loss for the actual angle from the Lower and Upper bounds
ElementLossDensity = ( (Angle - 45)*LossUpper + (67.5 - Angle)*LossLower ) / 22.5
endif
if ( 67.5 =< Angle =< 90 ) then
if ( Bmod =< 1 ) then
LossLower = Case_67.5_Loss(0) * Bmod
LossUpper = Case_90_Loss(0) * Bmod
endif
if ( 1 < Bmod =< 1.7 ) then
LossLower = interpolate( Bmod, Case_67.5_Loss )
LossUpper = interpolate( Bmod, Case_90_Loss )
endif
if ( 1.7 < Bmod ) then
LossLower = extrapolate( Bmod, Case_67.5_Loss )
LossUpper = extrapolate( Bmod, Case_90_Loss )
endif
# Now interpolate the loss for the actual angle from the Lower and Upper bounds
ElementLossDensity = ( (Angle - 67.5)*LossUpper + (90 - Angle)*LossLower ) / 22.5
endif
Tolonglah dah kebuntuan idea nih.. |
|
|
|
|
|
|
|
I have to write a programs which i have to add code to calculate /interpolate the loss density from the flux density.
These are the sample of Pseudocode of my program (as below):
# Find the modulus flux density
Bmod = sqrt(Bx*Bx + By*By)
# Find the angle of the field in the element with respect to the x-axis
FieldAngle = atan(By/Bx)
# Find the angle of the field in the element with respect to the rolling direction
Angle = mod(FieldAngle - RollingAngle)
if ( Angle > 90 ) Angle = 180 - Angle
# Find the loss density according to the particular case
if ( 0 =< Angle < 22.5 ) then
if ( Bmod =< 1 ) then
LossLower = Case_0_Loss(0) * Bmod
LossUpper = Case_22.5_Loss(0) * Bmod
endif
if ( 1 < Bmod =< 1.7 ) then
LossLower = interpolate( Bmod, Case_0_Loss )
LossUpper = interpolate( Bmod, Case_22.5_Loss )
endif
if ( 1.7 < Bmod ) then
LossLower = extrapolate( Bmod, Case_0_Loss )
LossUpper = extrapolate( Bmod, Case_22.5_Loss )
endif
# Now interpolate the loss for the actual angle from the Lower and Upper bounds
ElementLossDensity = ( (Angle - 0)*LossUpper + (22.5 - Angle)*LossLower ) / 22.5
endif
if ( 22.5 =< Angle < 45 ) then
if ( Bmod =< 1 ) then
LossLower = Case_22.5_Loss(0) * Bmod
LossUpper = Case_45_Loss(0) * Bmod
endif
if ( 1 < Bmod =< 1.7 ) then
LossLower = interpolate( Bmod, Case_22.5_Loss )
LossUpper = interpolate( Bmod, Case_45_Loss )
endif
if ( 1.7 < Bmod ) then
LossLower = extrapolate( Bmod, Case_22.5_Loss )
LossUpper = extrapolate( Bmod, Case_45_Loss )
endif
# Now interpolate the loss for the actual angle from the Lower and Upper bounds
ElementLossDensity = ( (Angle - 22.5)*LossUpper + (45 - Angle)*LossLower ) / 22.5
endif
if ( 45 =< Angle < 67.5 ) then
if ( Bmod =< 1 ) then
LossLower = Case_45_Loss(0) * Bmod
LossUpper = Case_67.5_Loss(0) * Bmod
endif
if ( 1 < Bmod =< 1.7 ) then
LossLower = interpolate( Bmod, Case_45_Loss )
LossUpper = interpolate( Bmod, Case_67.5_Loss )
endif
if ( 1.7 < Bmod ) then
LossLower = extrapolate( Bmod, Case_45_Loss )
LossUpper = extrapolate( Bmod, Case_67.5_Loss )
endif
# Now interpolate the loss for the actual angle from the Lower and Upper bounds
ElementLossDensity = ( (Angle - 45)*LossUpper + (67.5 - Angle)*LossLower ) / 22.5
endif
if ( 67.5 =< Angle =< 90 ) then
if ( Bmod =< 1 ) then
LossLower = Case_67.5_Loss(0) * Bmod
LossUpper = Case_90_Loss(0) * Bmod
endif
if ( 1 < Bmod =< 1.7 ) then
LossLower = interpolate( Bmod, Case_67.5_Loss )
LossUpper = interpolate( Bmod, Case_90_Loss )
endif
if ( 1.7 < Bmod ) then
LossLower = extrapolate( Bmod, Case_67.5_Loss )
LossUpper = extrapolate( Bmod, Case_90_Loss )
endif
# Now interpolate the loss for the actual angle from the Lower and Upper bounds
ElementLossDensity = ( (Angle - 67.5)*LossUpper + (90 - Angle)*LossLower ) / 22.5
endif
So, saya kena terjemahkan kod nie pd C languange..
Tolonglah dah kebuntuan idea nih.. |
|
|
|
|
|
|
|
straightforward aje tuh, top-down pseudocode, just convert je ke C/C++ code. what's the problem, code tak boleh jalan ke? of course tang interpolate and extrapolate tu you kena supply lah, sebab kita tak tau formula untuk interpolation / extrapolation. |
|
|
|
|
|
|
|
Reply #7 shahnazz's post
yg problem tu tang interpolate / extrapolate..code or formula dia tak tahu |
|
|
|
|
|
|
|
interpolate / extrapolate ini nama method yg ko buat je kan??? method tuh terima 2 parameter then return value double or float
ini penerangan kes
Bmod = sqrt(Bx*Bx + By*By)
FieldAngle = atan(By/Bx)
# Find the angle of the field in the element with respect to the rolling direction
Angle = mod(FieldAngle - RollingAngle)
if ( Angle > 90 ) Angle = 180 - Angle
pastikan ko ada value utk RollingAngle tuh..
if ( Bmod =< 1 ) then
LossLower = Case_0_Loss(0) * Bmod
LossUpper = Case_22.5_Loss(0) * Bmod
endif
cam interpolate( Bmod, Case_45_Loss )
- methd nih terima 2 parameter iaitu Bmod = sqrt(Bx*Bx + By*By), pastikan Bx n By ko letak value sebab dia adalah parameter plg penting..
- paramter kedua cam Case_22.5_Loss(0) ini myb constant shj dn mesti ada value dia contoh
Case_22.5_Loss(0) = -22.5// ini contoh jealah value dia..
- dan ko akan dapat nilai dalam variable LossUpper n LossLower
end of product hasil carian ko utk LossLower,LossUpper and Angle akan dapatkan nilai ElementLossDensity
ElementLossDensity = ( (Angle - 22.5)*LossUpper + (45 - Angle)*LossLower ) / 22.5
so buleh dikatakan ko hanya nk dapat nilai ElementLossDensity shj..
yg penting apa formula dalam method interpolate( float, float ) n extrapolate( float, float)
float interpolate( float a, float b){
float LossUpperLower= a*b;//ini aku reka jer..
return LossUpperLower;
}
float extrapolate( float a, float b){
float LossUpperLower= a*b;//ini aku reka jer..
return LossUpperLower;
}
so kita tak tau apa formula dalam function tuh
[ Last edited by liverpoolfctv at 24-10-2007 08:20 AM ] |
|
|
|
|
|
|
| |
|