Skip to content

Regarding the error details within the Binary_Precipitation program #28

Description

@m9187-maizuru-student

As part of my graduation research at a Japanese university, I am attempting to run Kawin's Binary_Precipitation, but an error occurs during the “model.solve()” process.

import os
os.chdir(R'\Users\中村研究室学生\Desktop\TDB')

import numpy as np
from kawin.thermo import BinaryThermodynamics

therm = BinaryThermodynamics('AlScZr.tdb', elements=['AL', 'ZR'], phases=['FCC_A1', 'AL3ZR'])
therm.setGuessComposition(0.24)

D0 = 1e-9 #Diffusivity pre-factor (m2/s)
Q = 180000 #Activation energy (J/mol)
diff = {
'FCC_A1': {
'ZR': lambda x, T=1100: D0 * np.exp(-Q / (8.314 * T))
},
'AL3ZR': {
'ZR': lambda x, T=1100: D0 * np.exp(-Q / (8.314 * T))
}
}
therm.setDiffusivity(diff)

from kawin.precipitation.PrecipitationParameters import MatrixParameters, PrecipitateParameters, TemperatureParameters

a = 0.405e-9 # nm
Va = a**3 # nm^3
atomsPerCell = 4

matrix = MatrixParameters(solutes=['ZR'])
matrix.initComposition = 0.01
matrix.volume.setVolume(Va, 'VA', atomsPerCell)
matrix.nucleationSites.setDislocationDensity(1e10)
matrix.nucleationSites.setNucleationDensity(1e20)

precipitate = PrecipitateParameters('AL3ZR')
precipitate.gamma = 0.3
precipitate.volume.setVolume(Va, 'VA', atomsPerCell)
precipitate.nucleation.setNucleationType('dislocations')

temperature = 1100 # Temperature in Kelvin
Tparameters = TemperatureParameters(1100)

from kawin.precipitation.KWNEuler import PrecipitateModel

model = PrecipitateModel([matrix], [precipitate])
model.setThermodynamics(therm)
model.Tparameters = 1100
model.VmAlpha = 1.0e-5
model.VaAlpha = Va
model.aAlpha = a
model.VaBeta = Va
model.VmBeta = {0: 1.05e-5}
model.solve(500*3600, verbose=True, vIt=500)

import matplotlib.pyplot as plt

from kawin.precipitation.Plot_new import plotPrecipitateResults

fig, axes = plt.subplots(2, 2, figsize=(10, 8))

plotPrecipitateResults(model, 'precipitate density', ax=axes[0,0])
plotPrecipitateResults(model, 'volume fraction', ax=axes[0,1])
plotPrecipitateResults(model, 'average radius', ax=axes[1,0], label=r'$R_{avg}$')
plotPrecipitateResults(model, 'critical radius', ax=axes[1,0], label=r'$R_{crit}$')
axes[1,0].legend()
plotPrecipitateResults(model, 'pdf', ax=axes[1,1])#粒径分布

fig.tight_layout()

import matplotlib.pyplot as plt
from kawin.precipitation.Plot_new import plotNucleationRate, plotDrivingForce, plotComposition, plotSupersaturation, plotSizeDistribution, plotCumulativeDistribution

fig, axes = plt.subplots(2, 2, figsize=(10, 8))

plotNucleationRate(model, ax=axes[0,0])
plotDrivingForce(model, ax=axes[0,1])

plotComposition(model, ax=axes[1,0], color='C0', label='Composition')
axes[1,0].set_ylim([0, 0.005])
ax10Twin = axes[1,0].twinx()
plotSupersaturation(model, ax=ax10Twin, color='C1', label='Supersaturation')
ax10Twin.set_ylim([0, 0.0175])
axes[1,0].legend(loc='upper right')
ax10Twin.legend(loc='upper right', bbox_to_anchor=[1, 0.9])

plotSizeDistribution(model, ax=axes[1,1], color='C0', label='PSD')
ax11Twin = axes[1,1].twinx()
plotCumulativeDistribution(model, ax=ax11Twin, color='C1', label='CDF')
axes[1,1].legend(loc='upper right')
ax11Twin.legend(loc='upper right', bbox_to_anchor=[1, 0.9])

fig.tight_layout()

Environment
・Windows 11
・Spyder (IDE)
・Version.Python 3.12.5

The contents of the Plot file in the Kawin folder differ from the Plot file on GitHub. Therefore, if you name the Plot file from the installation “Plot_old” and the GitHub Plot file ‘Plot_new’, the calculation can be performed, but you will encounter the error: “ImportError: cannot import name ‘plotPDF’ from ‘kawin.precipitation.PopulationBalance’”. To resolve this error, I renamed the GitHub PopulationBalance file to “PopulationBalance_new” and the installed one to ‘PopulationBalance_old’. However, running the program now produces an “AttributeError: ‘PopulationBalanceModel’ object has no attribute ‘ZeroMomentFromN’”. The calculations are working, but I cannot plot the results. I have made some minor edits to the program internally. Could this be causing the error? How can I resolve this issue? I would appreciate any advice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions