pdfxtmd 0.3.9__cp310-cp310-win32.whl → 1.0.0__cp310-cp310-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,266 @@
1
+ Metadata-Version: 2.4
2
+ Name: pdfxtmd
3
+ Version: 1.0.0
4
+ Summary: PDFxTMD is a library for parton distribution functions (PDFs) that integrates both collinear PDFs (cPDFs) and transverse momentum-dependent PDFs (TMDs).
5
+ Home-page: https://github.com/Raminkord92/PDFxTMD
6
+ Author: Ramin Kord Valeshabadi
7
+ Author-email: Ramin Kord Valeshabadi <raminkord92@gmail.com>
8
+ License: GPL-3.0
9
+ Project-URL: Homepage, https://github.com/Raminkord92/PDFxTMD
10
+ Platform: any
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.6
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Dynamic: author
18
+ Dynamic: home-page
19
+ Dynamic: license-file
20
+ Dynamic: platform
21
+ Dynamic: requires-python
22
+
23
+ # PDFxTMDLib Python API
24
+
25
+ **PDFxTMDLib** provides a powerful and easy-to-use Python interface for high-performance Parton Distribution Function (PDF) calculations. It offers unified access to collinear PDFs (cPDFs), Transverse Momentum-Dependent PDFs (TMDs), uncertainty analysis, and QCD coupling calculations.
26
+
27
+ This guide covers the installation and usage of the Python bindings.
28
+
29
+ -----
30
+
31
+ ## Installation
32
+
33
+ You can install the package directly from PyPI:
34
+
35
+ ```bash
36
+ pip install pdfxtmd
37
+ ```
38
+
39
+ -----
40
+
41
+ ## High-Level API: `PDFSet`
42
+
43
+ The `PDFSet` interface is the recommended way to work with PDF sets. It handles the entire collection of PDF members (central value and error sets) and provides a simple API for calculating **uncertainties** and **correlations**.
44
+
45
+ ### 1\. Collinear PDF (cPDF) Uncertainty
46
+
47
+ ```python
48
+ import pdfxtmd
49
+
50
+ # 1. Initialize a CPDFSet for a given PDF set name
51
+ cpdf_set = pdfxtmd.CPDFSet("CT18NLO")
52
+ print(f"Loaded CPDF Set: CT18NLO with {len(cpdf_set)} members.")
53
+
54
+ # 2. Define kinematics
55
+ x = 0.01
56
+ mu2 = 100
57
+
58
+ # 3. Get the central value PDF from member 0
59
+ central_cpdf = cpdf_set[0]
60
+ up_pdf_central = central_cpdf.pdf(pdfxtmd.PartonFlavor.u, x, mu2)
61
+ print(f"Central Up Quark PDF: {up_pdf_central:.6f}")
62
+
63
+ # 4. Calculate the PDF uncertainty (the result is a PDFUncertainty object)
64
+ uncertainty = cpdf_set.Uncertainty(pdfxtmd.PartonFlavor.u, x, mu2)
65
+ print(f"Uncertainty: central={uncertainty.central:.6f}, +{uncertainty.errplus:.6f}, -{uncertainty.errminus:.6f}")
66
+
67
+ # 5. Calculate the correlation between two different partons
68
+ correlation = cpdf_set.Correlation(
69
+ pdfxtmd.PartonFlavor.u, x, mu2, # PDF A
70
+ pdfxtmd.PartonFlavor.d, x, mu2 # PDF B
71
+ )
72
+ print(f"Correlation between u and d quarks: {correlation:.4f}")
73
+ ```
74
+
75
+ ### 2\. TMD Uncertainty
76
+
77
+ The interface for TMDs is analogous. Just use `TMDSet` and include the transverse momentum `kt2`.
78
+
79
+ ```python
80
+ import pdfxtmd
81
+
82
+ # 1. Initialize a TMDSet
83
+ tmd_set = pdfxtmd.TMDSet("PB-NLO-HERAI+II-2018-set2")
84
+ print(f"\nLoaded TMD Set: {tmd_set.info().get_string('SetDesc')} with {len(tmd_set)} members.")
85
+
86
+ # 2. Define kinematics
87
+ x = 0.01
88
+ mu2 = 100
89
+ kt2 = 10
90
+
91
+ # 3. Calculate the TMD uncertainty
92
+ uncertainty_tmd = tmd_set.Uncertainty(pdfxtmd.PartonFlavor.g, x, kt2, mu2)
93
+ print(f"Gluon TMD Uncertainty: central={uncertainty_tmd.central:.6f}, +{uncertainty_tmd.errplus:.6f}, -{uncertainty_tmd.errminus:.6f}")
94
+ ```
95
+
96
+ -----
97
+
98
+ ## Low-Level API: Factories
99
+
100
+ For applications where you only need to evaluate a **single PDF member** and do not require uncertainty analysis, the factory interface offers a more direct approach.
101
+
102
+ ```python
103
+ import pdfxtmd
104
+
105
+ x = 0.01
106
+ mu2 = 100
107
+ kt2 = 10
108
+
109
+ # --- Collinear PDFs (cPDF) using Factory ---
110
+ cpdf_factory = pdfxtmd.GenericCPDFFactory()
111
+ cpdf = cpdf_factory.mkCPDF("CT18NLO", 0) # Get member 0
112
+
113
+ # Evaluate a single flavor
114
+ up_pdf = cpdf.pdf(pdfxtmd.PartonFlavor.u, x, mu2)
115
+ print(f"CPDF (Up Quark) from Factory: {up_pdf:.6f}")
116
+
117
+ # Evaluate all flavors at once (returns a numpy array)
118
+ all_flavors_cpdf = cpdf.pdf(x, mu2)
119
+ print(f"All CPDF Flavors from Factory: {all_flavors_cpdf}")
120
+
121
+
122
+ # --- TMDs using Factory ---
123
+ tmd_factory = pdfxtmd.GenericTMDFactory()
124
+ tmd = tmd_factory.mkTMD("PB-NLO-HERAI+II-2018-set2", 0) # Get member 0
125
+
126
+ # Evaluate a single flavor
127
+ gluon_tmd = tmd.tmd(pdfxtmd.PartonFlavor.g, x, kt2, mu2)
128
+ print(f"\nTMD (Gluon) from Factory: {gluon_tmd:.6f}")
129
+
130
+ # Evaluate all TMD flavors at once (returns a numpy array)
131
+ all_flavors_tmd = tmd.tmd(x, kt2, mu2)
132
+ print(f"All TMD Flavors from Factory: {all_flavors_tmd}")
133
+ ```
134
+
135
+ -----
136
+
137
+ ## QCD Coupling ($\alpha_s$) Calculations
138
+
139
+ You can calculate the strong coupling constant $\alpha_s$ in two ways.
140
+
141
+ ```python
142
+ import pdfxtmd
143
+
144
+ cpdf_set = pdfxtmd.CPDFSet("CT18NLO")
145
+
146
+ # Method A: Directly from the PDFSet object (Recommended)
147
+ print("--- Method A: From PDFSet ---")
148
+ alpha_s_from_set = cpdf_set.alphasQ2(10000)
149
+ print(f"Alpha_s at mu2=10000: {alpha_s_from_set:.5f}")
150
+
151
+
152
+ # Method B: Using the low-level CouplingFactory
153
+ print("\n--- Method B: From CouplingFactory ---")
154
+ coupling_factory = pdfxtmd.CouplingFactory()
155
+ coupling = coupling_factory.mkCoupling("CT18NLO")
156
+ alpha_s_from_factory = coupling.AlphaQCDMu2(10000)
157
+ print(f"Alpha_s at mu2=10000: {alpha_s_from_factory:.5f}")
158
+ ```
159
+
160
+ -----
161
+
162
+ ## Complete Example: Plotting PDFs with Uncertainties
163
+
164
+ This example demonstrates a complete workflow: loading PDF/TMD sets, calculating values and uncertainties over a range of *x*, and plotting the results using `matplotlib`.
165
+
166
+ ```python
167
+ import pdfxtmd
168
+ import numpy as np
169
+ import matplotlib.pyplot as plt
170
+
171
+ # --- Part 1: Collinear PDF (cPDF) ---
172
+ cpdf_set = pdfxtmd.CPDFSet("CT18NLO")
173
+ print(f"Loaded cPDF set: {cpdf_set.info().get_string('SetDesc')}")
174
+
175
+ x_values = np.logspace(-4, -1, 100)
176
+ mu2 = 1000
177
+
178
+ # Calculate central values and uncertainties
179
+ uncertainties = [cpdf_set.Uncertainty(pdfxtmd.PartonFlavor.g, x, mu2) for x in x_values]
180
+ central_pdfs = [u.central for u in uncertainties]
181
+ upper_band = [u.central + u.errplus for u in uncertainties]
182
+ lower_band = [u.central - u.errminus for u in uncertainties]
183
+
184
+ # Plot the cPDF
185
+ plt.figure(figsize=(10, 6))
186
+ plt.plot(x_values, central_pdfs, label='Gluon PDF (CT18NLO)', color='blue')
187
+ plt.fill_between(x_values, lower_band, upper_band, color='blue', alpha=0.2, label='68% CL Uncertainty')
188
+ plt.xscale('log')
189
+ plt.xlabel('$x$')
190
+ plt.ylabel('$xg(x, \mu^2)$')
191
+ plt.title(f'Gluon PDF with Uncertainty at $\mu^2 = {mu2} \ GeV^2$')
192
+ plt.legend()
193
+ plt.grid(True, which="both", ls="--")
194
+ plt.savefig('gluon_pdf_plot.png')
195
+ print("Saved plot to gluon_pdf_plot.png")
196
+ plt.close()
197
+
198
+
199
+ # --- Part 2: Transverse Momentum-Dependent PDF (TMD) ---
200
+ tmd_set = pdfxtmd.TMDSet("PB-LO-HERAI+II-2020-set2")
201
+ print(f"Loaded TMD set: {tmd_set.info().get_string('SetDesc')}")
202
+
203
+ kt2 = 1
204
+
205
+ # Calculate central values and uncertainties
206
+ tmd_uncertainties = [tmd_set.Uncertainty(pdfxtmd.PartonFlavor.g, x, kt2, mu2) for x in x_values]
207
+ central_tmds = [u.central for u in tmd_uncertainties]
208
+ tmd_upper_band = [u.central + u.errplus for u in tmd_uncertainties]
209
+ tmd_lower_band = [u.central - u.errminus for u in tmd_uncertainties]
210
+
211
+ # Plot the TMD
212
+ plt.figure(figsize=(10, 6))
213
+ plt.plot(x_values, central_tmds, label='Gluon TMD (PB-LO-2020)', color='green')
214
+ plt.fill_between(x_values, tmd_lower_band, tmd_upper_band, color='green', alpha=0.2, label='68% CL Uncertainty')
215
+ plt.xscale('log')
216
+ plt.xlabel('$x$')
217
+ plt.ylabel('$xg(x, k_t^2, \mu^2)$')
218
+ plt.title(f'Gluon TMD with Uncertainty at $k_t^2 = {kt2} \ GeV^2, \mu^2 = {mu2} \ GeV^2$')
219
+ plt.legend()
220
+ plt.grid(True, which="both", ls="--")
221
+ plt.savefig('gluon_tmd_plot.png')
222
+ print("Saved plot to gluon_tmd_plot.png")
223
+ plt.close()
224
+ ```
225
+
226
+ -----
227
+
228
+ ## Additional Information
229
+
230
+ ### Error Handling
231
+
232
+ The API raises a `RuntimeError` for invalid kinematic inputs.
233
+
234
+ ```python
235
+ try:
236
+ cpdf.pdf(pdfxtmd.PartonFlavor.u, -0.1, mu2) # Invalid x
237
+ except RuntimeError as e:
238
+ print(f"Caught expected error for invalid x: {e}")
239
+ ```
240
+
241
+ ### Enumerating Parton Flavors
242
+
243
+ You can inspect all available parton flavors and their integer codes.
244
+
245
+ ```python
246
+ print("\n--- All PartonFlavor enum values ---")
247
+ for name, flavor in pdfxtmd.PartonFlavor.__members__.items():
248
+ print(f" {name}: {flavor.value}")
249
+ ```
250
+
251
+ ### Full Code Examples
252
+
253
+ For more detailed examples, see the full tutorials in the project repository:
254
+
255
+ * [python\_tutorial.py](https://www.google.com/search?q=examples/python/python_tutorial.py)
256
+ * [Jupyter Notebook Tutorial (run online)](https://www.google.com/search?q=https://colab.research.google.com/drive/1C_h9oGJJzt5h3m-h6o3lAJ5dl-AVv0j3)
257
+
258
+ -----
259
+
260
+ ## License
261
+
262
+ This project is licensed under the GNU General Public License v3.0. See the `LICENSE` file for details.
263
+
264
+ ## Contact
265
+
266
+ For questions or contributions, please contact [raminkord92@gmail.com](mailto:raminkord92@gmail.com).
@@ -0,0 +1,6 @@
1
+ pdfxtmd.cp310-win32.pyd,sha256=c-zv-qs3xTxF61h6gGv2nP9V-EMD8-oXRrIwOyzqmdE,624128
2
+ pdfxtmd-1.0.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
+ pdfxtmd-1.0.0.dist-info/METADATA,sha256=CNhjr3iFujGiuv23IlseDQyxe-UTptwyHsrBa-6itlw,8761
4
+ pdfxtmd-1.0.0.dist-info/WHEEL,sha256=GWZF0cboiU4MhsG0baPl8rrtCaXFSLW25384gp3vddM,97
5
+ pdfxtmd-1.0.0.dist-info/top_level.txt,sha256=Txg3I6UFaHGSNU9rzKh01hDSldU__3I_tnEY_LwvR5U,42
6
+ pdfxtmd-1.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp310-cp310-win32
5
5