-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiSCO_Comp-Exp.py
More file actions
133 lines (108 loc) · 4.27 KB
/
Copy pathDiSCO_Comp-Exp.py
File metadata and controls
133 lines (108 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"""
Spin Transition Analysis - Main Script
========================================
This script analyzes spin transition phenomena in metal complexes.
"""
import numpy as np
from scipy.optimize import root
import os
# Import custom modules
from Modules.thermodynamics import ThermodynamicEquations
from Modules.data_loader import load_parameters, load_systems_data
from Modules.solver import compute_molar_fractions
from Modules.analysis import compute_critical_temperatures, analyze_transition_type
from Modules.plotting import create_plots, export_data_to_file
def main():
"""
Main execution function for spin transition analysis.
"""
# ========================
# LOAD INPUT DATA
# ========================
print("Loading input data...")
# Load parameters (R, Tini, Tfin, dT)
R, Tini, Tfin, dT, print_txt = load_parameters()
# Load system thermodynamic data
systems_data = load_systems_data()
# ========================
# SETUP
# ========================
temperatures = np.arange(Tini, Tfin, dT)
num_systems = len(systems_data['names'])
# Initialize arrays for results
x_values = np.empty((num_systems, len(temperatures))) # Molar fraction of SS
y_values = np.empty((num_systems, len(temperatures))) # Molar fraction of QS
z_values = np.empty((num_systems, len(temperatures))) # Molar fraction of QQ
success_flags = np.empty((num_systems, len(temperatures))) # Success flags
# ========================
# COMPUTE MOLAR FRACTIONS
# ========================
print("Computing molar fractions for each system...")
for idx in range(num_systems):
system_params = {
'dH1': systems_data['dH1'][idx],
'dS1': systems_data['dS1'][idx],
'dH2': systems_data['dH2'][idx],
'dS2': systems_data['dS2'][idx],
'gamma': systems_data['gamma'][idx],
'R': R
}
x_vals, y_vals, z_vals, success_flag = compute_molar_fractions(
temperatures,
system_params
)
x_values[idx, :] = x_vals
y_values[idx, :] = y_vals
z_values[idx, :] = z_vals
success_flags[idx, :] = success_flag
# ========================
# ANALYSIS AND PLOTTING
# ========================
print("Generating plots and analyzing transitions...")
# Create output directory
if not os.path.exists("output"):
os.makedirs("output")
for system_idx in range(num_systems):
system_name = systems_data['names'][system_idx]
system_params = {
'dH1': systems_data['dH1'][system_idx],
'dS1': systems_data['dS1'][system_idx],
'dH2': systems_data['dH2'][system_idx],
'dS2': systems_data['dS2'][system_idx],
'gamma': systems_data['gamma'][system_idx]
}
# Extract results for this system
x_sys = x_values[system_idx, :]
y_sys = y_values[system_idx, :]
z_sys = z_values[system_idx, :]
success_flags_sys = success_flags[system_idx, :]
# Compute critical temperatures
critical_temps = compute_critical_temperatures(
temperatures, x_sys, y_sys, z_sys, system_params
)
# Analyze transition type
transition_type = analyze_transition_type(
temperatures, y_sys, z_sys, critical_temps, dT
)
# Create and save plots
create_plots(
temperatures, x_sys, y_sys, z_sys, success_flags_sys,
system_name, system_params, critical_temps,
Tini, Tfin, dT
)
#Print data
if int(print_txt)==1:
export_data_to_file(
temperatures, x_sys, y_sys, z_sys,
system_name)
# Print results
print(f"\n*** {system_name} ***")
print("------------------")
print(f"T½ = {critical_temps['T_critical']}")
if critical_temps['T1'] < critical_temps['T2']:
print(f"T½ (SS-QS) = {critical_temps['T1']}")
print(f"T½ (QS-QQ) = {critical_temps['T2']}")
print(transition_type)
print("\n✓ Analysis complete! Check the 'output' directory for results.")
if __name__ == "__main__":
main()