Difference between revisions of "Daniswara Azka Surjaatmadja"
Line 632: | Line 632: | ||
'''Flowchart''' | '''Flowchart''' | ||
− | [[File: | + | [[File:Flowchart_Tugas3.png]] |
'''Python Code''' | '''Python Code''' | ||
Line 748: | Line 748: | ||
'''Code Results''' | '''Code Results''' | ||
− | [[File: | + | [[File:Code_Python3.png]] |
'''Converting from Python Code to HTML+Javascript''' | '''Converting from Python Code to HTML+Javascript''' | ||
Line 855: | Line 855: | ||
'''Result''' | '''Result''' | ||
− | [[File: | + | [[File:Code_HTML1.png]] |
+ | |||
+ | [[File:Code_HTML2.png]] |
Revision as of 18:23, 18 November 2024
Contents
Biodata Diri
Perkenalkan, nama saya Daniswara Azka Surjaatmadja, mahasiswa Magister Teknik Mesin di Universitas Indonesia dengan NPM 2406508353. Saat ini, saya fokus pada bidang fire protection system pada bangunan gedung. Melalui studi ini, saya berupaya mendalami aspek-aspek perlindungan kebakaran yang esensial untuk memastikan keamanan dan keandalan struktur bangunan. Saya berharap pengetahuan dan pengalaman ini dapat menjadi kontribusi signifikan dalam meningkatkan standar keselamatan bangunan di masa mendatang.
Pertemuan 1 - Komputasi Teknik (Selasa, 29 Oktober 2024)
Pembuatan akun air.eng.ui.ac.id untuk sebagai fasilitas kegiatan belajar untuk mata kuliah komputasi teknik. Semua catatan mengenai kegiatan kuliah dicatat pada wiki untuk memudahkan dalam mengarsip semua catatan yang berkaitan dengan perkuliahan komputasi teknik.
Perkenalan terhadap metode DAI5 yang dikembangkan oleh Pak DAI untuk menyelesaikan permasalahan yang mungkin dihadapi. Metode DAI5 merupakan pendekatan conscious thinking yang menggunakan kesadaran secara penuh tentang eksistensi adanya Tuhan, dengan diawali niat untuk mendekatkan diri dan mengingat kepada Tuhan dalam melakukan penyelesaian masalah. Tahapan DAI5 terdiri dari Intention, Initial Thinking, Idealization dan Instruction Set. DAI5 juga mengintegrasikan antara hardware, brainware, software (hasil pemikiran) dan heartware (kalbu).
Framework DAI5 adalah pendekatan penyelesaian masalah berbasis conscious thinking, yang berfokus pada kesadaran penuh dalam setiap tahap proses pemecahan masalah. Tujuan DAI5 adalah untuk menciptakan solusi yang komprehensif dan berdampak positif, baik secara teknis maupun sosial, dengan melibatkan aspek-aspek penting seperti niat (intention), pemahaman awal (initial thinking), idealisasi (idealization), dan langkah-langkah instruksi (instruction set).
Adapun komponen dari framework DAI5, antara lain :
1. Intention
Ini adalah tahap awal di mana ditentukan niat dan tujuan yang jelas. Fokusnya adalah pada sila pertama Pancasila, yaitu Ketuhanan Yang Maha Esa, sehingga tujuan utama adalah mencari keridhaan Tuhan dalam menyelesaikan masalah. Intention bersifat subjektif dan hanya diketahui oleh masing-masing individu, dipengaruhi oleh latar belakang dan pengalaman pribadi.
2. Initial Thinking
Tahap ini melibatkan pemahaman mendalam tentang masalah yang akan diselesaikan. Dimulai dengan identifikasi masalah, pengumpulan informasi awal yang relevan, dan perumusan masalah secara detail. Tujuannya adalah untuk memperoleh gambaran besar dan memahami prinsip dasar yang mendasarinya.
3. Idealization
Di sini, kompleksitas masalah disederhanakan dengan membuat asumsi yang dapat dipertanggungjawabkan. Langkah ini membantu mengurangi variabel yang dianggap kurang penting, sehingga solusi yang terarah dapat tercapai.
4. Instruction Set
Tahap terakhir adalah pembuatan serangkaian langkah-langkah terstruktur berdasarkan model yang telah disederhanakan. Langkah ini bertujuan untuk menerapkan solusi dengan efektif sesuai hasil idealization sebelumnya, memberikan panduan yang jelas dalam penyelesaian masalah.
Framework DAI5 membantu dalam memahami konteks masalah secara holistik dan memberikan pendekatan yang lebih sadar dan efektif dibandingkan metode penyelesaian masalah lainnya, dengan menekankan pada brainware (kapasitas berpikir) dan heartware (nilai spiritual).
DAI5 berbeda dari metode lain, seperti DMAIC, Global 8D, dan PDCA, karena menambahkan dimensi kesadaran dan nilai spiritual dalam tiap tahapannya. Berbeda dengan DMAIC yang berbasis data atau PDCA yang iteratif, DAI5 tidak hanya teknis tetapi juga subjektif, menggabungkan pemahaman masalah dengan nilai brainware dan heartware. Hal ini memungkinkan solusi yang lebih holistik, memadukan aspek teknis dan kesadaran untuk menciptakan dampak yang lebih luas secara sosial dan etis. DAI5 cocok untuk pemecahan masalah yang membutuhkan pendekatan komprehensif yang mempertimbangkan tidak hanya hasil akhir, tetapi juga nilai-nilai yang membangun proses tersebut.
Tugas 1 - Komputasi Teknik
Pada tugas 1 Komputasi Teknik kami diarahkan oleh Pak DAI untuk melakukan diskusi dengan menggunakan ChatGPT mengenai finite element equation dari 1D PDE yang diselaraskan dengan DAI5 Framework. Berikut merupakan hasil diskusi saya dengan ChatGPT.
User Question :
Can you derive finite element equations from 1D PDE governing equations using weighted residual in a very simple way along with an example.
ChatGPT Answer :
User Question :
Can you provide with algorithm, flow chart and python code.
ChatGPT Answer :
Algorithm
Flow Chart
Python Code
User Question :
Can you restructure all of your above explanation using DAI5 Framework with intention step as fundamental step as you also mentioned in the following : Free will naturally ties into the DAI5 framework because both free will and consciousness play vital roles in the intention-setting and decision-making processes that drive each step in DAI5. With conscious intention as a central element in DAI5, free will could be seen as the "engine" that enables individuals to choose how to direct that consciousness. This conscious choice—the exercise of free will—could then influence each step, from problem understanding to creating solutions that align with one’s ultimate goals.
ChatGPT Answer :
DAI5 Framework Application
Algorithm and Flow Chart
Python Code
Hasil Coding
Conclusion
Dengan menerapkan kerangka kerja DAI5 pada penurunan persamaan elemen hingga, dapat dilakukan dengan mempertahankan pendekatan terstruktur selama proses berlangsung. Setiap langkah-mulai dari menetapkan tujuan hingga memahami masalah, menyederhanakannya, dan merumuskan langkah-langkah yang dapat ditindaklanjuti-memastikan hasil yang akurat dan bermakna. Metode ini menekankan pengambilan keputusan secara sadar dan pertimbangan etis dalam proses analisis teknik.
Pertemuan 2 - Komputasi Teknik (5 November 2024)
Pada pertemuan kedua Pak DAI menginstruksikan kepada mahasiswa untuk mencari perbedaan dalam pengetahuan dan pola pikir mahasiswa teknik mesin antara mahasiswa S1, S2, dan S3. Dalam menjawab persoalan tersebut Pak DAI mengarahkan agar pencarian dibantu menggunakan ChatGPT. Adapun hasil dari diskusi dengan ChatGPT sebagai berikut ini.
User Question : Give me a question, the question is in three level of degree. One for an undergraduate student, two for a magister student, and three for doctoral student. The question context must be related to mechanical engineering.
ChatGPT Answer :
Undergraduate Level (Basic Understanding) Question: Explain the principles of the first law of thermodynamics and describe how it applies to a closed system. Provide an example of a closed system in everyday life where energy conservation plays a significant role.
Magister Level (Advanced Application) Question: Analyze the effects of thermal conductivity, convection, and radiation in the heat transfer process for an insulated pipeline transporting hot fluid. How would you optimize the insulation to minimize energy loss while considering material and operational costs?
Doctoral Level (Research-Oriented Challenge) Question: Develop a theoretical model to predict heat transfer and energy loss in a multi-layered composite material system used in high-temperature industrial applications. How would you incorporate material heterogeneity and thermal stress factors into your model, and what numerical methods would you use to validate it against experimental data?
User Question : What is the main difference between thee question given above?
ChatGPT Answer :
The main differences between the questions at each academic level lie in depth of understanding, complexity of analysis, and scope of application:
1. Depth of Understanding:
Undergraduate Level: The question focuses on foundational principles, expecting a basic understanding of concepts like energy conservation within a closed system. It doesn’t require detailed technical calculations or modeling, only a conceptual explanation with an everyday example. Magister Level: The question requires a deeper understanding and practical application of heat transfer modes (conduction, convection, radiation). Here, students need to analyze specific engineering problems, consider optimization, and balance cost with effectiveness, demonstrating a more technical grasp. Doctoral Level: The doctoral question expects an advanced theoretical understanding and research-level approach, asking students to build a predictive model. They must consider complexities like material heterogeneity and thermal stresses, pushing beyond established principles to create and validate new methodologies.
2. Complexity of Analysis:
Undergraduate Level: Analysis is relatively simple, mainly focused on explaining core principles and basic applications. Magister Level: Analysis becomes more complex, involving multi-mode heat transfer, cost considerations, and practical engineering trade-offs. Doctoral Level: Analysis is the most complex, involving theoretical modeling, advanced computational methods, and validation through experimental data. This requires not just understanding of principles but also innovation in approach and tools.
3. Scope of Application:
Undergraduate Level: The application is broad and general, aimed at helping students recognize thermodynamics concepts in everyday scenarios. Magister Level: Application focuses on a specific, practical engineering system (e.g., an insulated pipeline) where students must apply advanced knowledge to optimize real-world solutions. Doctoral Level: Application is research-oriented, dealing with new or less understood systems. Here, students contribute to advancing the field by developing models that can be validated and applied in high-precision or high-stakes industrial settings.
Pada kelas Pak DAI menginstruksikan kami untuk diberikan jawaban mengenai one dimension heat conduction untuk mengetest pemahaman kami pada topik yang sedang dibahas tersebut. Didapatkan hasil sebagai berikut :
User Question : Please give me 5 questions about 1 dimension heat conduction. Can you give me in multiple choice and in Bahasa. Don't give me the answer, i will anser it myself, and then you can assess my answer.
ChatGPT Answer :
1. Apa hukum dasar yang digunakan untuk mendeskripsikan aliran panas dalam konduksi satu dimensi?
A. Hukum Newton B. Hukum Stefan-Boltzmann C. Hukum Fourier D. Hukum Avogadro
2. Pada konduksi panas satu dimensi dalam kondisi tunak, bagaimana perubahan suhu terhadap waktu?
A. Suhu meningkat seiring waktu B. Suhu berkurang seiring waktu C. Suhu tidak berubah seiring waktu D. Suhu berubah secara periodik seiring waktu
3. Kondisi batas tipe Dirichlet pada masalah konduksi panas satu dimensi menyatakan bahwa:
A. Suhu di ujung batang ditentukan secara tetap B. Fluks panas di ujung batang adalah konstan C. Fluks panas di ujung batang adalah nol D. Konduktivitas termal di ujung batang beragam
4. Apa keuntungan utama dari metode elemen hingga (finite element method) dalam memecahkan masalah konduksi panas satu dimensi?
A. Dapat memecahkan masalah dengan variabel dan geometri kompleks B. Memastikan hasilnya selalu tepat C. Membutuhkan sedikit data untuk pemecahan masalah D. Lebih cepat dibandingkan metode eksperimental
5. Bagaimana pengaruh konduktivitas termal k suatu material terhadap distribusi suhu dalam batang satu dimensi yang mengalami aliran panas?
A. Semakin tinggi konduktivitas termal, semakin besar gradien suhu B. Semakin rendah konduktivitas termal, semakin kecil gradien suhu C. Semakin tinggi konduktivitas termal, semakin kecil gradien suhu D. Konduktivitas termal tidak mempengaruhi distribusi suhu
Hasil akhir dari penilaian saya adalah sebagai berikut :
Berikut adalah penilaian berdasarkan jawaban Anda: Benar (C. Hukum Fourier) Benar (C. Suhu tidak berubah seiring waktu) Benar (A. Suhu di ujung batang ditentukan secara tetap) Benar (A. Dapat memecahkan masalah dengan variabel dan geometri kompleks) Salah (Jawaban yang benar: C. Semakin tinggi konduktivitas termal, semakin kecil gradien suhu) Skor Anda: 4 dari 5. Anda memperoleh 80%. Bagus sekali!
Tugas 2 - Komputasi Teknik
Tugas : Lakukan penyelesaian permasalahan 1D finite element dalam heat transfer dengan menggunakan pendekatan conscious continuum dan framework DAI 5, buatkan ke dalam aplikasi Python dalam menentukan kondisi pemanasan pada pipa.
Penjelasan Conscious Continuum Menurut ChatGPT
The term "conscious continuum" suggests a concept where continuity is viewed through a lens of awareness and intentionality, especially in the context of problem-solving or scientific analysis. It merges the technical idea of continuity from fields like continuum mechanics with a perspective that emphasizes conscious awareness and purpose at every step of an analysis or process.
Here’s how conscious continuum can apply in different contexts:
1. In Engineering and Physics (Continuum Mechanics): A material is often treated as continuous, assuming no breaks or discontinuities at the microscopic scale. By adding "conscious" to this concept, one might approach each step in the analysis with a clear, deliberate awareness of how small-scale phenomena contribute to the larger, smooth continuum. This means not only treating the material as continuous but doing so with a focused understanding of the process's holistic goal.
2. In Problem Solving (Frameworks like DAI5): A conscious continuum can imply an approach where each stage of analysis—from intention to execution—is approached with mindfulness and deliberate purpose. This continuity of conscious focus across each phase can help in achieving solutions that align with both technical accuracy and broader values, like sustainability or ethical responsibility.
Diskusi Terkait Conscious Continuum dan kaitannya dengan DAI5 Framework
User Question : Can you give a practical example (along with simple calculator such as 1D Problem) ,In engineering that continuum mechanics treatsmaterials as continuous, on integration of uninterrupted "conscious continuum" into the DAI5 framework.
ChatGPT Answer :
To practically apply a continuum mechanics approach integrated with the DAI5 framework in an engineering context, let’s explore a 1D heat conduction problem within a continuum material, for example, a metal rod. This scenario illustrates how material properties can be seen as continuous along the rod, with temperature changes occurring smoothly across its length. Here, we’ll follow each step of the DAI5 framework with a conscious integration approach to illustrate the problem's analysis and solution.
Problem Setup Let’s consider a metal rod of length 𝐿=1𝑚, fixed at one end at temperature 𝑇=100∘C and the other end at 𝑇=0∘C. The goal is to determine the temperature distribution along the rod in steady state, assuming no heat generation within the material (using the 1D steady-state heat conduction equation).
The differential equation governing this process is:
This equation represents the continuum treatment, assuming temperature changes without any abrupt jumps or gaps across the rod.
Applying the DAI5 Framework with Conscious Continuum Integration
1). Intention
Set a clear intention to solve the temperature distribution problem with an awareness of the material's continuous nature. Here, we aim not only to find a solution but to ensure it reflects the rod's physical behavior as a continuous entity, emphasizing stability and accuracy.
2). Initial Thinking
Develop an understanding of the physical laws and principles underlying heat conduction. In this case, Fourier’s law applies, assuming a homogenous material where thermal conductivity 𝑘 is constant. Recognizing the boundary conditions helps define the continuum’s extent: a fixed temperature at both ends ensures a steady-state solution across the rod.
3). Idealization
Simplify the problem by assuming: - The rod is perfectly insulated along its length, so there is no heat loss to the surroundings. - Material properties like thermal conductivity remain constant, reflecting an uninterrupted “conscious continuum” across the rod's length. This idealization provides a manageable framework while maintaining accuracy.
4). Instruction Set
Using the finite element method (FEM), break down the rod into discrete elements (nodes) while treating the material properties as continuous between nodes. Here, we will calculate the temperature distribution at different points along the rod.
The discretized version of the governing equation becomes:
This is solved with Dirichlet boundary conditions: T(0)=100 and T(L)=0
5). Instruction Set and Python Code Example
import numpy as np import matplotlib.pyplot as plt
- Problem setup
L = 1.0 # Length of the rod in meters N = 10 # Number of elements T0, TL = 100, 0 # Boundary temperatures k = 1 # Thermal conductivity (constant)
- Discretize the domain
x = np.linspace(0, L, N+1) # N+1 nodes dx = L / N # Element length
- Initialize temperature array
T = np.zeros(N+1) T[0] = T0 # Set boundary at x=0 T[-1] = TL # Set boundary at x=L
- Build and solve the linear system
A = np.zeros((N+1, N+1)) # Coefficient matrix b = np.zeros(N+1) # Right-hand side vector
- Fill the matrix A and vector b
for i in range(1, N):
A[i, i-1] = A[i, i+1] = k / dx**2 A[i, i] = -2 * k / dx**2
b[0], b[-1] = T0, TL
- Apply boundary conditions
A[0, 0] = A[-1, -1] = 1 A[0, 1] = A[-1, -2] = 0
- Solve the system
T = np.linalg.solve(A, b)
- Plot the result
plt.plot(x, T, '-o', label="Temperature Distribution") plt.xlabel("Position along the rod (m)") plt.ylabel("Temperature (°C)") plt.title("1D Heat Conduction in a Rod") plt.legend() plt.grid(True) plt.show()
Hasil Codingan Grafik
Pertanyaan Hasil Diskusi
User Question : Can you explain to me the recent answer you gave me about "a practical example (along with simple calculator such as 1D Problem) ,In engineering that continuum mechanics treatsmaterials as continuous, on integration of uninterrupted "conscious continuum" into the DAI5 framework". Tell why is the governing equation is like you mentioned before, give me a comprehensive answer about why is the discretized version of the governing equation becomes like you mentioned in the answer, and what is the meaning of "solved with Dirichlet boundary conditions", and please explain to me about the python code you made for the example because i don't really get what is you trying to do. Please explain to me why you use matrix in this example?
ChatGPT Answer :
Problem Setup: 1D Heat Conduction
We are solving a 1D steady-state heat conduction problem for a rod of length 𝐿, with known temperatures at both ends. This setup means that heat flows along the rod but does not change over time (steady state).
1). Governing Equation
In 1D steady-state heat conduction without any internal heat generation, the temperature distribution 𝑇(𝑥) along the rod satisfies the heat conduction (Poisson) equation:
This equation comes from Fourier's law of heat conduction, which states that the heat flux 𝑞 is proportional to the temperature gradient dT/dx. In steady state, the heat flux does not vary along the rod (no sources or sinks inside the rod), which simplifies the equation to a second derivative of 𝑇(𝑥) equal to zero.
2). Discretized Version of the Governing Equation
To solve this equation numerically, we discretize the domain by dividing the rod into 𝑁 segments. Each segment is represented by nodes (points along the rod), and we use these nodes to approximate the temperature at each position.
3). Dirichlet Boundary Conditions
Boundary conditions are necessary to solve the differential equation. Here, we use Dirichlet boundary conditions, meaning that the temperature is fixed at both ends of the rod:
These boundary conditions specify the exact temperatures at the boundaries, allowing us to compute the temperature distribution along the rod between these two endpoints.
4). Explanation of the Python Code
import numpy as np import matplotlib.pyplot as plt
- Problem setup
L = 1.0 # Length of the rod in meters N = 10 # Number of elements T0, TL = 100, 0 # Boundary temperatures k = 1 # Thermal conductivity (constant)
Explanation :
We set the length 𝐿 of the rod to 1 meter and specify 𝑁=10 segments, meaning the rod will have 𝑁+1 nodes (points of calculation). T0 and 𝑇𝐿 represent the fixed temperatures (boundary conditions) at each end of the rod. 𝑘 is the thermal conductivity, assumed to be constant here.
- Discretize the domain
x = np.linspace(0, L, N+1) # N+1 nodes dx = L / N # Element length
Explanation
We divide the rod into 𝑁 elements, generating 𝑁+1 points along the rod using np.linspace(0, L, N+1). This gives the locations (positions) of the nodes. 𝑑𝑥 is the spacing between nodes (element length).
- Initialize temperature array
T = np.zeros(N+1) T[0] = T0 # Set boundary at x=0 T[-1] = TL # Set boundary at x=L
Explanation
We initialize an array T to store the temperature at each node. The temperature at the first (T[0]) and last (T[-1]) nodes is set to the boundary values 𝑇0 and 𝑇𝐿, respectively.
- Build and solve the linear system
A = np.zeros((N+1, N+1)) # Coefficient matrix b = np.zeros(N+1) # Right-hand side vector
- Fill the matrix A and vector b
for i in range(1, N):
A[i, i-1] = A[i, i+1] = k / dx**2 A[i, i] = -2 * k / dx**2
b[0], b[-1] = T0, TL
Explanation
A[0, 0] = A[-1, -1] = 1 A[0, 1] = A[-1, -2] = 0
Explanation These lines enforce the boundary conditions. A[0,0] = 1 and A[-1,-1] = 1 set the first and last entries to match the boundary temperatures exactly. We ensure the temperature at these nodes doesn’t change, reflecting the Dirichlet conditions.
- Solve the system
T = np.linalg.solve(A, b)
Explanation
The np.linalg.solve(A, b) function solves the linear system to obtain the temperature T at each node.
- Plot the result
plt.plot(x, T, '-o', label="Temperature Distribution") plt.xlabel("Position along the rod (m)") plt.ylabel("Temperature (°C)") plt.title("1D Heat Conduction in a Rod") plt.legend() plt.grid(True) plt.show()
Explanation
This part of the code plots the temperature distribution along the rod, with x as the position and T as the temperature at each position.
5). Matrix Representation of the Finite Difference Equations
When we discretize the continuous 1D heat conduction equation, we approximate the temperature at each node by applying finite difference methods. For an internal node 𝑖, we have:
This equation relates the temperatures at adjacent nodes. Repeating this process for each internal node leads to a system of equations where each equation connects several temperatures.
This system can be rewritten in the form: A.T=b,
Using matrices allows us to compactly represent this large system of equations. In matrix form:
-Each row in 𝐴 represents one of the finite difference equations. -The diagonal and off-diagonal entries in 𝐴 correspond to the coefficients of 𝑇𝑖 and its neighboring nodes, capturing the relationships between the nodes in one structure.
When we use matrices, we can solve for the unknowns in a highly systematic way. In our example:
𝑇, the vector of unknown temperatures, is calculated using 𝑇=𝐴^−1.𝑏, or more efficiently with a direct solver like np.linalg.solve(A, b). By using a matrix structure, we leverage linear algebra techniques that are efficient and reliable for solving such systems.
Applying boundary conditions directly to a matrix system is straightforward and organized. For example:
By setting rows in 𝐴 to enforce the boundary conditions, we fix values at the endpoints without needing additional adjustments in the solution.
Penyelesaian Soal Di Kelas
User Question : Now with the same question command make me an example in explaining the conscious continuum and DAI 5 make an application to determine the heating conditions with 1D finite element method on a pipe uniformly with a temperature of 0 degrees Celsius on both sides, heating is given 1000 K. the pipe is made of galvanized with a diameter of 0.75 inch, the length of the pipe is 1.5 meters, heating on the pipe is given uniformly (steady state condition), and also enter the time for the heating conditions (3000 seconds with 10 s interval). explain comprehensively.
ChatGPT Answer :
To solve this problem under the steady-state assumption, we’ll simplify the transient heat conduction equation to the steady-state heat conduction equation for a 1D system. In this case, we ignore the time-dependent term, leaving only the spatial variation.
Problem Setup
We’re considering a galvanized pipe of 1.5 meters in length with a uniform internal heat source and temperatures fixed at both ends (Dirichlet boundary conditions). Here are the details:
Pipe Material: Galvanized steel Pipe Length (L): 1.5 meters Pipe Diameter: 0.75 inches (converted to meters for calculation purposes) Boundary Conditions: Temperature at both ends of the pipe is set to 0 K Internal Heat Source (Q): 1000 K applied uniformly Thermal Conductivity (k): Galvanized steel, assumed to be 16.2 W/m·K
Governing Equation For steady-state, 1D heat conduction with a uniform heat source, the governing equation is:
where:
𝑇 is the temperature, 𝑥 is the position along the length of the pipe, 𝑄 is the uniform heat source (in K), 𝑘 is the thermal conductivity of the material.
Finite Element Formulation
To solve this with the finite element method (FEM):
- Discretize the Domain: Divide the pipe length into 𝑁 elements, each of length ℎ. - Set Up Element Equations
- Assemble Global Matrix and Vector: Combine the element matrices and vectors to create the global stiffness matrix 𝐾 and load vector 𝐹. - Apply Boundary Conditions: Set the temperatures at the pipe’s ends to 0 K. - Solve: Use linear algebra to solve the resulting system for the temperature distribution along the pipe.
Phyton Code
import numpy as np import matplotlib.pyplot as plt
- Problem setup
L = 1.5 # Length of the pipe (meters) N = 10 # Number of elements T_left, T_right = 273.15, 273.15 # Boundary conditions in Kelvin (0°C) Q = 1000 # Uniform internal heat source (K) k = 16.2 # Thermal conductivity (W/m·K) rho = 7850 # Density of galvanized steel (kg/m³) cp = 500 # Specific heat capacity of galvanized steel (J/kg·K)
- Discretize the domain
nodes = np.linspace(0, L, N+1) # N+1 nodes h = L / N # Element length dt = 10 # Time step (seconds) total_time = 3000 # Total simulation time (seconds) time_steps = int(total_time / dt)
- Initialize temperature array
T = np.full(N+1, 273.15) # Initial temperature in Kelvin temperature_over_time = [T.copy()]
- Initialize global stiffness matrix K and load vector F
K = np.zeros((N+1, N+1)) F = np.zeros(N+1)
- Element stiffness matrix and load vector
Ke = (k / h) * np.array([[1, -1], [-1, 1]]) Fe = (Q * h / 2) * np.array([1, 1])
- Assemble the global matrix and vector
for i in range(N):
K[i:i+2, i:i+2] += Ke F[i:i+2] += Fe
- Apply Dirichlet boundary conditions
K[0, :] = 0 K[0, 0] = 1 F[0] = T_left
K[N, :] = 0 K[N, N] = 1 F[N] = T_right
- Transient solution using time-stepping
for t in range(time_steps):
# Update temperature based on the previous temperature distribution T = np.linalg.solve(K + (rho * cp * dt / h) * K, F + (rho * cp * dt / h) * T) temperature_over_time.append(T.copy())
- Plotting the final temperature distribution over time
plt.figure(figsize=(10, 6)) plt.plot(nodes, temperature_over_time[-1], '-o', color="blue", label="Temperature at 3000s") plt.xlabel("Position along the pipe (m)") plt.ylabel("Temperature (K)") plt.title("Temperature Distribution along the Pipe after 3000 Seconds") plt.legend() plt.grid() plt.show()
Hasil Coding
User Question : Why is the temperatur only reach 305 K, eventhough it is expose to 1000 K heat source?
ChatGPT Answer :
If the temperature only reaches 305 K, even though the system is exposed to a 1000 K internal heat source, this can be explained by several factors related to the physical properties and numerical setup of the simulation. Let's break down the potential reasons:
1). Heat Source Distribution
- In your current setup, the internal heat source 𝑄 is uniformly distributed along the length of the pipe. However, this heat source is likely being distributed across the entire pipe, and the heat is being conducted away toward the boundaries.
- The boundaries are held at 273.15 K (0°C), so there is a large temperature gradient between the heat source and the boundaries. Heat will flow from the source towards the boundaries, and the temperature will be limited by the boundary conditions. In a finite length system, it’s not uncommon for the temperature to stabilize at a lower value than the heat source due to heat dissipation at the boundaries.
2). Thermal Conductivity and Heat Diffusion
- The material's thermal conductivity plays a big role in how quickly heat can propagate through the pipe. For galvanized steel with a conductivity of 16.2 W/m·K, heat is conducted along the pipe, but the rate at which the temperature increases depends on the balance between heat supply (from the internal heat source) and heat dissipation at the boundaries.
- The thermal diffusion may not allow the temperature to rise very high, especially if there’s significant heat loss at the boundaries. The temperature increases in response to the heat input, but it’s also continuously lost at the boundaries.
3). Heat Capacity and Mass The density 𝜌 and specific heat capacity 𝑐𝑝 of the material determine how much heat is required to raise the temperature of the pipe by a certain amount. If the material is relatively large or has a high heat capacity, it will require more time and energy to achieve a significant temperature increase. For instance, in your setup, if the pipe has a high mass and a significant specific heat, it may take longer or require more heat to reach higher temperatures.
4). Time Stepping and Simulation Constraints
The simulation uses a time-stepping method, and the step size (10 seconds) might not be small enough to capture the fine details of the transient process. This could lead to an oversimplified temperature evolution, where the system doesn't accumulate enough heat to reach higher temperatures before reaching a steady state.
5). Boundary Conditions (Fixed at 273.15 K)
- With the boundary conditions fixed at 273.15 K (the temperature is set to 0°C in Kelvin), the heat that flows towards the boundaries is continually lost, preventing the temperature from increasing much higher. In a practical setup, heat loss to the surroundings or heat transfer to external systems would prevent the temperature from rising indefinitely.
- If the boundaries were insulated or held at a higher temperature, the pipe could achieve higher temperatures.
6). Heat Source Magnitude
- While the internal heat source 𝑄=1000 𝐾 might seem significant, the actual power transferred to the system depends on its interaction with the material and the balance of the system. The heat source could be in the form of power or energy per unit length, and depending on how it's modeled, it might not be sufficient to overcome the thermal losses and raise the temperature drastically.
- You may want to check whether the heat source is applied as a power input (W/m) or a temperature increase (K) and adjust it accordingly.
Suggestions for Adjustment:
- Increase Heat Source Intensity: If the heat source 𝑄 is applied as a temperature increase, you could increase its value or switch to a power input (in watts per meter) to increase the heat transferred to the system.
- Modify Boundary Conditions: If you want higher temperatures, consider setting the boundary conditions to a higher temperature (e.g., 300 K or higher) to allow more heat to accumulate in the pipe.
- Lower the Heat Capacity or Increase Heat Input: Decrease the specific heat capacity 𝑐𝑝 or increase the internal heat source intensity to make the pipe heat up faster and reach higher temperatures.
- Check the Time Stepping: Ensure that the time-stepping interval is appropriate for capturing the transient behavior accurately. Try reducing 𝑑𝑡 to ensure that the simulation captures smaller temperature changes over time.
- Verify Heat Transfer and Insulation: Consider whether heat loss through the boundaries is realistically modeled. If you want to simulate a more controlled environment, you could assume insulated boundaries or adjust the heat transfer properties at the pipe ends.
Pertemuan dan Tugas 3 - Komputasi Teknik
Pada pertemuan kali ini Pak DAI menginstruksikan kami untuk menentukan sebuah studi kasus berkaitan dengan Teknik Mesin yang dapat kami pilih sendiri dan melakukan penyelesaian terhadap kasus tersebut dengan menggunakan coding. Berdasarkan tugas yang diberikan tersebut, saya ingin membuat sebuah codingan untuk kasus untuk Clapeyron Clacius Equation untuk mencari nilai tekanan saturasi dari suatu senyawa. Tekanan saturasi tersebut dapat digunakan untuk mengetahui apakah senyawa tersebut flammable pada temperatur tertentu atau tidak. Properties dari setiap senyawa mengacu pada buku oleh dreysdale “introduction to fire dynamics”. Dengan menggunakan bantuan ChatGPT berikut merupakan hasil codingannya.
Problem Setup
I want to make a coding for the case for the Clapeyron Clacius Equation to find the saturation pressure value. The saturation pressure can be used to determine whether the compound is flammable at a certain temperature or not. Properties of each compound refer to the book by dreysdale ‘introduction to fire dynamics’. Make the code that i can input the Temperature, E, and F by myself. so that when i want to tun the code it will ask the tempaterature, E, and F. After I input that values it will calculate for the saturated pressure. and from the equation we only got saturated vapor in mmHg, and i want it to be the ratio off saturated pressure and pressure ambient. After we calculate the ratio turn it into percentage so i can analyze if the ratio is flammable or not if its below the volume percentage in table from the book.
DAI5 Framework Approach for Solving the Problem
1. Intention
The objective is to create a program that evaluates whether a compound is flammable at a given temperature based on its physical properties and provides a visual analysis of the flammability over a temperature range.
2. Initial Thinking
- Consider how flammability is determined (e.g., comparing vapor pressure with LFL). - Explore different methods for user interaction (e.g., text input, GUI, or web-based). - Brainstorm how to make the results more accessible (e.g., generating a plot to show trends). - Identify possible compounds and their data for inclusion in the program.
3. Idealization
- A perfect system would automatically detect compounds without user input errors. - It would handle real-time data updates for compound properties and safety limits. - It could simulate various environmental conditions (e.g., different ambient pressures). - It would integrate web-based, cross-platform functionality for broader accessibility.
4. Instruction Set
- Database Setup: Include essential properties (E, F, and LFL) for common compounds. - Flammability Calculation: Implement the Clausius-Clapeyron equation to determine vapor pressures. - Plotting Mechanism: Use libraries (Matplotlib or Chart.js) to visualize trends. - User Input Handling: Build functions to take and validate user input. - Output: Provide a clear decision (flammable or not) and a visual representation of flammability trends.
Flowchart
Python Code
import math import matplotlib.pyplot as plt
- Constants
ambient_pressure_mmHg = 760 # Standard ambient pressure in mmHg
- Compound data
compound_data = {
"n-Pentane": {"E": 6595.1, "F": 7.4897, "LFL": 1.4}, "n-Hexane": {"E": 7627.2, "F": 7.717, "LFL": 1.2}, "n-Octane": {"E": 9221.0, "F": 7.894, "LFL": 0.95}, "n-Decane": {"E": 10912.0, "F": 8.248, "LFL": 0.75}, "Methanol": {"E": 8978.8, "F": 8.639, "LFL": 6.7}, "Ethanol": {"E": 9673.9, "F": 8.827, "LFL": 3.3}, "n-Propanol": {"E": 10421.1, "F": 8.937, "LFL": 2.2}, "Acetone": {"E": 7641.5, "F": 7.904, "LFL": 2.6}, "Methyl ethyl ketone": {"E": 8149.5, "F": 7.959, "LFL": 1.9}, "Benzene": {"E": 8146.5, "F": 7.833, "LFL": 1.3},
}
def calculate_saturation_pressure(E, F, T):
"""Calculate the saturation vapor pressure using Clausius-Clapeyron equation.""" log10_P_sat = -0.2185 * E / T + F P_sat = 10 ** log10_P_sat # Saturation pressure in mmHg return P_sat
def check_flammability(P_sat, LFL):
"""Check if the compound is flammable at the given temperature.""" ratio_percentage = (P_sat / ambient_pressure_mmHg) * 100 is_flammable = ratio_percentage >= LFL return ratio_percentage, is_flammable
def plot_graph(compound_name, E, F, LFL):
"""Plot saturation vapor pressure and flammability.""" temperatures = range(250, 400, 5) # Temperatures in Kelvin saturation_pressures = [calculate_saturation_pressure(E, F, T) for T in temperatures] percentage_ratios = [(P / ambient_pressure_mmHg) * 100 for P in saturation_pressures]
# Plot saturation vapor pressure plt.figure(figsize=(10, 6)) plt.plot(temperatures, percentage_ratios, label=f"{compound_name} - % Saturation Vapor")
# Highlight LFL line plt.axhline(y=LFL, color='r', linestyle='--', label=f"LFL ({LFL}%)")
# Add labels and title plt.xlabel("Temperature (K)") plt.ylabel("Percentage of Saturation Vapor (%)") plt.title(f"Flammability Analysis of {compound_name}") plt.legend() plt.grid(True) plt.show()
- Input values
compound_name = input("Enter the compound name (e.g., n-Pentane): ") temperature = float(input("Enter the temperature in Kelvin: "))
- Retrieve compound properties
if compound_name in compound_data:
E = compound_data[compound_name]["E"] F = compound_data[compound_name]["F"] LFL = compound_data[compound_name]["LFL"]
# Calculate saturation vapor pressure P_sat = calculate_saturation_pressure(E, F, temperature) ratio_percentage, is_flammable = check_flammability(P_sat, LFL)
# Display results print(f"\nFor {compound_name} at {temperature} K:") print(f"Saturation Vapor Pressure: {P_sat:.2f} mmHg") print(f"Percentage of Saturated Vapor Pressure relative to Ambient: {ratio_percentage:.2f}%") if is_flammable: print(f"The compound is flammable at this temperature.") else: print(f"The compound is NOT flammable at this temperature.") # Plot the graph plot_graph(compound_name, E, F, LFL)
else:
print("Compound not found in the database. Please check the name or add it to the database.")
Explanation of the Code
The Python code performs two primary functions:
1. Evaluate Flammability: Determines if a compound is flammable at a user-specified temperature by comparing the compound's saturation vapor pressure (calculated using the Clausius-Clapeyron equation) to its Lower Flammability Limit (LFL).
2. Plot Data: Visualizes how the percentage of saturation vapor pressure relative to ambient pressure changes with temperature and highlights the LFL threshold.
Key Components of the Code:
1. Compound Database:
The data contains values for activation energy (E), a constant (F), and the LFL (%). These values are used in calculations and are specific to each compound. Flammability Evaluation:
2. The Clausius-Clapeyron equation estimates the saturation vapor pressure based on E, F, and the temperature.
- The percentage of this saturation pressure relative to ambient pressure is calculated. - If this percentage exceeds the LFL, the compound is deemed flammable at the given temperature.
3. Plotting:
- Generates a plot showing how the saturation vapor pressure percentage changes across a range of temperatures. - A horizontal line represents the LFL, making it easy to visualize when the compound becomes flammable.
4. User Interaction:
- The program takes inputs for the compound name and temperature, retrieves the relevant data, and performs calculations.
Code Results
Converting from Python Code to HTML+Javascript
<!DOCTYPE html> <html lang="en"> <head>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Flammability Analysis</title> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head> <body>
Flammability Analysis
<label for="compound">Enter Compound Name:</label> <input type="text" id="compound" placeholder="e.g., n-Pentane"> <label for="temperature">Enter Temperature (K):</label> <input type="number" id="temperature" placeholder="e.g., 300"> <button onclick="analyzeFlammability()">Analyze</button>
<canvas id="chart" width="600" height="400"></canvas>
<script> const compoundData = { "n-Pentane": { E: 6595.1, F: 7.4897, LFL: 1.4 }, "n-Hexane": { E: 7627.2, F: 7.717, LFL: 1.2 }, "n-Octane": { E: 9221.0, F: 7.894, LFL: 0.95 }, "n-Decane": { E: 10912.0, F: 8.248, LFL: 0.75 }, "Methanol": { E: 8978.8, F: 8.639, LFL: 6.7 }, "Ethanol": { E: 9673.9, F: 8.827, LFL: 3.3 }, "n-Propanol": { E: 10421.1, F: 8.937, LFL: 2.2 }, "Acetone": { E: 7641.5, F: 7.904, LFL: 2.6 }, "Methyl ethyl ketone": { E: 8149.5, F: 7.959, LFL: 1.9 }, "Benzene": { E: 8146.5, F: 7.833, LFL: 1.3 }, };
function calculateSaturationPressure(E, F, T) { const log10_P_sat = -0.2185 * E / T + F; return Math.pow(10, log10_P_sat); // Saturation pressure in mmHg }
function analyzeFlammability() { const compound = document.getElementById("compound").value; const temperature = parseFloat(document.getElementById("temperature").value); const result = document.getElementById("result");
if (compoundData[compound]) { const { E, F, LFL } = compoundData[compound]; const P_sat = calculateSaturationPressure(E, F, temperature); const percentageRatio = (P_sat / 760) * 100;
result.textContent = `${compound} at ${temperature}K: Saturation Vapor Pressure: ${P_sat.toFixed(2)} mmHg Percentage: ${percentageRatio.toFixed(2)}% Flammability: ${percentageRatio >= LFL ? "Flammable" : "Not Flammable"}`;
plotGraph(compound, E, F, LFL); } else { result.textContent = "Compound not found in the database."; } }
function plotGraph(compound, E, F, LFL) { const temperatures = []; const percentages = []; for (let T = 250; T <= 400; T += 5) { temperatures.push(T); percentages.push((calculateSaturationPressure(E, F, T) / 760) * 100); }
const ctx = document.getElementById("chart").getContext("2d"); new Chart(ctx, { type: "line", data: { labels: temperatures, datasets: [ { label: `${compound} - % Saturation Vapor`, data: percentages, borderColor: "blue", fill: false, }, { label: "LFL (%)", data: Array(temperatures.length).fill(LFL), borderColor: "red", borderDash: [5, 5], fill: false, }, ], }, options: { responsive: true, scales: { x: { title: { display: true, text: "Temperature (K)" } }, y: { title: { display: true, text: "Percentage (%)" } }, }, }, }); } </script>
</body> </html>
Result