Changing Cd in OpenRocket

The Rocketry Forum

Help Support The Rocketry Forum:

WERA611

Member
Joined
Feb 3, 2013
Messages
13
Reaction score
0
I apologize if this is something everyone knows, but I told a TARC group using openrocket to check the impact of Cd on their simulation. They embarrassed me by asking how to do so. I see how to change mass, but Cd seems to be variable only by changing surface finish of individual components. This seems way too clunky and easy to loose track of the end result. What are we overlooking?
 

Buckeye

Well-Known Member
TRF Supporter
Joined
Sep 6, 2009
Messages
2,732
Reaction score
543
Not possible. OR does not have a constant value override option. Rocksim does.

The Cd model in OR can only be changed by changing the rocket shape or finish.
 

woferry

Well-Known Member
Joined
Oct 9, 2013
Messages
808
Reaction score
27
Location
San Jose, CA
I will note that the finish can make a big impact in OR's sims, and there is a "Set for all" button on each part that makes it easy to push the change throughout the parts.

I was lost as to why OR kept coming up with altitudes for my 4" FG Nike Smoke that were way below what I was actually getting from it, until I finally realized that the original source for my .ork had everything set to rough, and that was costing me 1000-2000' per sim (OR estimated 4000' on a flight that went to 5950', etc). Once I switched to polished the sims were much closer (now estimates 5527' for that motor, with accurate weight and Cg, within the margin of error for the motor).

Amusingly though, it seems I have to set every .ork I have to polished on all parts to get accurate sims, and I'd still say that some of my surfaces are pretty rough. :) Seems like if I actually had something that counted as "polished" then OR would once again be low in its sims, assuming the finish can really make as big of a difference as OR thinks it can.
 

Nytrunner

Pop lugs, not drugs
TRF Supporter
Joined
Oct 15, 2016
Messages
7,996
Reaction score
3,709
Location
Huntsville AL
Similar to Woferry, I've got a couple rockets that only sim accurately when set to polished, but I GUARantee you that my paint job was not to a polished quality.

Its important to remember that OR is still an opensource hobby simulator, and has some wiggle room. Your team will have to et a couple practice flights in and compare data.
 

Buckeye

Well-Known Member
TRF Supporter
Joined
Sep 6, 2009
Messages
2,732
Reaction score
543
... OR would once again be low in its sims...
My experience, also. When it comes to drag coefficient, I think the simulators are too conservative and underpedict the flight, all other things being equal. If the simulation predicts much higher than a measurement (as most people complain about), then there is something else very wrong in the simulation that is likely user error.

You can't really verify motor thrust profile or how the developer coded the drag model. However, just about everything else in the simulation is up to you.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
I would like to be able to take actual flight data recalculate CD and then feed it back into OR. You can create extensions or plugins (forget what they are called) to OR, I've not seen details about this but it may be possible to override CD using one.
 

rharshberger

Well-Known Member
Joined
Oct 13, 2014
Messages
9,947
Reaction score
1,896
Location
Pasco, WA
You also have to watch the temperature and other weather variables when the simulation is setup, on more than one occasion correcting the temp brought the sim within 5% of the actual flight.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
You also have to watch the temperature and other weather variables when the simulation is setup, on more than one occasion correcting the temp brought the sim within 5% of the actual flight.
Altitude can also make a big impact
 

Buckeye

Well-Known Member
TRF Supporter
Joined
Sep 6, 2009
Messages
2,732
Reaction score
543
I would like to be able to take actual flight data recalculate CD and then feed it back into OR. You can create extensions or plugins (forget what they are called) to OR, I've not seen details about this but it may be possible to override CD using one.
May be possible, but the plugins are not very clear, even for experts. Called "java gibberish" by a computer scientist in these threads. Ouch.

https://www.rocketryforum.com/showt...igher-winds-at-altitude&p=1677113#post1677113

https://www.rocketryforum.com/showt...igher-winds-at-altitude&p=1677243#post1677243

The venerable wRASP allows you to input a user-defined CD vs. velocity profile.

Do you have a routine to extract CD from your flight data that you can share? I started writing my own data manipulator in Excel for Raven accelerometer output, but I got bogged down in the Standard Atmosphere model and non-standard temperature/pressure corrections.
 

jderimig

Sponsor
TRF Sponsor
Joined
Jan 23, 2009
Messages
3,433
Reaction score
834
You can do a simple work around in OpenRocket to vary Cd.

The drag on a rocket is proportional (linear) with Cd, A, and rho (air density). You can see what OR uses for the Cd of your design by looking at "Component Analysis". If you do not like that value (for example you want a value that's 10% less), you can have OR simulate a flight where the air density is 10% less. Alas, OR doesn't allow you to set air density but it does allow you to set launch altitude.

If you want to sim a flight where the Cd is 10% less than the OR assumption simply set the launch site altitude where the air density is 10% less then the actual launch site altitude.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
May be possible, but the plugins are not very clear, even for experts. Called "java gibberish" by a computer scientist in these threads. Ouch.

https://www.rocketryforum.com/showt...igher-winds-at-altitude&p=1677113#post1677113

https://www.rocketryforum.com/showt...igher-winds-at-altitude&p=1677243#post1677243

The venerable wRASP allows you to input a user-defined CD vs. velocity profile.

Do you have a routine to extract CD from your flight data that you can share? I started writing my own data manipulator in Excel for Raven accelerometer output, but I got bogged down in the Standard Atmosphere model and non-standard temperature/pressure corrections.
sounds like your ahead of me, I've been looking at a spreadsheet that that was for older Raven units and figuring out how to convert it to newer but not really progressed far. Not thought about atmospheric correction at all. I had seen those threads which are not encouraging, especially as my Java experience is pretty limited. Still if there are a few sample plugins would be helpful.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
Found this Thrust Scaler plugin example, sounds close enough to what we want. So should be able to figure out the rest.

https://github.com/plaa/ThrustScaler

Just need to get my laptop working as the power pack has died:facepalm:
Got my new laptop charger and was able to download and build the ThrustScaler plugin and tested it. It's not much but it is a start. Have copied the ThrustScaler to a new project for the CD Override plugin, will see how I go.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
Ok so as an initial step I decided to just build the CD Override plugin to simply accept a multiplier.

In this version we multiply the Friction, Pressure and Base CDs by the specified amount
Then sum up the total CD
Also since Axial Drag is now wrong we need to recalculate it as well

This is the main piece of code doing the work, I had to copy calculateAxialDrag out of OR code as it is kept private.
So should probably talk to the OR guys about getting it exposed.

Code:
[SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setFrictionCD([/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getFrictionCD() * [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]multiplier[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setPressureCD([/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getPressureCD() * [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]multiplier[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setBaseCD([/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getBaseCD() * [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]multiplier[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setCD([/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getFrictionCD() + [/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getPressureCD() + [/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getBaseCD());[/SIZE]
[SIZE=2] 
[/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setCaxial(calculateAxialDrag([/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]conditions[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#6a3e3e][SIZE=2][COLOR=#6a3e3e]forces[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getCD()));[/SIZE]
Also the conditions were not available (required field is AOA), so had to add an extra listener just to catch them.


Here's the plot without the plugin
CD no plugin.jpg

And a second plot with CD set to 90%. As expected it went much higher.
CD at 90%.jpg

I've now had the thought that perhaps people would be interested in using this plugin to tweak their simulations.
 

caveduck

semi old rocketeer
Joined
Jun 6, 2011
Messages
1,570
Reaction score
258
Nice! Are you going to publish your plugin? I was planning to go in and hack OR to change the CD adjustment from a few discrete steps to a continuous variable, but this looks like it will stave off that sink of time. :cool:
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
Nice! Are you going to publish your plugin? I was planning to go in and hack OR to change the CD adjustment from a few discrete steps to a continuous variable, but this looks like it will stave off that sink of time. :cool:
I think for now I'll just post the executable tonight after work, I assume I can just post it here for now. Like I said in my previous post it's a little bit messy, need to talk to the OR guys about cleaning it up. My Java experience isn't so big, but was fun digging into the simulation engine and figuring out what the impact was etc.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
As promised attached is the CD Override plugin.
Download then unzip and place the jar file in your plugins folder.
For Windows 7 it is C:\Users\<user name>\AppData\Roaming\OpenRocket\Plugins
Then start OpenRocket and load a rocket
Go to the Flight Simulations tab, highlight a simulation and choose Edit Simulation
In the Edit Simulation window go to the Simulations options tab
Choose Add extension and under Flight you should find the CD Override plugin

Add Plugin.jpg
 
Last edited:

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
change the CD adjustment from a few discrete steps to a continuous variable
First part was just to figure out how to manipulate the CD in the simulation. Second part is to figure out how to feed in a file with my own CD values.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
A bit more progress on the plugin. I exported the CD curve from OR (same model as above) and also the CD from RasAero for the same model.placed them both in Excel for comparison.



I then then exported the RA data to a text file and loaded it into my plugin. Still got a bit more work to do to tidy it up.

image.jpg
 

Buckeye

Well-Known Member
TRF Supporter
Joined
Sep 6, 2009
Messages
2,732
Reaction score
543
This is really cool. This is the first time I have seen a user on the forum discuss his OR customization and exploit the true "free" part of Open source (ie, "freedom"). The main OR developers do their thing, but most of that is in the background and not discussed in detail here.

So, do the OR simulations run successfully with the imported RASAero Cd curve? Now you can get the accuracy of RASAero in the more user-friendly environment of OR. Bravo.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
This is really cool. This is the first time I have seen a user on the forum discuss his OR customization and exploit the true "free" part of Open source (ie, "freedom"). The main OR developers do their thing, but most of that is in the background and not discussed in detail here.

So, do the OR simulations run successfully with the imported RASAero Cd curve? Now you can get the accuracy of RASAero in the more user-friendly environment of OR. Bravo.
Actually I think there may be a few more plugins out there, just not as well known or perhaps people keeping them to themselves.

Yes it runs, compare the attachment in my last post with the previous attachment marked CD No Plugin. These are from the same OR model.

The biggest limitation is this is really only for single stage rockets. There is a bit of checking that you need to do to cleanup the data before importing but it's not too fiddly. Will go through it in details once I finish refining the GUI and finish up testing.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
Apologies progress for updating the GUI and other refinements has stalled out so instead I'll provide the first working version I tested with the file override option.

To setup:
Download then unzip and place the jar file in your plugins folder.
For Windows 7 it is C:\Users\<user name>\AppData\Roaming\OpenRocket\Plugins

To use
First create / obtain your revised CD data.
I placed mine in Excel for further manipulation and checking
You need to supply a data file as follows:
1. It must contain only 2 columns. The first is Mach, the second is CD
2. The data must follow flight order. IE it must accelerate to max velocity then decelerate. In extracts from both OR and RA I found some entries where it slowed down before reaching max velocity etc which I think was caused by random wind or similar. I used a formula in Excel to help me clean up the data.
3. Duplicate entries are ignored as are any entries with the same Mach speed as the previous entry. You might like to clean these up yourself, again I found OR and RA had multiple entries at the same Mach.
4. Zero entries are ignored
5. Non numerical entries are assumed to be column headings and are ignored.
6. If you don't provide a low enough or high enough Mach entry then the simulation will fall back on the CD calculated by OR. You will want to check the first and last entries are slow enough and that the max Mach entry is fast enough. Add additional entries if required. Also remember you cannot have zero Mach speeds either.
7. When your data is ready then you need to convert it to a text file with white space or tab delimiting.

Next start OpenRocket and load your rocket
Go to the Flight Simulations tab, highlight a simulation and choose Edit Simulation
In the Edit Simulation window go to the Simulations options tab
Choose Add extension and under Flight you should find the CD Override plugin

View attachment 316630

Select Use File to Override CD.
Enter the File Name or use the Browse button to locate your file
Press the Load button
Settings.jpg

The file will load and you'll be shown a graph of its contents
CD Override Screen.jpg

Close the window and run your simulation.
 
Last edited:

Buckeye

Well-Known Member
TRF Supporter
Joined
Sep 6, 2009
Messages
2,732
Reaction score
543
2. The data must follow flight order. IE it must accelerate to max velocity then decelerate. In extracts from both OR and RA I found some entries where it slowed down before reaching max velocity etc which I think was caused by random wind or similar. I used a formula in Excel to help me clean up the data.
I don't understand this implied time requirement. Cd vs. Mach should be sufficient. Doesn't matter if the rocket is accelerating or decelerating. The graph shows two values for a given speed through M= 0.15. How is that possible? I have seen 2 curves of "power on" and off CD because of motor exhaust/base pressure, but never "accelerating" and "decelerating."

Edit: I tried to write power off in quotes, and it was edited to **** How is that a problem?
 
Last edited:

markkoelsch

Well-Known Member
Joined
Mar 18, 2009
Messages
4,364
Reaction score
150
I don't understand this implied time requirement. Cd vs. Mach should be sufficient. Doesn't matter if the rocket is accelerating or decelerating. The graph shows two values for a given speed through M= 0.15. How is that possible? I have seen 2 curves of "power on" and off CD because of motor exhaust/base pressure, but never "accelerating" and "decelerating."

Edit: I tried to write power off in quotes, and it was edited to **** How is that a problem?
You beat me to essentially the same comment. Cd and velocity are the items that should matter. Time and Cd does not make sense to me.

You are also correct about the power on and power off effects on base drag.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
I don't understand this implied time requirement. Cd vs. Mach should be sufficient. Doesn't matter if the rocket is accelerating or decelerating. The graph shows two values for a given speed through M= 0.15. How is that possible? I have seen 2 curves of "power on" and off CD because of motor exhaust/base pressure, but never "accelerating" and "decelerating."

Edit: I tried to write power off in quotes, and it was edited to **** How is that a problem?
The accelerating curve is used during thrusting and the deceleration curve during coast. The thrust curve that is exported by either OR or RA is simply just a continuous values accelerating to a maximum speed and then back down again and yes both of them have different CD curves. It's easiest just to import it again in the same fashion without making people play around with the order. I suppose if people were to produce their own CD data using wind tunnel data then perhaps they won't have 2 seperate curves so won't want to make a second one. Open to ideas as to how you guys think this should work. Perhaps give people some options so people don't have to play with the data as much?
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
Here's the oringinal CD curve as calculated by OR without any plugin you can clearly see the two separate CD curves. Looks like the simulated friction CD is where this comes from
View attachment 316549
 

Buckeye

Well-Known Member
TRF Supporter
Joined
Sep 6, 2009
Messages
2,732
Reaction score
543
Yes, RA and OR will create two curves, power on and power off. I would think that then the simulator would be smart enough have some conditional logic:

IF Thrust > 0, THEN use power on Cd curve
IF Thrust = 0, THEN use power off Cd curve

The user should not have to do this sequencing in his custom curves for import.

I would just use one curve anyway. The power on curve probably has some wild ass guesses based on motor nozzle diameter and exhaust pressure.
 

SpaceManMat

Space Nut
Joined
Dec 20, 2013
Messages
693
Reaction score
62
Yes, RA and OR will create two curves, power on and power off. I would think that then the simulator would be smart enough have some conditional logic:

IF Thrust > 0, THEN use power on Cd curve
IF Thrust = 0, THEN use power off Cd curve

The user should not have to do this sequencing in his custom curves for import.

I would just use one curve anyway. The power on curve probably has some wild ass guesses based on motor nozzle diameter and exhaust pressure.
Ok Ill add an option to allow an import from a simulation file or a single CD curve.
I can rename the graph to show Thrust CD and Coast CD to avoid confusion but if you import a single CD curve then it would just display that.

If the user only supplies a single curve then that would be used for both Thrust and Coast, I don't think the simulator should be altering the file data when the whole point of the plugin was to allow you to override the simulator. At least that's my thinking but again perhaps people want the simulator to do this for them. Would have to dig into the code to figure out what it's doing. One of the difficulties with the plugins is figuring out how to get access to the reqired data and also methods that the simulator is using.

keen to understand how people would use this and what features they require. Obviously all I've done at this stage is figured out how to re-import the simulation data.
 
Top