Gains:
- Ability to produce and understand the code that cleans, analyzes and visualizes metallurgical data with Python, with AI support
- Ability to establish a habit of validating AI-generated code with unit checking, test case and physical plausibility
- A holistic understanding of the end-to-end limits, responsibility and ethical framework of AI in metallurgy
Metalurji işi giderek daha çok veriyle yapılıyor: yüzlerce çekme testi sonucu, binlerce SPC ölçümü, ısıl işlem fırın kayıtları, karakterizasyon çıktıları. Chasing this data manually in Excel is slow and error-prone; Python (a common programming language for data analysis and scientific computing) makes this repeatable, auditable, and automatic. Yapay zeka, Python kodu yazma, hata ayıklama ve açıklama konusunda çok güçlüdür — ancak ürettiği kod doğru görünüp yanlış sonuç verebilir: birim hatası, yanlış katsayı, sessiz veri kaybı. Bu son ünitede metalurjik veriyi Python ile AI desteğiyle nasıl analiz edeceğinizi ve her kodu nasıl doğrulayacağınızı öğrenecek, ardından tüm modül boyunca işlenen AI sınırlarını, sorumluluk ve etik çerçevesini bütünsel biçimde toparlayacaksınız.
Typical tasks in metallurgical data analysis
Common tasks with AI support in Python:
- Data cleaning: Missing value, unit confusion (MPa vs. ksi), outlier removal. Dirty data corrupts even the best analysis.
- Visualization: Drawing tensile curve, control chart, grain size distribution, temperature-time profile.
- Hesap ve ilişki: Hall-Petch (tane boyutu-akma dayanımı ilişkisi: σ = σ₀ + k·d^(-1/2)), Arrhenius (sıcaklık-hız), regresyon, istatistik.
- Automation: Batch processing a large number of files and producing summary tables/reports.
The Hall-Petch relationship is a good example here: yield strength increases inversely proportional to the square root of grain diameter. AI can translate this formula into code; But whether you use d as micrometer or meter and what unit you use for k coefficient completely changes the result. The correctness of the code lies not in memorizing the formula, but in validating the units and a test case.
Tip: Be sure to include a “known answer test” in every account the AI writes. Give a small input whose result you know by hand (e.g. expected strength for d = 100 µm); If the code gives that value, you can trust it; if it does not, the error is hidden.
Step by step: A safe analysis flow with AI
- Describe the task and data: Which file, which columns, which units, what will be calculated?
- Request code skeleton: Ask the AI for a commented, step-divided skeleton; Define units with explicit variables at the top.
- Test with small data: Run with a few rows/known values first; Check the result manually.
- Unit and boundary control: Is the output physically reasonable? Is there any nonsense like negative strength, 120% rate?
- Visualize and look: Does the graph show the expected trend? Are the outliers data errors?
- Verify and document: Compare the result to an independent calculation/standard; Comment out the code and assumptions.
AI code verification table
Risk
symptom
Control method
Unit error
The result is 1000x pervert
Define units in explicit variable, size control
Incorrect coefficient/formula
Reasonable but wrong value
Test scenario with known answers
Silent data loss
Number of rows is less than expected
Print number of rows before/after processing
outlier distortion
average kayak
Visualize with a graph, look at the distribution
Overfitting (hallucinatory library)
non-existent function
Run, read error, look at documentation
three mini cases
Case 1 — Hidden volume error. An engineer requests code from the AI for Hall-Petch calculation; The code expects grain diameter in meters, but the engineer enters micrometers. The result is 1000 times perverse, but it is not noticeable at first glance because it looks like a "number". Mühendis d = 100 µm için elle beklediği ~350 MPa ile kodun verdiği absürt değeri karşılaştırınca hatayı yakalar, birim dönüşümünü koda ekler. Lesson: known-answer testing reveals unit error in seconds.
Case 2 — Silent data loss. A team cleans 500 pull test results with AI-written code; While the code drops the rows with missing values, it also accidentally discards some of the valid rows, leaving 300 rows. The average strength is higher than expected because the low value batch is eliminated. When the team prints the number of rows before/after processing, they see that 200 rows have silently disappeared and fix the filter. Lesson: printing the number of rows at each data processing step catches silent losses.
Case 3 — Correct use, repeatable report. A quality team must process dozens of furnace records and produce summary reports every week. It asks the AI to write a commented script that reads files in bulk and produces graphs and summary tables. The team tests the code with a few known files, verifies the number of units and lines, visually inspects the output graph. Then uses the script weekly; Hours of work are reduced to minutes and work in the same, auditable way every week. AI enabled repeatable automation, the team confirmed.
Copiable prompt templates
KOD İSKELETİ ŞABLONU"Rol: Metalurji veri analizi kod asistanısın.Görev: [ör. CSV'den çekme sonuçlarını okuyup ortalama akma dayanımı].Veri: [dosya, kolonlar, BİRİMLER]. pandas ile yorumlu bir iskeletyaz: (1) birimleri en üstte açık değişkende tanımla, (2) veriyi okuve satır sayısını yazdır, (3) temizle ve satır sayısını TEKRARyazdır, (4) hesabı yap, (5) print the result and a plausibility check. Add comments to each step. Mark where I need to verify."
BİLİNEN CEVAPLI TEST ŞABLONU"Aşağıdaki fonksiyon için bir 'bilinen cevaplı test' yaz:[fonksiyon]. Sonucu elle hesaplanabilir küçük bir girdi seç,beklenen çıktıyı yorum olarak yaz ve assert ile kontrol et.Birim tutarlılığını da test et. Test geçmezse olası nedenleri(birim, katsayı, formül) listele."
KOD İNCELEME / HATA AYIKLAMA ŞABLONU"Şu kodu incele: [kod]. Şunları kontrol et ve işaretle:(1) birim tutarlılığı, (2) sessiz veri kaybı riski, (3) aykırıdeğer etkisi, (4) fiziksel olarak imkansız çıktı (negatif dayanım,>%100 oran). Her risk için nasıl doğrulayacağımı yaz. Kodu'çalışıyor' diye onaylama; test edilmeden güvenilmez olduğunu belirt."
GÖRSELLEŞTİRME ŞABLONU"matplotlib ile [çekme eğrisi / kontrol grafiği / dağılım] çiz.Eksen etiketlerine BİRİMLERİ ekle, başlık ve ızgara koy. Aykırınoktaları farklı işaretle. Grafiği gözle kontrol edip bekleneneğilimi (ör. artan gerilme-uzama) doğrulamam gerektiğini belirt.Veriyi 'güzelleştirmek' için hiçbir noktayı gizleme."
Weak prompt / Strong prompt
WEAK PROMPT: "Write me code that does Hall-Petch calculation."
GÜÇLÜ PROMPT:"Rol: Metalurji veri analizi kod asistanısın. Hall-Petch(σy = σ0 + k·d^(-1/2)) hesabı için Python fonksiyonu yaz.Birimler: d mikrometre, σ0 ve σy MPa, k MPa·µm^(1/2). Birimdönüşümünü fonksiyon içinde AÇIK yap ve yorumla. Ayrıca d = 100 µm,σ0 = 50 MPa, k = 300 MPa·µm^0.5 için beklenen sonucu elle hesaplayıpassert ile test et. Fiziksel makullük kontrolü ekle (σy negatifolamaz). Kodu test edilmeden güvenilmez say."
Weak prompt produces code that has no unit and testing and may silently go wrong. Güçlü prompt birimleri açıkça tanımlar, dönüşümü zorunlu kılar, bilinen cevaplı testi ve makullük kontrolünü şart koşar — kodu doğrulanabilir yapar.
Holistic summary of the module: The place and limits of AI in metallurgy
A single principle was repeated throughout this module: AI is an assistant, not a decision maker. Across twelve units, we used AI end-to-end, from material selection to property prediction, phase analysis to microstructure, heat treatment to fabrication, quality control to damage analysis, characterization to standardization and Python analysis. In each unit, the AI explained concepts, generated hypotheses, wrote drafts and code — but in no unit did it make the decision alone. The limits were clear: hallucination (made-up number and standard), non-delegability of safety-critical responsibility, dependence on data quality and measurement/calibration, risk of extrapolation and confidentiality. The discipline of verification has always remained with humans in the standard-laboratory-account triangle.
Common mistakes
- Applying the code to real data without testing with known answers.
- Not defining units clearly; Overlooking the MPa/ksi, µm/m confusion.
- Not printing the number of rows during data processing steps and not noticing the silent loss.
- Relying on the mean without visualizing outliers.
- Accepting the non-existent library/function made up by the AI without executing it.
- Assuming the code is correct because it "seems to work"; failure to check physical plausibility.
In summary
AI in metallurgical data analysis with Python is a powerful accelerator for coding, debugging, and automation; but the code it produces may carry unit errors, incorrect coefficients, and silent data loss. Verify each code with known-answer testing, unit checking, line count tracking, and physical plausibility. Here, as in the entire module, AI is the assistant: it ensures speed and organization, accuracy and responsibility are taken over by the authorized engineer. In safety-critical metallurgical decisions, AI output is never a substitute for standards, experiments, calculations and competent engineer approval.
Application task
Choose a metallurgical calculation (e.g. Hall-Petch or a tensile data average). With the "CODE SKELETON" template, ask the AI for a commented code that prints the number of lines with units explicit. Then add a test scenario where you know the result manually with the "KNOWN ANSWER TEST" template and run it. If the code does not give the expected value, find the error (unit, coefficient, data) and fix it. Finally, write about the AI verification discipline you learned in this module by adapting it to your own business in three articles.
checklist
- [ ] I clearly defined the task, data and units to the AI.
- [ ] I defined the units with explicit variables at the top of the code.
- [ ] In the data processing steps, I printed the number of rows and checked the silent loss.
- [ ] I verified the code with a test case with a known answer.
- [ ] I checked the physical plausibility (negative/absurd value) of the output.
- [ ] I used AI as an accelerator; I kept integrity and responsibility.
Module Exam
1. When working with an AI tool as a materials engineer, the ultimate responsibility for which of the following should always remain with the human (legal engineer)?
- A) Approval and signing of a part's suitability for service ✔
- B) Preparation of the first draft of a damage report
- C) Editing the axis labels of a microstructure graph
- D) Preparing a glossary of metallurgical terms for a presentation
Description: AI; It can speed up tasks such as concept clarification, report drafting, hypothesis list and code skeleton. However, approving the suitability of a part for service/flight is a decision that results in the safety of life and property; cannot be transferred to AI without accredited testing and authorized engineer approval.
2. You asked AI about the yield strength of AISI 4140 steel when quenched and tempered at 200 °C, and he answered '1500 MPa for sure'. What is the first correct action to take?
- A) Put the value directly into the design account because AI seems confident
- B) Verifying the value with material data sheet/mill certificate and tensile test if necessary, not relying on single point value ✔
- C) Randomly lowering the value to stay on the safe side
- D) Accept the value and move directly to the heat treatment recipe
Explanation: Language models can convincingly fabricate unsubstantiated numbers (hallucination). Yield strength; It varies over a wide range depending on tempering temperature, section thickness and hardenability. It is necessary to obtain the value from the mill certificate or the tensile test in accordance with the standard, and not include a single point AI output in the design.
3. With a machine learning model predicting the property of a steel, AI produced a 'safe' value for an alloy well outside the composition range in the training data. What is the main problem with this output?
- A) The model always gives results in percent, MPa is wrong
- B) The prediction is unreliable because it is made outside the training data range (extrapolation) and must be verified by experiment ✔
- C) Model only works for stainless steels
- D) The model's output is always exactly twice the actual value
Explanation: Machine learning models work reasonably within the range of training data (interpolation); When outside this range (extrapolation), predictions become unreliable and the model often does not show this. The value generated at a point outside the training data distribution cannot be used without experimental validation.
4. You applied AI to calculate the phase ratio in a two-phase alloy. What input should AI use correctly when applying the 'lever rule'?
- A) Temperature only; combinations are unnecessary
- B) Only the density of the alloy
- C) Total composition of the alloy with phase boundary compositions at the relevant temperature ✔
- D) Only the melting temperature
Explanation: The lever rule gives the phase quantities using the distances between the phase boundary compositions (e.g. the compositions of the solid and liquid phase) and the total composition of the alloy at a given temperature. If the phase boundary combinations are read incorrectly, the ratio will be completely wrong; Therefore, confirmation of the values from the phase diagram is mandatory.
5. You measured grain size from the microstructure with an AI-powered image processing flow, but forgot to calibrate the scale bar to pixel. Why is the result unreliable?
- A) All dimensional measurements are at the wrong scale because pixel-length calibration was not performed ✔
- B) Measurement is distorted because color image is used
- C) Grain size can only be measured by SEM, optical microscopy is inaccurate
- D) Measurement is unnecessary because the image resolution is high
Description: In quantitative metallography, each pixel corresponds to a length; If this transformation is not calibrated with the scale bar, all dimensional measurements such as grain size, phase ratio, and porosity will appear on the wrong scale. Calibration is the first and mandatory step of image-based measurement.
6. AI suggested a heat treatment recipe (austenitizing + quenching + tempering) to achieve target hardness for a steel. What is the best step before applying the prescription?
- A) Applying the recipe directly to mass production
- B) Apply the recipe on the trial piece, measure the hardness/microstructure and compare it with the standard ✔
- C) Just randomly increase the tempering temperature on the safe side
- D) Correcting and approving only the spelling of the prescription
Description: As a result of heat treatment; Part section thickness, hardenability (Jominy) vary strongly with the reality of the furnace and cooling environment. The prescription given by the AI is an initial hypothesis; It should be verified by applying it on the trial piece and measuring the hardness and microstructure and comparing it with the standard.
7. You asked the AI for a 'specific substance number' of an ASTM standard for a material limit value and it responded with an exact value. What is the correct engineering behavior?
- A) Writing the value directly to the report because the AI is up to date
- B) Changing the value randomly to stay on the safe side
- C) Verify the substance number, version and value from the official and current standard text ✔
- D) Adding the item number to the conformity file without checking it
Explanation: Even if language models know the standard name correctly, they may misremember or make up the article number, version, and breakpoint. In binding fields such as ASTM/ISO/EN, each substance and value must be verified verbatim from the official and current source; The AI output only shows where to look.
8. You showed the photo of the broken surface of a bolt to the AI and received the answer 'this is definitely a fatigue fracture'. What is the correct approach to root cause analysis?
- A) Writing the diagnosis directly into the report because AI speaks precisely
- B) Just increase the resolution of the photo and confirm the diagnosis
- C) Installing a new part without examining the broken surface
- D) Confirm the diagnosis as a hypothesis with fractography, charge history, and microstructure evidence ✔
Description: Broken surface interpretation; Fractography (striation, beach lines, dimple/cleavage separation with SEM) requires consideration of load history, environment and microstructure evidence together. The definitive diagnosis AI makes from a single photo is a hypothesis; The root cause cannot be declared without confirmation by laboratory findings.
9. AI assigned a peak to a specific phase in an XRD (X-ray diffraction) pattern. What is the most appropriate method to make phase identification reliable?
- A) Matching the peak to the reference pattern database (e.g. PDF cards) and checking for overlap and artifacts ✔
- B) Accepting the assignment directly because AI says the phase name
- C) Considering only the highest peak and ignoring the rest
- D) Color the pattern and make it visually beautiful
Description: XRD phase identification is done by matching measured peak positions and intensities with known reference patterns (e.g. ICDD/PDF cards). Assigning a single peak in isolation is misleading; overlapping peaks, preferential orientation and background artifacts should be taken into account and the assignment confirmed with the reference database.
10. A damage/inspection report draft prepared by AI contains technical values that are fluid but of unknown origin. What is the correct behavior?
- A) Presenting the report as it is because the text is fluent
- B) Rounding and glossing the values
- C) Just read the executive summary and skip the rest
- D) Match each value with the original measurement/source and remove the unconfirmed ✔
Description: Each technical value in the report; It must be traceable to measurement, calibrated device record, standard or manufacturer data. Even if it is a value in a fluent sentence, no number whose source has not been verified should be included in the report or decision basis; Otherwise, a fictitious value is transferred to the document that creates liability.
11. What is the best step before using an AI-generated Python calculation (e.g., Hall-Petch relationship for grain size-yield strength)?
- A) Applying the code directly to actual production data
- B) Just making sure the code looks short and neat
- C) Run the code in a test scenario with known results and verify the units and output ✔
- D) Deleting part of the code to shorten it
Explanation: A code may appear correct but give the wrong result: there may be a unit error, incorrect coefficient or formula error. Running the code in a small test case where you know the outcome by hand and comparing it to the expected output and checking the units catches the error before it carries over to the actual decision.
12. You want to paste your company's not yet patented alloy recipe and process parameters into a publicly available AI tool and request analysis. Which is the most correct approach?
- A) Pasting the recipe as is to make it faster
- B) It is enough to just delete the company name and share all the remaining parameters.
- C) Sharing the data and then asking the AI to delete it
- D) Checking the institutional policy and anonymizing the data or using a secure/institutional tool ✔
Description: Alloy recipe, process parameters and customer specifications are trade secret and intellectual property sensitive. Before sharing data, it is necessary to check corporate policy, anonymize it, or use an institutional/on-site tool that does not send the data out.
13. AI-powered SPC (statistical process control) system flagged that a control chart limit had been exceeded in a production batch. What is the correct engineering behavior?
- A) Ignore the warning and continue production
- B) Expanding control limits so that no warning occurs
- C) Consider the warning as a trigger, confirm the measurement, investigate the root cause and decide with acceptance criteria ✔
- D) Directly scrapping the entire batch without measuring
Explanation: Exceeding the control chart limit is a warning; The root cause is not automatically obvious. It could be measurement error, sampling issue, or actual process drift. The correct approach is to consider the warning as a trigger, confirm the measurement, investigate the root cause and make a decision based on the acceptance criteria and NDT/examination result.
14. AI-assisted image assessment on a casting part marked a zone as 'acceptable'. What is the right approach for a safety-critical part?
- A) Considering the AI preliminary evaluation as a screening tool and linking the final acceptance to the NDT result and authorized approval ✔
- B) Consider the AI evaluation as final acceptance and approve the part
- C) Moving on to the next process without inspecting the part at all
- D) It is sufficient to just visually check the surface of the part.
Description: Casting internal defects (porosity, shrinkage, inclusions) are often invisible from the surface and are evaluated by non-destructive testing (NDT: radiography, ultrasonic). The preliminary evaluation that AI gives through the image is a screening tool; Final acceptance of the safety-critical part is given with NDT and authorized inspection approval in accordance with the standard.