Looking for FCalC code
#11
Posted 02 April 2020 - 07:14 AM
FCalc 2.0 Standard Freight.xls does contain the equation for C2, but uses fixed values for E2, which the actual program does not. Still something missing...
#12
Posted 02 April 2020 - 09:58 AM
Based on the description in the document, it looks like E2 was calculated numerically to minimize the squared difference between the davis equation and the MSTS equation. In other words, pick a value for E2. Loop over all integer speeds from 5 to 80 mph and calculate the difference between the davis equation and the MSTS equation. Sum the square of this difference over all speeds. Then pick a different value for E2 and repeat the calculation. Select the E2 that gives the smaller sum. Repeat until the sum doesn't change too much.
The hard part is picking good E2 values. I'm not sure what method the fcalc code used, but I would probably use golden section search.
Doug
The hard part is picking good E2 values. I'm not sure what method the fcalc code used, but I would probably use golden section search.
Doug
#13
Posted 02 April 2020 - 10:41 AM
Thanks for your advise
I managed to download the source code from UKTS and now looking through it, hope I can find the missing pieces.
I managed to download the source code from UKTS and now looking through it, hope I can find the missing pieces.
#14
Posted 02 April 2020 - 11:27 AM
NickonWheels, on 02 April 2020 - 04:29 AM, said:
Well, I have read Methodology and Theory of FCalc 2.txt to the best of my understanding. FCalC puts out five values termed C1, E1, V2, C2, E2.
Those are MSTS parameters, not Davis parameters. In the early stages of creating FCalc OR was not on the scene and the objective was values for MSTS's Friction() parameter. That is NOT the same as Davis -- close, but different.
AFAIK what you want to produce are the A, B, C values going into OR.
#15
Posted 02 April 2020 - 12:36 PM
I'm pretty sure there is an option in FCalc specifically for Davis Coefficients. Unless that's not in all versions...that could be
#16
Posted 02 April 2020 - 03:38 PM
#17
Posted 03 April 2020 - 12:37 AM
Genma Saotome, on 02 April 2020 - 11:27 AM, said:
Those are MSTS parameters, not Davis parameters. In the early stages of creating FCalc OR was not on the scene and the objective was values for MSTS's Friction() parameter. That is NOT the same as Davis -- close, but different.
AFAIK what you want to produce are the A, B, C values going into OR.
AFAIK what you want to produce are the A, B, C values going into OR.
No, I´m indeed looking for the old MSTS parameters in order to get around ORTS Davis lines because of their inappropriate way to define starting resistance and principally non-working private ORTS versions. I finally found the code, but it looks needlessly complicated, mostly because of speed settings everywhere. For Davis lines speed settings don´t matter so there is need to replace them with some general value but this obviously does not work...again
/* Quickly estimate optimum e2 value using midpoint values of vequal and v2 */ c1_temp=0; c2_temp=0; e2_temp=1.0; v2_temp=0.5*(v2_max + v2_min); vequal=0.5*(speed_range + 13.4112); speed=0.44704*ceil(v2_temp); RMS_minimum_error=1e9; RMS_error=1e9; while ((RMS_error = RMS_minimum_error)&&(e2_temp <= 2.0)) { if ((bearingtype == 'S')||(bearingtype == 's')) c1_temp=(A + 0.268224*v2_temp*B + C*pow(0.268224*v2_temp, 2))/pow(0.44704*v2_temp, e1); else c1_temp=A; c2_temp=(A + vequal*B + C*pow(vequal, 2) - c1_temp*pow(0.44704*v2_temp, e1))/(0.44704*v2_temp + pow(vequal, e2_temp)); RMS_error=0; while (speed <= speed_range) { friction1=A + speed*B + C*pow(speed, 2); if (speed > 0.44704*v2_temp) friction2=c1_temp*pow(0.44704*v2_temp, e1) + 0.44704*v2_temp*c2_temp + c2_temp*pow(speed, e2_temp); else friction2=c1_temp*pow(speed, e1); error=friction1-friction2; if (speed > 0.44704*v2_temp) RMS_error=RMS_error + error*error; speed = speed + 0.44704; } RMS_error=sqrt(RMS_error/(speed_range/0.44704 - ceil(v2_temp) + 1)); speed=0.44704*ceil(v2_temp); if (RMS_error < RMS_minimum_error) { RMS_minimum_error=RMS_error; v2=v2_temp; c1=c1_temp; c2=c2_temp; e2=e2_temp; vequal_best=vequal; } if (RMS_error<=50) e2_temp=e2_temp+0.001; else if (RMS_error<=100) e2_temp=e2_temp+0.01; else e2_temp=e2_temp+0.05; } /* Calculate final values using best e2 value as starting point */ RMS_error_last=RMS_minimum_error; RMS_minimum_iteration_error=RMS_minimum_error; v2_temp=v2_min; e2_temp=e2; vequal=13.4112; speed=0.44704*ceil(v2_temp); while ((e2_temp <= 2)&&(RMS_minimum_iteration_error <= RMS_error_last)) { RMS_error_last=RMS_minimum_iteration_error; RMS_minimum_iteration_error = 1e9; while (v2_temp <= v2_max) { if ((bearingtype == 'S')||(bearingtype == 's')) c1_temp=(A + 0.268224*v2_temp*B + C*pow(0.268224*v2_temp, 2))/pow(0.44704*v2_temp, e1); else c1_temp=A; while (vequal <= speed_range) { c2_temp=(A + vequal*B + C*pow(vequal, 2) - c1_temp*pow(0.44704*v2_temp, e1))/(0.44704*v2_temp + pow(vequal, e2_temp)); RMS_error=0; while (speed <= speed_range) { friction1=A + speed*B + C*pow(speed, 2); friction2=c1_temp*pow(0.44704*v2_temp, e1) + 0.44704*v2_temp*c2_temp + c2_temp*pow(speed, e2_temp); error=friction1-friction2; RMS_error=RMS_error + error*error; speed = speed + 0.44704; } RMS_error=sqrt(RMS_error/(speed_range/0.44704 - ceil(v2_temp) + 1)); if (RMS_error < RMS_minimum_error) { RMS_minimum_error=RMS_error; v2=v2_temp; c1=c1_temp; c2=c2_temp; e2=e2_temp; vequal_best=vequal; } if (RMS_error < RMS_minimum_iteration_error) RMS_minimum_iteration_error=RMS_error; error_ratio=RMS_error/RMS_minimum_error; if ((error_ratio<=1.3)&&(error_ratio>=0.77)) vequal=vequal+0.44704; else vequal=vequal+2.23535; speed=0.44704*ceil(v2_temp); } v2_temp=v2_temp+0.1; vequal=13.4112; } e2_temp=e2_temp+0.001; v2_temp=v2_min; }
It seems to me that E2 only got calculated in regards to solid bearings, but even this puts out values not even close enough than what you get in the actual program.
#18
Posted 03 April 2020 - 10:34 AM
NickonWheels, on 03 April 2020 - 12:37 AM, said:
No, I´m indeed looking for the old MSTS parameters in order to get around ORTS Davis lines because of their inappropriate way to define starting resistance and principally non-working private ORTS versions. I finally found the code, but it looks needlessly complicated, mostly because of speed settings everywhere. For Davis lines speed settings don´t matter so there is need to replace them with some general value but this obviously does not work...again
IIRC Joe was trying to push the Friction() values towards something that was closer to Davis values.
I made a spreadsheet for the purpose of plotting resistance (Newtons) over speed where I could see how the two compared. The lines were close but subtly different. I then changed the chart to display only the differences at speed. Looking at value differences, this chart often showed wild variability (e.g., often an s curve) going above and below zero. That is what convinced me to drop Friction() and go with Davis.