pdfxtmd 0.3.0__cp38-cp38-win_amd64.whl → 1.0.0__cp38-cp38-win_amd64.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,261 @@
1
+ Metadata-Version: 2.1
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
+
18
+ # PDFxTMDLib Python API
19
+
20
+ **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.
21
+
22
+ This guide covers the installation and usage of the Python bindings.
23
+
24
+ -----
25
+
26
+ ## Installation
27
+
28
+ You can install the package directly from PyPI:
29
+
30
+ ```bash
31
+ pip install pdfxtmd
32
+ ```
33
+
34
+ -----
35
+
36
+ ## High-Level API: `PDFSet`
37
+
38
+ 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**.
39
+
40
+ ### 1\. Collinear PDF (cPDF) Uncertainty
41
+
42
+ ```python
43
+ import pdfxtmd
44
+
45
+ # 1. Initialize a CPDFSet for a given PDF set name
46
+ cpdf_set = pdfxtmd.CPDFSet("CT18NLO")
47
+ print(f"Loaded CPDF Set: CT18NLO with {len(cpdf_set)} members.")
48
+
49
+ # 2. Define kinematics
50
+ x = 0.01
51
+ mu2 = 100
52
+
53
+ # 3. Get the central value PDF from member 0
54
+ central_cpdf = cpdf_set[0]
55
+ up_pdf_central = central_cpdf.pdf(pdfxtmd.PartonFlavor.u, x, mu2)
56
+ print(f"Central Up Quark PDF: {up_pdf_central:.6f}")
57
+
58
+ # 4. Calculate the PDF uncertainty (the result is a PDFUncertainty object)
59
+ uncertainty = cpdf_set.Uncertainty(pdfxtmd.PartonFlavor.u, x, mu2)
60
+ print(f"Uncertainty: central={uncertainty.central:.6f}, +{uncertainty.errplus:.6f}, -{uncertainty.errminus:.6f}")
61
+
62
+ # 5. Calculate the correlation between two different partons
63
+ correlation = cpdf_set.Correlation(
64
+ pdfxtmd.PartonFlavor.u, x, mu2, # PDF A
65
+ pdfxtmd.PartonFlavor.d, x, mu2 # PDF B
66
+ )
67
+ print(f"Correlation between u and d quarks: {correlation:.4f}")
68
+ ```
69
+
70
+ ### 2\. TMD Uncertainty
71
+
72
+ The interface for TMDs is analogous. Just use `TMDSet` and include the transverse momentum `kt2`.
73
+
74
+ ```python
75
+ import pdfxtmd
76
+
77
+ # 1. Initialize a TMDSet
78
+ tmd_set = pdfxtmd.TMDSet("PB-NLO-HERAI+II-2018-set2")
79
+ print(f"\nLoaded TMD Set: {tmd_set.info().get_string('SetDesc')} with {len(tmd_set)} members.")
80
+
81
+ # 2. Define kinematics
82
+ x = 0.01
83
+ mu2 = 100
84
+ kt2 = 10
85
+
86
+ # 3. Calculate the TMD uncertainty
87
+ uncertainty_tmd = tmd_set.Uncertainty(pdfxtmd.PartonFlavor.g, x, kt2, mu2)
88
+ print(f"Gluon TMD Uncertainty: central={uncertainty_tmd.central:.6f}, +{uncertainty_tmd.errplus:.6f}, -{uncertainty_tmd.errminus:.6f}")
89
+ ```
90
+
91
+ -----
92
+
93
+ ## Low-Level API: Factories
94
+
95
+ 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.
96
+
97
+ ```python
98
+ import pdfxtmd
99
+
100
+ x = 0.01
101
+ mu2 = 100
102
+ kt2 = 10
103
+
104
+ # --- Collinear PDFs (cPDF) using Factory ---
105
+ cpdf_factory = pdfxtmd.GenericCPDFFactory()
106
+ cpdf = cpdf_factory.mkCPDF("CT18NLO", 0) # Get member 0
107
+
108
+ # Evaluate a single flavor
109
+ up_pdf = cpdf.pdf(pdfxtmd.PartonFlavor.u, x, mu2)
110
+ print(f"CPDF (Up Quark) from Factory: {up_pdf:.6f}")
111
+
112
+ # Evaluate all flavors at once (returns a numpy array)
113
+ all_flavors_cpdf = cpdf.pdf(x, mu2)
114
+ print(f"All CPDF Flavors from Factory: {all_flavors_cpdf}")
115
+
116
+
117
+ # --- TMDs using Factory ---
118
+ tmd_factory = pdfxtmd.GenericTMDFactory()
119
+ tmd = tmd_factory.mkTMD("PB-NLO-HERAI+II-2018-set2", 0) # Get member 0
120
+
121
+ # Evaluate a single flavor
122
+ gluon_tmd = tmd.tmd(pdfxtmd.PartonFlavor.g, x, kt2, mu2)
123
+ print(f"\nTMD (Gluon) from Factory: {gluon_tmd:.6f}")
124
+
125
+ # Evaluate all TMD flavors at once (returns a numpy array)
126
+ all_flavors_tmd = tmd.tmd(x, kt2, mu2)
127
+ print(f"All TMD Flavors from Factory: {all_flavors_tmd}")
128
+ ```
129
+
130
+ -----
131
+
132
+ ## QCD Coupling ($\alpha_s$) Calculations
133
+
134
+ You can calculate the strong coupling constant $\alpha_s$ in two ways.
135
+
136
+ ```python
137
+ import pdfxtmd
138
+
139
+ cpdf_set = pdfxtmd.CPDFSet("CT18NLO")
140
+
141
+ # Method A: Directly from the PDFSet object (Recommended)
142
+ print("--- Method A: From PDFSet ---")
143
+ alpha_s_from_set = cpdf_set.alphasQ2(10000)
144
+ print(f"Alpha_s at mu2=10000: {alpha_s_from_set:.5f}")
145
+
146
+
147
+ # Method B: Using the low-level CouplingFactory
148
+ print("\n--- Method B: From CouplingFactory ---")
149
+ coupling_factory = pdfxtmd.CouplingFactory()
150
+ coupling = coupling_factory.mkCoupling("CT18NLO")
151
+ alpha_s_from_factory = coupling.AlphaQCDMu2(10000)
152
+ print(f"Alpha_s at mu2=10000: {alpha_s_from_factory:.5f}")
153
+ ```
154
+
155
+ -----
156
+
157
+ ## Complete Example: Plotting PDFs with Uncertainties
158
+
159
+ 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`.
160
+
161
+ ```python
162
+ import pdfxtmd
163
+ import numpy as np
164
+ import matplotlib.pyplot as plt
165
+
166
+ # --- Part 1: Collinear PDF (cPDF) ---
167
+ cpdf_set = pdfxtmd.CPDFSet("CT18NLO")
168
+ print(f"Loaded cPDF set: {cpdf_set.info().get_string('SetDesc')}")
169
+
170
+ x_values = np.logspace(-4, -1, 100)
171
+ mu2 = 1000
172
+
173
+ # Calculate central values and uncertainties
174
+ uncertainties = [cpdf_set.Uncertainty(pdfxtmd.PartonFlavor.g, x, mu2) for x in x_values]
175
+ central_pdfs = [u.central for u in uncertainties]
176
+ upper_band = [u.central + u.errplus for u in uncertainties]
177
+ lower_band = [u.central - u.errminus for u in uncertainties]
178
+
179
+ # Plot the cPDF
180
+ plt.figure(figsize=(10, 6))
181
+ plt.plot(x_values, central_pdfs, label='Gluon PDF (CT18NLO)', color='blue')
182
+ plt.fill_between(x_values, lower_band, upper_band, color='blue', alpha=0.2, label='68% CL Uncertainty')
183
+ plt.xscale('log')
184
+ plt.xlabel('$x$')
185
+ plt.ylabel('$xg(x, \mu^2)$')
186
+ plt.title(f'Gluon PDF with Uncertainty at $\mu^2 = {mu2} \ GeV^2$')
187
+ plt.legend()
188
+ plt.grid(True, which="both", ls="--")
189
+ plt.savefig('gluon_pdf_plot.png')
190
+ print("Saved plot to gluon_pdf_plot.png")
191
+ plt.close()
192
+
193
+
194
+ # --- Part 2: Transverse Momentum-Dependent PDF (TMD) ---
195
+ tmd_set = pdfxtmd.TMDSet("PB-LO-HERAI+II-2020-set2")
196
+ print(f"Loaded TMD set: {tmd_set.info().get_string('SetDesc')}")
197
+
198
+ kt2 = 1
199
+
200
+ # Calculate central values and uncertainties
201
+ tmd_uncertainties = [tmd_set.Uncertainty(pdfxtmd.PartonFlavor.g, x, kt2, mu2) for x in x_values]
202
+ central_tmds = [u.central for u in tmd_uncertainties]
203
+ tmd_upper_band = [u.central + u.errplus for u in tmd_uncertainties]
204
+ tmd_lower_band = [u.central - u.errminus for u in tmd_uncertainties]
205
+
206
+ # Plot the TMD
207
+ plt.figure(figsize=(10, 6))
208
+ plt.plot(x_values, central_tmds, label='Gluon TMD (PB-LO-2020)', color='green')
209
+ plt.fill_between(x_values, tmd_lower_band, tmd_upper_band, color='green', alpha=0.2, label='68% CL Uncertainty')
210
+ plt.xscale('log')
211
+ plt.xlabel('$x$')
212
+ plt.ylabel('$xg(x, k_t^2, \mu^2)$')
213
+ plt.title(f'Gluon TMD with Uncertainty at $k_t^2 = {kt2} \ GeV^2, \mu^2 = {mu2} \ GeV^2$')
214
+ plt.legend()
215
+ plt.grid(True, which="both", ls="--")
216
+ plt.savefig('gluon_tmd_plot.png')
217
+ print("Saved plot to gluon_tmd_plot.png")
218
+ plt.close()
219
+ ```
220
+
221
+ -----
222
+
223
+ ## Additional Information
224
+
225
+ ### Error Handling
226
+
227
+ The API raises a `RuntimeError` for invalid kinematic inputs.
228
+
229
+ ```python
230
+ try:
231
+ cpdf.pdf(pdfxtmd.PartonFlavor.u, -0.1, mu2) # Invalid x
232
+ except RuntimeError as e:
233
+ print(f"Caught expected error for invalid x: {e}")
234
+ ```
235
+
236
+ ### Enumerating Parton Flavors
237
+
238
+ You can inspect all available parton flavors and their integer codes.
239
+
240
+ ```python
241
+ print("\n--- All PartonFlavor enum values ---")
242
+ for name, flavor in pdfxtmd.PartonFlavor.__members__.items():
243
+ print(f" {name}: {flavor.value}")
244
+ ```
245
+
246
+ ### Full Code Examples
247
+
248
+ For more detailed examples, see the full tutorials in the project repository:
249
+
250
+ * [python\_tutorial.py](https://www.google.com/search?q=examples/python/python_tutorial.py)
251
+ * [Jupyter Notebook Tutorial (run online)](https://www.google.com/search?q=https://colab.research.google.com/drive/1C_h9oGJJzt5h3m-h6o3lAJ5dl-AVv0j3)
252
+
253
+ -----
254
+
255
+ ## License
256
+
257
+ This project is licensed under the GNU General Public License v3.0. See the `LICENSE` file for details.
258
+
259
+ ## Contact
260
+
261
+ For questions or contributions, please contact [raminkord92@gmail.com](mailto:raminkord92@gmail.com).
@@ -0,0 +1,6 @@
1
+ pdfxtmd.cp38-win_amd64.pyd,sha256=1ttV6jgZmR313wvbj-PYV-UJmQuBVSKI2T_xcMt89Y0,686080
2
+ pdfxtmd-1.0.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
+ pdfxtmd-1.0.0.dist-info/METADATA,sha256=34AsE5gtQLqBceBuBku4fxTAaGofO04xInOtKyhisug,8656
4
+ pdfxtmd-1.0.0.dist-info/WHEEL,sha256=2M046GvC9RLU1f1TWyM-2sB7cRKLhAC7ucAFK8l8f24,99
5
+ pdfxtmd-1.0.0.dist-info/top_level.txt,sha256=Txg3I6UFaHGSNU9rzKh01hDSldU__3I_tnEY_LwvR5U,42
6
+ pdfxtmd-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Common
2
+ Implementation
3
+ Uncertainty
4
+ pdfxtmd
Binary file
@@ -1,5 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pdfxtmd
3
- Version: 0.3.0
4
- License-File: LICENSE
5
-
@@ -1,6 +0,0 @@
1
- pdfxtmd.cp38-win_amd64.pyd,sha256=ZTg4nYQUV9MANKqaw-D11wT7N3--aTb9Z_42otHBa5o,460288
2
- pdfxtmd-0.3.0.dist-info/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
3
- pdfxtmd-0.3.0.dist-info/METADATA,sha256=vl9qyErT-zDVWwQE46d6kjk5sSnY8_Xqn3GGDE857zI,79
4
- pdfxtmd-0.3.0.dist-info/WHEEL,sha256=2M046GvC9RLU1f1TWyM-2sB7cRKLhAC7ucAFK8l8f24,99
5
- pdfxtmd-0.3.0.dist-info/top_level.txt,sha256=w0BAo-du9KuBSdf2omVP6cG2wuwZYUfycMtlU9obMus,8
6
- pdfxtmd-0.3.0.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- pdfxtmd