Skip to content

Commit

Permalink
Refresh and optimize legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
supratimdasinfo committed Oct 8, 2023
1 parent b42b537 commit 6e6c483
Show file tree
Hide file tree
Showing 80 changed files with 280 additions and 240 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ This table provides a clear and concise overview of the 3D models and their corr

- Intuitive Graphical User Interface: Simplifying Program Interaction. Experience seamless interaction with our PyQt5-powered UI. Standalone Python executable created using PyInstaller - no additional dependencies required.

![GUIblank](https://raw.githubusercontent.com/supratimdasinfo/magnetocaloric.mcepy/main/images/GUIv3b.PNG?raw=True)

![GUI](https://raw.githubusercontent.com/supratimdasinfo/magnetocaloric.mcepy/main/images/GUIv3.PNG?raw=True)

For the Python programming approach, follow the steps in the README.
Expand All @@ -61,7 +59,7 @@ For the Python programming approach, follow the steps in the README.
You can easily install the **magnetocaloric** package using pip. Open your command-line interface and run the following command:

```shell
pip install magnetocaloric==1.6.1
pip install magnetocaloric==1.6.6
```

This will install the specified version of the **magnetocaloric** package.
Expand Down
5 changes: 5 additions & 0 deletions build/lib/magnetocaloric/MH_Interpolation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .interpol import interpol

__all__ = [
'interpol'
]
File renamed without changes.
47 changes: 22 additions & 25 deletions build/lib/magnetocaloric/__init__.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
from .interpol import interpol
from .Msqr_HbyM import Msqr_HbyM
from .data_reading import data_reading
from .color_marker import color_marker
from .data_plotting import data_plotting
from .delSm_T import delSm_T
from .delSm_Pivoting import delSm_Pivoting
from .MH_Pivoting import MH_Pivoting
from .arrott_plotting import arrott_plotting
from .data_writing import data_writing
from .T_FWHM_RCP import T_FWHM_RCP
from .data_3d_plotting import mce_3d
from .mag_sus import mag_sus
from .mce_2D_Operations.data_2d_operation import mce
from .mce_3D_Distribution.data_3d_plotting import mce_3d
from .MH_Interpolation.interpol import interpol

__all__ = [
'interpol',
'Msqr_HbyM',
'data_reading',
'color_marker',
'data_plotting',
'delSm_T',
'delSm_Pivoting',
'MH_Pivoting',
'arrott_plotting',
'data_writing',
'T_FWHM_RCP',
'mce_3d',
'mag_sus'
'mce',
'mce_3d'
]
# magnetocaloric package
# Developed by Supratim Das
# First release: November 5, 2021
# Email: supratim0707@gmail.com

# This file can include package-level metadata or comments.
# It's executed when the package is imported.

# Example metadata:

__version__ = '1.6.6' # Package version
__author__ = 'Supratim Das' # Package author
__email__ = 'supratim0707@gmail.com' #Get in Touch
__description__ = 'Effective Approach To Calculate Magnetocaloric Effect Of Any Magnetic Material Using Python' # Package description
__license__ = 'MIT' # License information
__url__ = 'https://pypi.org/project/magnetocaloric/' # URL to the package's repository
__keywords__ = ['magnetism', 'thermodynamics', 'magnetocaloric'] # Keywords describing the package
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions build/lib/magnetocaloric/mce_2D_Operations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .data_2d_operation import mce

__all__ = [
'mce'
]
File renamed without changes.
File renamed without changes.
81 changes: 81 additions & 0 deletions build/lib/magnetocaloric/mce_2D_Operations/data_2d_operation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import matplotlib.pyplot as plt
import sys
from .Msqr_HbyM import Msqr_HbyM
from .data_reading import data_reading
from .color_marker import color_marker
from .data_plotting import data_plotting
from .delSm_T import delSm_T
from .delSm_Pivoting import delSm_Pivoting
from .MH_Pivoting import MH_Pivoting
from .arrott_plotting import arrott_plotting
from .data_writing import data_writing
from .T_FWHM_RCP import T_FWHM_RCP
from .mag_sus import mag_sus
from .N_exponent import n_expo

if not sys.warnoptions:
import warnings
warnings.simplefilter("ignore")

plt.rcParams.update({'font.size': 7})


def mce(samp_name, file_dir, sheet_index, T_row, H_col, g_name, M_unit, H_unit, T_unit, plot_legend, loc, field, linear_threshold, save_data):
"""
Perform Magnetocaloric Effect (MCE) analysis.
Args:
n (int): Number of temperature values.
one_n (int): Number of data points at each temperature.
Returns:
None: The function performs the MCE analysis and generates plots, without returning any value.
"""
# Data Collection
H, M, T, n, one_n, two_n = data_reading(file_dir, sheet_index, T_row, H_col)
# Entropy Change Calculation
three_entropy_change_con, temperatures, Label_one = delSm_T(n, one_n, two_n, H, M, T)
five_entropy_change_con, six_entropy_change_con = delSm_Pivoting(n, three_entropy_change_con, Label_one, temperatures)
# Local Exponent Calculation
N_expo_con, T_arr, H_arr, N_H_label = n_expo(n, one_n, two_n, H, M, T)
# Color and Marker Definitions
colour, marker = color_marker()
# Magnetization and Field Reshaping
one_M_plot_final, two_M_plot_final = MH_Pivoting(one_n, n, M, H)
# Arrott Plot
H_plot_final, M_sqr, one_H_by_M_con = Msqr_HbyM(one_n, n, M, H, T, one_M_plot_final)
# Susceptibility
susceptibility_final = []
T_sus = []
sus_inv = []
sus = []
np_T_sus = []
regression_line = []
np_T_sus_bu = []
regression_bu = []
x = 0
if (g_name== 'sus_plot' or g_name== 'all_plots'):
susceptibility_final, T_sus, sus_inv, sus, np_T_sus, regression_line, np_T_sus_bu, regression_bu, x = mag_sus(g_name, n, one_n, T, H, M, field, linear_threshold)
else:
pass
T_FWHM_con = []
T_FWHM_con_final = []
RCP_con = []
RCP_final = []
H_for_RCP = []
if (g_name== 'RCP_plot' or g_name== 'all_plots'):
# Calculate T_FWHM and RCP
T_FWHM_con, T_FWHM_con_final, RCP_con, RCP_final, H_for_RCP = T_FWHM_RCP(n, Label_one, six_entropy_change_con)
else:
pass
# Data Visualization
data_plotting(g_name, one_n, n, T, H, M_unit, H_unit, T_unit, colour, marker, Label_one, plot_legend, loc, one_M_plot_final, two_M_plot_final, H_plot_final, temperatures, five_entropy_change_con, M_sqr, one_H_by_M_con, N_expo_con, T_arr, N_H_label, T_sus, sus_inv, sus, np_T_sus, regression_line, np_T_sus_bu, regression_bu, x, linear_threshold, T_FWHM_con, T_FWHM_con_final, RCP_con, RCP_final, H_for_RCP, samp_name)
# Modified Arrott Plot
M_pow_MFT, H_by_M_pow_MFT, M_pow_TMFT, H_by_M_pow_TMFT, M_pow_3DH, H_by_M_pow_3DH, M_pow_3DI, H_by_M_pow_3DI = arrott_plotting(g_name, n, one_M_plot_final, one_H_by_M_con)
# Store Data to Excel Files
if (save_data == 'allow'):
data_writing(g_name, file_dir, n, T, Label_one, six_entropy_change_con, M_sqr, one_H_by_M_con, M_pow_MFT, H_by_M_pow_MFT, M_pow_TMFT, H_by_M_pow_TMFT, M_pow_3DH, H_by_M_pow_3DH, M_pow_3DI, H_by_M_pow_3DI, susceptibility_final, T_FWHM_con_final, RCP_final, H_for_RCP, N_expo_con, T_arr, N_H_label)
else:
pass
return ("")



Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def data_plotting(g_name, one_n, n, T, H, M_unit, H_unit, T_unit, colour, marker


fig, ax1 = plt.subplots()
ax1.set_xlabel(f"Temperature (T) {T_unit}")
ax1.set_xlabel(f"Temperature ({T_unit})")
ax1.set_ylabel(f"1/Chi {H_unit}/({M_unit})")
ax1.plot(T_sus, sus_inv, linestyle='solid', marker='o',label=label01, markerfacecolor='none', color='black',markersize=5, linewidth=0.5)
if linear_threshold == 0.0 or linear_threshold == 'None':
Expand Down Expand Up @@ -207,7 +207,7 @@ def data_plotting(g_name, one_n, n, T, H, M_unit, H_unit, T_unit, colour, marker

if len(RCP_final) >= 2:
fig, ax1 = plt.subplots()
ax1.set_xlabel(f"Magnetic Field(H) {H_unit}")
ax1.set_xlabel(f"Magnetic Field ({H_unit})")
ax1.set_ylabel(f"RCP ({M_unit}).{H_unit}")
ax1.plot(H_for_RCP, RCP_final, linestyle='solid', marker='o', label=samp_name_plus_RCP, color='r', markersize=5, linewidth=0.5)
ax1.legend(loc='upper left', frameon=False, ncol=2)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions build/lib/magnetocaloric/mce_3D_Distribution/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .data_3d_plotting import mce_3d

__all__ = [
'mce_3d',
]
89 changes: 8 additions & 81 deletions build/lib/magnetocaloric/mcepy.py
Original file line number Diff line number Diff line change
@@ -1,91 +1,18 @@
import numpy as np
import xlsxwriter
from random import randint
import xlrd
import matplotlib.pyplot as plt
from num2words import num2words
# Import necessary libraries
import sys
import itertools

import matplotlib.pyplot as plt

from .interpol import interpol
from .Msqr_HbyM import Msqr_HbyM
from .data_reading import data_reading
from .color_marker import color_marker
from .data_plotting import data_plotting
from .delSm_T import delSm_T
from .delSm_Pivoting import delSm_Pivoting
from .MH_Pivoting import MH_Pivoting
from .arrott_plotting import arrott_plotting
from .data_writing import data_writing
from .T_FWHM_RCP import T_FWHM_RCP
from .data_3d_plotting import mce_3d
from .mag_sus import mag_sus
from .N_exponent import n_expo
# Import modules from different packages
from .mce_2D_Operations.data_2d_operation import mce
from .mce_3D_Distribution.data_3d_plotting import mce_3d
from .MH_Interpolation.interpol import interpol

# Suppress warnings if not already suppressed
if not sys.warnoptions:
import warnings
warnings.simplefilter("ignore")

# Customize font size for matplotlib
plt.rcParams.update({'font.size': 7})


def mce(samp_name, file_dir, sheet_index, T_row, H_col, g_name, M_unit, H_unit, T_unit, plot_legend, loc, field, linear_threshold, save_data):
"""
Perform Magnetocaloric Effect (MCE) analysis.
Args:
n (int): Number of temperature values.
one_n (int): Number of data points at each temperature.
Returns:
None: The function performs the MCE analysis and generates plots, without returning any value.
"""
# Data Collection
H, M, T, n, one_n, two_n = data_reading(file_dir, sheet_index, T_row, H_col)
# Entropy Change Calculation
three_entropy_change_con, temperatures, Label_one = delSm_T(n, one_n, two_n, H, M, T)
five_entropy_change_con, six_entropy_change_con = delSm_Pivoting(n, three_entropy_change_con, Label_one, temperatures)
# Local Exponent Calculation
N_expo_con, T_arr, H_arr, N_H_label = n_expo(n, one_n, two_n, H, M, T)
# Color and Marker Definitions
colour, marker = color_marker()
# Magnetization and Field Reshaping
one_M_plot_final, two_M_plot_final = MH_Pivoting(one_n, n, M, H)
# Arrott Plot
H_plot_final, M_sqr, one_H_by_M_con = Msqr_HbyM(one_n, n, M, H, T, one_M_plot_final)
# Susceptibility
susceptibility_final = []
T_sus = []
sus_inv = []
sus = []
np_T_sus = []
regression_line = []
np_T_sus_bu = []
regression_bu = []
x = 0
if (g_name== 'sus_plot' or g_name== 'all_plots'):
susceptibility_final, T_sus, sus_inv, sus, np_T_sus, regression_line, np_T_sus_bu, regression_bu, x = mag_sus(g_name, n, one_n, T, H, M, field, linear_threshold)
else:
pass
T_FWHM_con = []
T_FWHM_con_final = []
RCP_con = []
RCP_final = []
H_for_RCP = []
if (g_name== 'RCP_plot' or g_name== 'all_plots'):
# Calculate T_FWHM and RCP
T_FWHM_con, T_FWHM_con_final, RCP_con, RCP_final, H_for_RCP = T_FWHM_RCP(n, Label_one, six_entropy_change_con)
else:
pass
# Data Visualization
data_plotting(g_name, one_n, n, T, H, M_unit, H_unit, T_unit, colour, marker, Label_one, plot_legend, loc, one_M_plot_final, two_M_plot_final, H_plot_final, temperatures, five_entropy_change_con, M_sqr, one_H_by_M_con, N_expo_con, T_arr, N_H_label, T_sus, sus_inv, sus, np_T_sus, regression_line, np_T_sus_bu, regression_bu, x, linear_threshold, T_FWHM_con, T_FWHM_con_final, RCP_con, RCP_final, H_for_RCP, samp_name)
# Modified Arrott Plot
M_pow_MFT, H_by_M_pow_MFT, M_pow_TMFT, H_by_M_pow_TMFT, M_pow_3DH, H_by_M_pow_3DH, M_pow_3DI, H_by_M_pow_3DI = arrott_plotting(g_name, n, one_M_plot_final, one_H_by_M_con)
# Store Data to Excel Files
if (save_data == 'allow'):
data_writing(g_name, file_dir, n, T, Label_one, six_entropy_change_con, M_sqr, one_H_by_M_con, M_pow_MFT, H_by_M_pow_MFT, M_pow_TMFT, H_by_M_pow_TMFT, M_pow_3DH, H_by_M_pow_3DH, M_pow_3DI, H_by_M_pow_3DI, susceptibility_final, T_FWHM_con_final, RCP_final, H_for_RCP, N_expo_con, T_arr, N_H_label)
else:
pass
return ("")



Binary file removed dist/magnetocaloric-1.6.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/magnetocaloric-1.6.1.tar.gz
Binary file not shown.
Binary file added dist/magnetocaloric-1.6.6-py3-none-any.whl
Binary file not shown.
Binary file added dist/magnetocaloric-1.6.6.tar.gz
Binary file not shown.
Binary file modified images/GUIv3.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/GUIv3b.PNG
Binary file not shown.
6 changes: 2 additions & 4 deletions magnetocaloric.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: magnetocaloric
Version: 1.6.1
Version: 1.6.6
Summary: Effective Approach To Calculate Magnetocaloric Effect Of Any Magnetic Material Using Python
Home-page: https://github.com/supratimdasinfo/magnetocaloric.mcepy
Author: Supratim Das
Expand Down Expand Up @@ -67,8 +67,6 @@ This table provides a clear and concise overview of the 3D models and their corr

- Intuitive Graphical User Interface: Simplifying Program Interaction. Experience seamless interaction with our PyQt5-powered UI. Standalone Python executable created using PyInstaller - no additional dependencies required.

![GUIblank](https://raw.githubusercontent.com/supratimdasinfo/magnetocaloric.mcepy/main/images/GUIv3b.PNG?raw=True)

![GUI](https://raw.githubusercontent.com/supratimdasinfo/magnetocaloric.mcepy/main/images/GUIv3.PNG?raw=True)

For the Python programming approach, follow the steps in the README.
Expand All @@ -78,7 +76,7 @@ For the Python programming approach, follow the steps in the README.
You can easily install the **magnetocaloric** package using pip. Open your command-line interface and run the following command:

```shell
pip install magnetocaloric==1.6.1
pip install magnetocaloric==1.6.6
```

This will install the specified version of the **magnetocaloric** package.
Expand Down
34 changes: 19 additions & 15 deletions magnetocaloric.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ Licence.txt
MANIFEST.in
README.md
setup.py
magnetocaloric/MH_Pivoting.py
magnetocaloric/Msqr_HbyM.py
magnetocaloric/N_exponent.py
magnetocaloric/T_FWHM_RCP.py
magnetocaloric/__init__.py
magnetocaloric/arrott_plotting.py
magnetocaloric/color_marker.py
magnetocaloric/data_3d_plotting.py
magnetocaloric/data_plotting.py
magnetocaloric/data_reading.py
magnetocaloric/data_writing.py
magnetocaloric/delSm_Pivoting.py
magnetocaloric/delSm_T.py
magnetocaloric/interpol.py
magnetocaloric/mag_sus.py
magnetocaloric/mcepy.py
magnetocaloric.egg-info/PKG-INFO
magnetocaloric.egg-info/SOURCES.txt
magnetocaloric.egg-info/dependency_links.txt
magnetocaloric.egg-info/requires.txt
magnetocaloric.egg-info/top_level.txt
magnetocaloric.egg-info/top_level.txt
magnetocaloric/MH_Interpolation/__init__.py
magnetocaloric/MH_Interpolation/interpol.py
magnetocaloric/mce_2D_Operations/MH_Pivoting.py
magnetocaloric/mce_2D_Operations/Msqr_HbyM.py
magnetocaloric/mce_2D_Operations/N_exponent.py
magnetocaloric/mce_2D_Operations/T_FWHM_RCP.py
magnetocaloric/mce_2D_Operations/__init__.py
magnetocaloric/mce_2D_Operations/arrott_plotting.py
magnetocaloric/mce_2D_Operations/color_marker.py
magnetocaloric/mce_2D_Operations/data_2d_operation.py
magnetocaloric/mce_2D_Operations/data_plotting.py
magnetocaloric/mce_2D_Operations/data_reading.py
magnetocaloric/mce_2D_Operations/data_writing.py
magnetocaloric/mce_2D_Operations/delSm_Pivoting.py
magnetocaloric/mce_2D_Operations/delSm_T.py
magnetocaloric/mce_2D_Operations/mag_sus.py
magnetocaloric/mce_3D_Distribution/__init__.py
magnetocaloric/mce_3D_Distribution/data_3d_plotting.py
5 changes: 5 additions & 0 deletions magnetocaloric/MH_Interpolation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .interpol import interpol

__all__ = [
'interpol'
]
Binary file not shown.
Binary file not shown.
File renamed without changes.
Loading

0 comments on commit 6e6c483

Please sign in to comment.