[PYTHON] Try 1.5-dimensional unsteady heat transfer analysis with heatrapy

I tried a one-dimensional unsteady heat transfer analysis using open source heatrapy. Recently, I'm doing a passionate relationship at work.

Environment

pip install heatrapy

What you can do

You can do the following: You can do quite a lot!

--Unsteady --Material temperature dependence --Materials can be added at will --Contact between components --Boundary conditions are temperature designation or heat insulation conditions --Heat transfer to the outside of the system at any position (heat input, heat output) ← Heat transfer coefficient and heat transfer by radiation can be set

【model】

--Ta, insulations: Boundary conditions --Q: Heat transfer (possible at any position) --h: Contact condition (possible at any position) --Q0: Temperature-dependent heat transfer (possible at any position)

image.png

paper

The theoretical ones are summarized in the following papers. Thank you https://www.sciencedirect.com/science/article/pii/S2352711018301298#!

One-dimensional unsteady thermal analysis of one component

An example in Documentation.

image.png

[Analysis conditions]

--Component length: 0.5m --Materials: Gd (gadolinium) --Initial condition (amb_temperature): 293K --Boundaries: Temperature condition (300K) on the left side, insulation on the right side (insulation condition at 0) --Time step (dt): 1 second (Note that if you make a mistake here, it will be strange! ← It is related to heat transfer speed) --Borders: 10 divisions --Spatial step (dx): 0.05m (component length / number of divisions = 0.5 / 10 = 0.05m) --Time Interval: 30000s

【material】

The material data is in the installation folder / heatrapy / database. If you add it here, you can add materials. Each file name in the material folder means the following physical property values, and the values can be temperature-dependent.

--cp: Specific heat [J / kg ℃] --k: Thermal conductivity [W / m K] --rho: Density [kg / m3]

[Execution]

Even if I try to move it as a document, it does not work. .. .. (Maybe I haven't maintained it) So I looked at the source code and fixed it.

When you execute the code below, the analysis result will be output to example.txt. write_interval is a specification of how many seconds the result is output. There are four solvers available, and it seems that you can select them accordingly.

run.py


import heatrapy as ht

example = ht.single_object(amb_temperature=293, materials=('Gd',), borders=(1,11),materials_order=(0,),
                            dx=0.05, dt=1., file_name='example.txt',boundaries=(300,0), Q=[], Q0=[],initial_state=False)

example.compute(timeInterval=30000, write_interval=300, solver='implicit_k(x)')

[Visualization of results]

The documentation says to see the results in physplotlib, but we'll use pandas to see the results.

read_data.py


df = pd.read_csv("example.txt")

Read the output file above. As shown below, the temperature at each node is output as a time history.

image.png

Let's look at the graph

graph.py


df = pd.read_csv("example.txt")
df=df.drop("heat[1](W)",axis=1)
df=df.drop("heat[-2](J)",axis=1)
df = df.set_index("time(s)")
df.plot(figsize=(15,8))

image.png

The graph of one-dimensional unsteady thermal analysis!

Impressions

It's a great library. As you can see in the paper, thermal analysis and object-oriented programs go very well together! If such a library increases, the manufacturing industry will not have to "reinvent the wheel", but that is still a story.

Recommended Posts

Try 1.5-dimensional unsteady heat transfer analysis with heatrapy
Two-dimensional unsteady heat conduction analysis with Python
Dimensional compression with self-encoder and principal component analysis