Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Kamhal · Aug 24, 2013 at 10:58 PM · valuestwomix

How do I mix two values as if they were fluids?

Hello. In my scene I have a fluid object, which has certain properties, such as volume, density, temperature and so on. I want it so that if while holding down a certain key, another kind of fluid is gradually added to the one already present. I have the volume figured out, since it is simply a matter of increasing the value multiplied by Time.deltaTime, however I cannot figure out how to mix things such as temperature and density. My theory is, if I have a fluid which is 20° and I add to it another fluid of the same volume which is 40°, the temperature should be 30°, since it is the average of the two fluids. However, since I want it to change gradually as the user holds the key down and pours more liquid, I don't have two specific volumes that I can average out. I would like it so that as I pour more of a fluid of a certain temperature in another one, the resulting temperature gradually averages out. How do I mix the two fluids in a realistic manner?

This is the code I currenly use to increase the fluid's volume.

 function AddFluid(addSpeed:float) {
     addedFluid = new Fluid(1,0,0);     //this is a custom class with the fluid's properties
     currentFluid.volu += addedFluid.volu * Time.deltaTime * addSpeed; }

I hope I have been sufficiently clear. Thanks

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Aug 24, 2013 at 11:36 PM 0
Share

This is not really a Unity question. If you google for "calculating the temperature of a mixture," You will find lots of hits. Assu$$anonymous$$g both liquids have the same heat capacity, you can use the equation by $$anonymous$$ybert most of the way down this page:

http://www.scienceforums.net/topic/16788-calculating-mixed-water-temperature/

Note that since in Unity you will be poring over time, after each frame of calculating, you will end up with a new volume and temperature for fluid 'A', which will then be used in the next frame of calculation. So the temperature of 'A' will come up gradually, and the volume will increase gradually.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Aug 25, 2013 at 01:23 AM

I'm actually shocked that the wikipedia pages in english are horrible or even not existant.

What you need to know are:

  • The specific heat capacity "c" of both liquids. If you mix the same liquid this can be ignored.

  • The temperature "T" of both liquids.

  • The mass "m" of both liquids.

If you only have the volume you additionally neeed the density of both liquids to calculate the mass out of the volume.

To calulate the energy in a material there's this forumla:

 Q = c * m * T

where T is the absolute temperature (kelvin scale)

To calculate the mixture temperature of two materials you use this one:

 Tmix = (c1*m1*T1 + c2*m2*T2) / (c1*m1 + c2*m2)

Keep in mind if you're mixing the same materials you can simply omit c and can even use the volume instead of the mass. In this special case you could use:

 Tmix = (V1*T2 + V2*T2) / (V1+V2)

To calculate the temperature while the two fluids are mixing you just have to use the current values. So each time you calculate the new volume (V1+V2) you would also calculate the new temperature (Tmix)

This is btw the Richmannsche Mischungsregel (sorry but i only found the german wiki page :| ).

Anyway what you actually want can't be done in a "realistic manner" since mixing two fluids takes time until you actually have an average temperature. You don't get that immediately. The temerature has to spread out in the volume.

Since you didn't tell us for what putpose you need this, it makes not much sense to go any further here.

Just as side note: the density will never really "mix" since if the fluids come to rest the would be seperated due to gravity if they have different dendities.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by trs9556 · Aug 24, 2013 at 11:28 PM

You could have a method to get current temperature and one to set current temperature (and density). From there you can get the temp of fluid one and the temp of fluid two, do whatever math you wish to do (averaging you mentioned) and then set the value to the fluid.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unexpected values at the inspector when initializing member values from built-in arrays 0 Answers

How will i update my table values every time? 1 Answer

Input.getaxis (and getaxisraw) not returning the correct values with my joysticks 0 Answers

Dictionary doesn't exist? 1 Answer

Triple Slider control - UI slider value control 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges