|
38 | 38 |
|
39 | 39 | #Constants
|
40 | 40 | h = const.physical_constants["Planck constant in eV/Hz"][0]
|
| 41 | +hJ = const.physical_constants["Planck constant"][0] |
41 | 42 | hbar = h/(2*np.pi)
|
42 | 43 | kb = const.physical_constants["Boltzmann constant in eV/K"][0]
|
43 | 44 | kbJ = const.physical_constants["Boltzmann constant"][0]
|
44 | 45 | Na = const.physical_constants["Avogadro constant"][0]
|
45 | 46 | eV2J = const.eV
|
46 |
| - |
| 47 | +J2eV = 6.242E18 |
47 | 48 |
|
48 | 49 | #--------------------------------------------------------------------
|
49 | 50 | # TI PATH INTEGRATION ROUTINES
|
@@ -469,64 +470,96 @@ def get_einstein_crystal_fe(
|
469 | 470 | calc,
|
470 | 471 | vol,
|
471 | 472 | k,
|
472 |
| - cm_correction=True): |
| 473 | + cm_correction=True, |
| 474 | + return_contributions=False): |
473 | 475 | """
|
474 | 476 | Get the free energy of einstein crystal
|
475 | 477 |
|
476 | 478 | Parameters
|
477 | 479 | ----------
|
478 |
| - temp : temperature, float |
479 |
| - units - K |
480 |
| -
|
481 |
| - natoms : int |
482 |
| - no of atoms in the system |
483 |
| -
|
484 |
| - mass : float |
485 |
| - units - g/mol |
| 480 | + calc : Calculation object |
| 481 | + contains all input parameters |
486 | 482 |
|
487 |
| - a : lattice constant, float |
488 |
| - units - Angstrom |
| 483 | + vol : float |
| 484 | + converged volume per atom |
489 | 485 |
|
490 | 486 | k : spring constant, float
|
491 | 487 | units - eV/Angstrom^2
|
492 | 488 |
|
493 | 489 | cm_correction : bool, optional, default - True
|
494 | 490 | add the centre of mass correction to free energy
|
495 | 491 |
|
| 492 | + return_contributions: bool, optional, default - True |
| 493 | + If True, return individual contributions to the reference free energy. |
| 494 | +
|
496 | 495 | Returns
|
497 | 496 | -------
|
498 |
| - fe : float |
499 |
| - free energy of Einstein crystal |
| 497 | + F_tot : float |
| 498 | + total free energy of reference crystal |
| 499 | +
|
| 500 | + F_e : float |
| 501 | + Free energy of Einstein crystal without centre of mass correction. Only if `return_contributions` is True. |
| 502 | +
|
| 503 | + F_cm : float |
| 504 | + centre of mass correction. Only if `return_contributions` is True. |
| 505 | +
|
| 506 | + Notes |
| 507 | + ----- |
| 508 | + The equations for free energy of Einstein crystal and centre of mass correction are from https://doi.org/10.1063/5.0044833. |
500 | 509 |
|
501 | 510 | """
|
502 |
| - #convert mass first for single particle in kg |
503 |
| - mass = np.array([calc._element_dict[x]['mass'] for x in calc.element]) |
504 |
| - mass = (mass/Na)*1E-3 |
505 |
| - natoms = np.sum([calc._element_dict[x]['count'] for x in calc.element]) |
506 |
| - concentration = np.array([calc._element_dict[x]['composition'] for x in calc.element]) |
| 511 | + #temperature |
| 512 | + temp = calc._temperature |
507 | 513 |
|
508 |
| - #convert k from ev/A2 to J/m2 |
509 |
| - k = np.array(k)*(eV2J/1E-20) |
510 |
| - omega = np.sqrt(k/mass) |
| 514 | + #natoms |
| 515 | + natoms = np.sum([calc._element_dict[x]['count'] for x in calc.element]) |
511 | 516 |
|
512 | 517 | #convert a to m3
|
513 | 518 | vol = vol*1E-30
|
514 | 519 |
|
515 |
| - F_harm = 0 |
516 |
| - F_cm = 0 |
| 520 | + #whats the beta |
| 521 | + beta = (1/(kbJ*temp)) |
517 | 522 |
|
518 |
| - for count, om in enumerate(omega): |
519 |
| - if concentration[count] > 0: |
520 |
| - F_harm += concentration[count]*np.log((hbar*om)/(kb*calc._temperature)) |
521 |
| - if cm_correction: |
522 |
| - F_cm += np.log((natoms*concentration[count]/vol)*(2*np.pi*kbJ*calc._temperature/(natoms*concentration[count]*k[count]))**1.5) |
523 |
| - #F_cm = 0 |
524 |
| - F_harm = 3*kb*calc._temperature*F_harm |
525 |
| - F_cm = (kb*calc._temperature/natoms)*F_cm |
526 |
| - |
527 |
| - F_harm = F_harm + F_cm |
| 523 | + #create an array of mass |
| 524 | + mass = [] |
| 525 | + for x in calc.element: |
| 526 | + for count in range(calc._element_dict[x]['count']): |
| 527 | + mass.append(calc._element_dict[x]['mass']) |
| 528 | + mass = np.array(mass) |
| 529 | + |
| 530 | + #convert mass to kg |
| 531 | + mass = (mass/Na)*1E-3 |
528 | 532 |
|
529 |
| - return F_harm |
| 533 | + #create an array of k as well |
| 534 | + karr = [] |
| 535 | + for c, x in enumerate(calc.element): |
| 536 | + for count in range(calc._element_dict[x]['count']): |
| 537 | + karr.append(k[c]) |
| 538 | + k = np.array(karr) |
| 539 | + #convert k from ev/A2 to J/m2 |
| 540 | + k = k*(eV2J/1E-20) |
| 541 | + |
| 542 | + #fe of Einstein crystal |
| 543 | + Z_e = ((beta**2*k*hJ**2)/(4*np.pi**2*mass))**1.5 |
| 544 | + F_e = np.log(Z_e) |
| 545 | + F_e = kb*temp*np.sum(F_e)/natoms #*J2eV #convert back to eV |
| 546 | + |
| 547 | + #now get the cm correction |
| 548 | + if cm_correction: |
| 549 | + mass_sum = np.sum(mass) |
| 550 | + mu = mass/mass_sum |
| 551 | + mu2_over_k = mu**2/k |
| 552 | + mu2_over_k_sum = np.sum(mu2_over_k) |
| 553 | + prefactor = vol |
| 554 | + F_cm = np.log(prefactor*(beta/(2*np.pi*mu2_over_k_sum))**1.5) |
| 555 | + F_cm = kb*temp*F_cm/natoms #convert to eV |
| 556 | + else: |
| 557 | + F_cm = 0 |
| 558 | + |
| 559 | + F_tot = F_e - F_cm |
| 560 | + if return_contributions: |
| 561 | + return F_e, -F_cm |
| 562 | + return F_tot |
530 | 563 |
|
531 | 564 | #--------------------------------------------------------------------
|
532 | 565 | # REF. STATE ROUTINES: LIQUID
|
|
0 commit comments