# -*- coding: utf-8 -*-
"""Round 257: batch add 5 Physics PhD (Canadian 4 + UChicago Astronomy)
- UofT Physics PhD (Dec 12, 2026; GRE not required; $125 CAD fee; 2 LOR; direct-entry PhD no supervisor needed before arrival but PhD registration requires supervisor; Sept intake; TOEFL 93)
- UBC Physics PhD (Dec 1, 2026; GRE not required; direct PhD requires MSc/MASc 80%+ AND firm supervisor commitment before admission; international students without PhD supervisor commitment considered as MSc applicant; Sept intake opens Oct 15)
- McGill Physics PhD (Dec 15, 2026 Fall; GRE recommended but not required; min 3.0/4.0 GPA; SCIR 716/717 PhD1 research courses; PHYS 700 Preliminary Exam; research at Argonne/CERN/FermiLab/SLAC/TRIUMF)
- Waterloo Physics PhD (Jan 9 for Sept; Master's in Physics 75%+; Physics Subject GRE optional due to COVID-19 for non-Canadian post-secondary; 3 academic references; TOEFL 90 W25 S25 / IELTS 7.0 W6.5 S6.5; must contact supervisor with 500-word statement; 48 months thesis-based; ties to Perimeter Institute)
- UChicago Astronomy PhD (Dec 1, 2026 11:59pm EST; GRE not required but optional; TOEFL 90 / IELTS 7.0; $90 fee waivable; 3 LOR; personal statement + CV; Magellan Telescopes Chile access; Chicago-Carnegie Brinson predoctoral program; SEPARATE from UChicago Physics PhD Dec 14)
Key finding: Canadian 4 schools all require supervisor agreement before offer (Canadian model). UChicago splits Physics (Dec 14, Physics GRE required) vs Astronomy (Dec 1, GRE optional).
"""
import os, re

BASE = os.path.dirname(os.path.abspath(__file__))
DET = os.path.join(BASE, "details")
os.makedirs(DET, exist_ok=True)

PROGRAMS = [
    {
        "id": "ut-physics-phd",
        "s": "ut",
        "n": "物理博士",
        "en": "PhD in Physics (University of Toronto, Faculty of Arts and Science, Department of Physics; located in Toronto, Canada; PhD registration requires supervisor secured; direct-entry PhD does not require supervisor prior to arrival; Sept intake primarily; January start uncommon and only for domestic students pursuing four-year PhD)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5 years (direct-entry from undergraduate) or 4 years (after master's); core of PhD is original investigation embodied in thesis; lecture courses subsidiary but important; September start aligned with funding priorities and course sequence; January start uncommon (not more than one student per year, domestic only); on-campus residential (Toronto, Canada)",
        "ddl": "Fall 2027 (September matriculation): **Deadline December 12, 2026** per Department of Physics Application Procedure. Application opens October 7, 2026. Application fee $125 CAD. All application materials including reference letters must be submitted to online portal by December 12. Students with major external scholarships (NSERC, OGS, Commonwealth) may apply after December 12 case-by-case. January start deadline August 1, 2026 (domestic only).",
        "lang": "TOEFL iBT minimum 93 per PhDportal and School of Graduate Studies General Regulations section 4.3. Applicants whose primary language is not English and who graduated from a university where language of instruction and examination was not English must demonstrate proficiency. ETS institution code for University of Toronto.",
        "test": {"cls": "GRE NOT REQUIRED (UofT Physics FAQ: 'There is no requirement to take these examinations.' General GRE and Subject GRE both not required. Required materials: online application, $125 CAD fee, two reference letters (no more than two permitted), transcripts. Students with degrees in related fields (Astronomy, Engineering Physics, Mathematics) also admitted.)"},
        "tui": "University of Toronto Physics PhD students receive competitive funding package. Pre-doctoral Summer Research Program available for incoming MSc and PhD students. Department is a major research center with strong theoretical and experimental programs in condensed matter, astrophysics, biophysics, high energy physics, quantum optics, and medical physics. Note: Students admitted to the MSc and direct-entry PhD programs are not required to secure a supervisor prior to arrival; students admitted to the PhD program are required to secure a supervisor prior to registration.",
        "url": "details/ut-physics-phd.html",
    },
    {
        "id": "ubc-physics-phd",
        "s": "ubc",
        "n": "物理博士",
        "en": "PhD in Physics (University of British Columbia, Faculty of Science, Department of Physics and Astronomy; located in Vancouver, Canada; direct PhD admission requires firm commitment of research supervision from faculty member; international students without PhD supervisor commitment considered as MSc applicant; Sept 2027 intake opens Oct 15, 2026)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 4-5 years after master's; research-based degree with thesis; minimum M.Sc. or M.A.Sc. in physics, astronomy, or mathematics with average grade at least 80%; direct admission to PhD requires firm commitment of research supervision from faculty; alternative path: students with master's from outside Canada can be admitted into UBC MSc program then transfer to PhD once supervisor secured; on-campus residential (Vancouver, Canada)",
        "ddl": "Fall 2027 (September matriculation): **Application deadline December 1, 2026** (same for Canadian and International applicants) per UBC Graduate School program listing. Application opens October 15, 2026. Transcript deadline December 15, 2026. Referee deadline December 31, 2026. January 2028 intake also available.",
        "lang": "TOEFL iBT minimum overall 90 with Speaking 120 / Listening 115 (per UBC Graduate School English proficiency); IELTS Academic minimum overall 6.5 with each band no less than 6.0. ETS institution code for UBC. Official scores required.",
        "test": {"cls": "GRE NOT REQUIRED (UBC Graduate School program listing: 'The GRE is not required.' Required materials: online application, transcripts, letters of reference, statement of interest, CV. CRITICAL: Direct admission to PhD additionally requires student to secure a firm commitment of research supervision from a faculty member. International students who cannot secure commitment of PhD adviser will be considered as MSc applicant - it is much easier to secure longer-term commitment once on-campus taking classes and interning in research group."},
        "tui": "UBC Physics PhD students receive competitive funding package including tuition, stipend, and health insurance. Department is a major research center in Vancouver with strengths in condensed matter, astrophysics, biophysics, AMO, high energy physics, and gravity/wave cosmology. CRITICAL CANADIAN MODEL: Direct admission to PhD requires faculty supervisor firm commitment before admission; international students without PhD supervisor commitment are considered as MSc applicant. Students should contact faculty members whose research is of interest about possibility of supervision as soon as possible; admissions process is competitive so supervisor commitment does not guarantee admission.",
        "url": "details/ubc-physics-phd.html",
    },
    {
        "id": "mcg-physics-phd",
        "s": "mcg",
        "n": "物理博士",
        "en": "PhD in Physics (McGill University, Faculty of Science, Department of Physics; located in Montreal, Canada; research strengths in astronomy, high energy physics, condensed matter, materials science, biophysics; off-campus research at MUHC, Jewish General Hospital, MNI, Argonne, CERN, FermiLab, SLAC, TRIUMF; SCIR 716/717 PhD1 research courses)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 4-5 years; PhD1 students required to register in two consecutive research courses during first Fall and Winter terms: SCIR 716 (first term) followed by SCIR 717 (second term); PHYS 700 Preliminary PhD Examination; thesis must focus on research in area related to one of Department's research groups and produce original contributions to scholarship; on-campus residential (Montreal, Canada); Fall and Winter intakes",
        "ddl": "Fall 2027 (September matriculation): **Application deadline December 15, 2026** (same for International and Canadian/Domestic applicants) per McGill Future Graduate Students. Applications open September 15, 2026. Winter 2027 intake deadline August 1, 2026. Note: PhD program with research emphasis on medical physics only accepts students in Fall.",
        "lang": "English proficiency required per McGill Graduate and Postdoctoral Studies. McGill is an English-language university in Montreal. TOEFL iBT minimum overall 86 with each component no less than 20 (Writing 20, Speaking 20, Reading 20, Listening 20); IELTS Academic minimum overall 6.5. ETS institution code for McGill. Note: McGill requires institutional email for letters of recommendation (gmail/yahoo/hotmail not accepted).",
        "test": {"cls": "GRE RECOMMENDED BUT NOT REQUIRED (McGill eCalendar: 'GRE - recommended but not required.' University-level admission requirements: eligible Bachelor's degree with minimum 3.0 GPA out of 4.0. Required materials: online application, transcripts, personal statement, CV, thesis abstract or summary (optional), letters of recommendation (institutional email). Both local and international students receive competitive funding package."},
        "tui": "McGill Physics PhD students receive competitive funding package including tuition, stipend, and health insurance. Both local and international students receive competitive funding package. Research may also be conducted off campus at the McGill University Health Centre (MUHC), the Jewish General Hospital, the Montreal Neurological Institute (MNI), and laboratories around the world including Argonne, CERN, FermiLab, SLAC, TRIUMF, and K. Thesis must constitute original scholarship and be distinct contribution to knowledge. PhD1 students register SCIR 716 first Fall and SCIR 717 second Winter. PHYS 700 Preliminary PhD Examination required.",
        "url": "details/mcg-physics-phd.html",
    },
    {
        "id": "uw-physics-phd",
        "s": "uw",
        "n": "物理博士",
        "en": "PhD in Physics (University of Waterloo, Faculty of Science, Department of Physics and Astronomy; located in Waterloo, Canada; one of largest physics and astronomy graduate programs in Canada; close ties to Perimeter Institute; 48 months full-time thesis-based; supervisor matching required before admission)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 48 months full-time thesis-based; normally Master's degree in Physics with at least 75% standing; undergraduate students with outstanding record may apply directly to PhD; 3 academic references; Supplementary Information Form (SIF); PhD Advisory Committee must consist of at least 4 members (supervisor, at least one regular faculty of Waterloo Physics and Astronomy, at least two regular/adjunct/cross-listed faculty); on-campus residential (Waterloo, Canada); Fall, Winter, Spring intakes",
        "ddl": "Fall 2027 (September matriculation): **Application deadline January 9, 2027** per Waterloo Department of Physics and Astronomy. Other intake deadlines: June 1 for January admission of following year; October 1 for May admission of following year. Supplementary Information Form required.",
        "lang": "TOEFL iBT minimum overall 90 with Writing 25 and Speaking 25; IELTS Academic minimum overall 7.0 with Writing 6.5 and Speaking 6.5. ELP required if schooling completed outside Canada and not in English-speaking country. ETS institution code for University of Waterloo.",
        "test": {"cls": "GRE PHYSICS SUBJECT OPTIONAL (Waterloo Physics & Astronomy: 'Graduate Record Examination (GRE) Physics subject test scores for all students who have completed their post-secondary education outside of Canada. Due to COVID-19, the Physics subject GRE test requirement is optional for admission. You may choose to include the results of GRE tests if you have taken them, but the tests are not required for admission.' Required: online application, transcripts, 3 academic references, Supplementary Information Form (SIF), proof of English language proficiency. CRITICAL: Must contact potential supervisor with 500-word statement on why want to work with this faculty, status in Canada, research interest, previous degree and GPA."},
        "tui": "Waterloo Physics PhD students receive funding covering tuition and stipend. One of largest physics and astronomy graduate programs in Canada; department tradition of collaboration and innovations. Students work closely with supervisor to perform original research culminating in PhD thesis. CRITICAL: close ties to Perimeter Institute for Theoretical Physics in Waterloo; PhD Advisory Committee may include Perimeter Institute faculty with Approved Doctoral Dissertation Supervisor (ADDS) status. Accelerated Doctoral Program in Physics available for exceptional MSc students (preliminary research proposal acceptable to committee and Associate Chair, Graduate Studies; completion of at least two graduate level courses with grade at least 80%).",
        "url": "details/uw-physics-phd.html",
    },
    {
        "id": "uchicago-astro-phd",
        "s": "uchicago",
        "n": "天文与天体物理博士",
        "en": "PhD in Astrophysics (University of Chicago, Physical Sciences Division, Department of Astronomy and Astrophysics; located in Chicago, IL; guaranteed access to Magellan Telescopes at Las Campanas Observatory in Chile; Chicago-Carnegie Brinson predoctoral program partnership with Carnegie Observatories; SEPARATE from UChicago Physics PhD deadline Dec 14)",
        "deg": "PhD",
        "lvl": "d",
        "stem": 1,
        "dur": "Typically 5-6 years; leading to PhD in Astrophysics; students typically have strong backgrounds in Physical Sciences and Mathematics; research opportunities across observational, theoretical, and computational astrophysics; access to Magellan Telescopes at Las Campanas Observatory in Chile; Chicago-Carnegie Brinson predoctoral program allows year at Carnegie Observatories; on-campus residential (Chicago, IL); Fall admission",
        "ddl": "Fall 2027-2028: **Deadline December 1, 2026 at 11:59 PM EST** per Department of Astronomy and Astrophysics How to Apply. Application fee $90 (may be waived if applicant meets Physical Sciences Division fee waiver criteria). NOTE: This entry is Astronomy PhD; UChicago Physics PhD deadline is December 14, 2026 (with Physics GRE required for 2026-27 cycle).",
        "lang": "TOEFL iBT minimum 90 overall; IELTS Academic minimum 7.0 overall. Only TOEFL iBT or IELTS Academic accepted as proof of proficiency (per Department of Astronomy and Astrophysics). Applicants who do not meet waiver criteria must submit proof. ETS institution code 1832.",
        "test": {"cls": "GRE NOT REQUIRED BUT OPTIONAL (UChicago Department of Astronomy and Astrophysics: 'GRE scores are not required but may be submitted optionally.' Required materials: personal statement, 3 letters of recommendation, college transcript(s), CV or resume of past accomplishments. ETS institution code 1832. No minimum GRE score. NOTE: UChicago Physics PhD (separate program) REQUIRES Physics GRE for 2026-27 cycle; Astronomy PhD does NOT require Physics GRE."},
        "tui": "UChicago Astronomy PhD students receive multi-year fully-funded support through research assistantships, teaching assistantships, and fellowships including tuition, stipend, and health insurance. The Department of Astronomy and Astrophysics is the home of world-leaders in cosmological physics, astroparticle and high-energy physics, and computational astrophysics. Students have guaranteed access to Magellan Telescopes at Las Campanas Observatory in Chile - among the highest per-capita access to 8-m class telescopes in the country. Through Chicago-Carnegie Brinson predoctoral program partnership with Carnegie Observatories, students also have opportunity to spend a year of PhD studies working alongside staff at Carnegie Observatories. Vera C. Rubin First Look, Simons Observatory, and other flagship observational facilities available. NOTE: This entry is Astronomy PhD; UChicago Physics PhD is a separate program with different deadline (Dec 14, 2026) and Physics GRE required.",
        "url": "details/uchicago-astro-phd.html",
    },
]

DETAIL_TEMPLATE = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{school} - {en}</title>
<style>
body{{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;max-width:960px;margin:24px auto;padding:0 20px;color:#222;line-height:1.6}}
h1{{font-size:24px;border-bottom:2px solid #1a73e8;padding-bottom:8px}}
h2{{font-size:18px;color:#1a73e8;margin-top:24px}}
.card{{background:#f8f9fa;border-left:4px solid #1a73e8;padding:12px 16px;margin:12px 0;border-radius:4px}}
.meta{{display:grid;grid-template-columns:120px 1fr;gap:6px 12px;font-size:14px}}
.meta b{{color:#555}}
ul{{margin:6px 0;padding-left:20px}}
.note{{background:#fff3cd;border-left-color:#ffc107;padding:10px 14px;margin-top:16px;font-size:13px}}
a{{color:#1a73e8}}
</style>
</head>
<body>
<h1>{school} - {en}</h1>
<div class="card">
<div class="meta">
<b>Degree</b><span>{deg}</span>
<b>Level</b><span>Research Doctorate (PhD)</span>
<b>STEM</b><span>{stem_label}</span>
<b>Duration</b><span>{dur}</span>
<b>Deadline</b><span>{ddl}</span>
<b>Language</b><span>{lang}</span>
<b>Standardized</b><span>{test_cls}</span>
<b>Funding</b><span>{tui}</span>
</div>
</div>

<h2>Program Overview</h2>
<div class="card">
{overview}
</div>

<h2>Admissions Requirements</h2>
<div class="card">
{requirements}
</div>

<h2>Research Areas</h2>
<div class="card">
{research}
</div>

<h2>Official Source</h2>
<div class="card">
{source}
</div>

<div class="note">
<strong>Note:</strong> Round 257 - Canadian 4 Physics PhD sweep plus UChicago Astronomy PhD (separate track). Key finding: Canadian model requires supervisor agreement before offer at all 4 Canadian schools. UChicago splits Physics (Dec 14, Physics GRE required) vs Astronomy (Dec 1, GRE optional). Important distinctions: (1) UofT Physics Dec 12, 2026; GRE not required; $125 CAD fee; 2 LOR; direct-entry PhD does not require supervisor before arrival but PhD registration requires supervisor secured; Sept intake; TOEFL 93. (2) UBC Physics Dec 1, 2026; GRE not required; direct PhD requires MSc/MASc 80%+ AND firm supervisor commitment; international students without PhD supervisor commitment considered as MSc applicant; Sept 2027 opens Oct 15, 2026. (3) McGill Physics Dec 15, 2026; GRE recommended but not required; min 3.0/4.0 GPA; SCIR 716/717 PhD1 research courses; PHYS 700 Preliminary Exam; research at Argonne/CERN/FermiLab/SLAC/TRIUMF; institutional email LOR required. (4) Waterloo Physics Jan 9 for Sept intake; Master's in Physics 75%+; Physics Subject GRE optional due to COVID-19 for non-Canadian post-secondary; 3 academic references; TOEFL 90 W25 S25 / IELTS 7.0 W6.5 S6.5; must contact supervisor with 500-word statement; 48 months thesis-based; ties to Perimeter Institute. (5) UChicago Astronomy PhD Dec 1, 2026 11:59pm EST; GRE not required but optional; TOEFL 90 / IELTS 7.0; $90 fee waivable; 3 LOR; personal statement + CV; Magellan Telescopes Chile access; Chicago-Carnegie Brinson predoctoral program; SEPARATE from UChicago Physics PhD Dec 14 (which requires Physics GRE).
</div>
</body>
</html>
"""

PAGES = {
    "ut-physics-phd": {
        "school": "University of Toronto, Faculty of Arts and Science, Department of Physics",
        "en": "PhD in Physics",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Physics / CIP 40.0801)",
        "dur": "Typically 5 years direct-entry from undergraduate or 4 years after master's; core is original investigation embodied in thesis; lecture courses subsidiary but important; September start aligned with funding priorities and course sequence; January start uncommon (not more than one student per year, domestic only); on-campus (Toronto, Canada)",
        "ddl": "Fall 2027: **Deadline December 12, 2026**. Application opens October 7, 2026. Application fee $125 CAD. All materials including reference letters due by Dec 12. Major scholarship holders (NSERC, OGS, Commonwealth) may apply after deadline case-by-case. January start deadline August 1 (domestic only).",
        "lang": "TOEFL iBT minimum 93 per SGS General Regulations section 4.3. Required for applicants whose primary language is not English and who graduated from university where language of instruction and examination was not English. ETS institution code for University of Toronto.",
        "test_cls": "GRE NOT REQUIRED (UofT Physics FAQ: 'There is no requirement to take these examinations.' General GRE and Subject GRE both not required. 2 LOR (no more than 2). Related fields (Astronomy, Engineering Physics, Math) also admitted.",
        "tui": "Competitive funding package. Pre-doctoral Summer Research Program for incoming MSc/PhD students. Department is major research center with strong programs in condensed matter, astrophysics, biophysics, high energy, quantum optics, medical physics. Note: direct-entry PhD does not require supervisor prior to arrival; PhD registration requires supervisor secured.",
        "overview": "The University of Toronto Department of Physics, within the Faculty of Arts and Science, offers graduate work leading to the Master of Science and Doctor of Philosophy in Physics. The PhD program is designed to train students in both theoretical and experimental physics at the highest level. The core of the PhD program is an original investigation, the results of which are embodied in a thesis. Lecture courses constitute a subsidiary but important part of the program. CRITICAL POLICY per Department FAQ: Do I need to take the GRE general and subject exams? There is no requirement to take these examinations. We do admit students who hold degrees in fields closely related to Physics (e.g., Astronomy, Engineering Physics, Mathematics, etc.). Only applicants holding a major external scholarship (e.g., NSERC, OGS, Commonwealth Scholarship, etc.) may apply after the December 12th deadline; other late applicants may be deferred to the next round of selection, one year later. Do you accept students for January admission instead of September? Not normally. Due to funding priorities and the sequence in which graduate courses are offered, the MSc and PhD programs are aligned with a September start. A January start is uncommon (not more than one student per year) and available only to domestic applicants who wish to pursue a four-year PhD program. This varies between the MSc program and the PhD program. Students admitted to the MSc and direct-entry PhD programs are not required to secure a supervisor prior to arrival. Students admitted to the PhD program are required to secure a supervisor prior to registration. Per the School of Graduate Studies: Applicants may enter the PhD program via one of two routes: (1) following completion of an appropriate master's degree; or (2) direct entry from undergraduate. An appropriate University of Toronto master's degree with average at least B+ or demonstrated comparable research competence. Outstanding applicants may be considered directly from undergraduate programs; normally these applicants will have an undergraduate average of A or higher. The application deadline is December 12th. Application opens October 7th. Application fee $125 CAD. Two reference letters are required; no more than two reference letters are permitted. The department is located in Toronto, Canada.",
        "requirements": "<ul><li>Bachelor's degree in physics or related quantitative field (Astronomy, Engineering Physics, Mathematics also admitted)</li><li>Master's route: appropriate UofT master's degree with average at least B+</li><li>Direct-entry PhD: undergraduate average A or higher (outstanding applicants)</li><li>GRE General: NOT required</li><li>GRE Physics Subject: NOT required</li><li>TOEFL iBT minimum 93</li><li>Required for applicants whose primary language is not English</li><li>ETS institution code for University of Toronto</li><li>SGS online application</li><li>Application fee $125 CAD</li><li>2 reference letters (no more than 2 permitted)</li><li>Transcripts</li><li>**Deadline December 12, 2026** for September admission</li><li>Application opens October 7, 2026</li><li>Major external scholarship holders (NSERC/OGS/Commonwealth) may apply after deadline</li><li>January start deadline August 1 (domestic only, max 1 student/year)</li><li>September start aligned with funding priorities and course sequence</li><li>Direct-entry PhD: supervisor not required prior to arrival</li><li>PhD program: supervisor must be secured prior to registration</li><li>Pre-doctoral Summer Research Program available for incoming students</li><li>Competitive funding package</li><li>On-campus residential (Toronto, Canada)</li></ul>",
        "research": "<ul><li>Condensed matter physics</li><li>Astrophysics</li><li>Biophysics</li><li>High energy physics</li><li>Quantum optics</li><li>Medical physics</li><li>Particle physics</li><li>Atomic, molecular, and optical physics</li><li>Statistical physics</li><li>Interdisciplinary research with UofT departments of astronomy, chemistry, engineering, medicine</li></ul>",
        "source": '<a href="https://www.physics.utoronto.ca/graduate/prospective-students/graduate-admissions-department-physics/application-procedure/" target="_blank">UofT Physics Application Procedure (application opens Oct 7; deadline Dec 12; $125 CAD fee; 2 reference letters; GRE not required; major scholarship holders may apply after deadline; January start domestic only)</a> | <a href="https://www.physics.utoronto.ca/graduate/prospective-students/graduate-admissions-department-physics/frequently-asked-questions/" target="_blank">UofT Physics FAQ (no requirement to take GRE general and subject; admit students from related fields; only external scholarship holders may apply after Dec 12; January start uncommon domestic only; direct-entry PhD no supervisor needed before arrival; PhD program requires supervisor before registration)</a> | <a href="https://www.sgs.utoronto.ca/programs/physics/" target="_blank">UofT School of Graduate Studies: Physics PhD (two entry routes: after master\'s B+ or direct-entry undergraduate A; English proficiency per SGS General Regulations section 4.3; core is original investigation embodied in thesis)</a> | <a href="https://www.physics.utoronto.ca/graduate/prospective-students/graduate-admissions-department-physics/application-information/" target="_blank">UofT Physics Key Dates and Deadlines (application opens Oct 7; Dec 12 deadline all materials; Jan start Aug 1 deadline domestic only; entirely online application; no paper forms)</a>',
    },
    "ubc-physics-phd": {
        "school": "University of British Columbia, Faculty of Science, Department of Physics and Astronomy",
        "en": "PhD in Physics",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Physics / CIP 40.0801; Astronomy / CIP 40.0201)",
        "dur": "Typically 4-5 years after master's; research-based with thesis; minimum M.Sc. or M.A.Sc. in physics, astronomy, or mathematics with average grade at least 80%; direct admission to PhD requires firm commitment of research supervision from faculty; on-campus (Vancouver, Canada); September intake primarily",
        "ddl": "Fall 2027 (September matriculation): **Application deadline December 1, 2026** (same for Canadian and International). Application opens October 15, 2026. Transcript deadline December 15, 2026. Referee deadline December 31, 2026. January 2028 intake also available.",
        "lang": "TOEFL iBT minimum overall 90 with Speaking 120 / Listening 115 per UBC Graduate School English proficiency; IELTS Academic minimum overall 6.5 with each band no less than 6.0. ETS institution code for UBC.",
        "test_cls": "GRE NOT REQUIRED (UBC Graduate School program listing: 'The GRE is not required.' CRITICAL: Direct admission to PhD additionally requires firm commitment of research supervision from faculty member. International students without PhD supervisor commitment considered as MSc applicant - easier to secure commitment once on-campus.)",
        "tui": "Competitive funding package including tuition, stipend, and health insurance. Major research center in Vancouver. CANADIAN MODEL: Direct PhD admission requires faculty supervisor firm commitment before admission; international students without PhD supervisor commitment are considered as MSc applicant. Students should contact faculty members whose research is of interest about possibility of supervision as soon as possible; admissions process is competitive so supervisor commitment does not guarantee admission.",
        "overview": "The University of British Columbia Department of Physics and Astronomy, within the Faculty of Science, offers graduate work leading to the Doctor of Philosophy in Physics. The minimum academic requirement for direct admission to the PhD program is an M.Sc. or M.A.Sc. in physics, astronomy or mathematics with an average grade of at least 80%. CRITICAL CANADIAN MODEL: Direct admission to the PhD program additionally requires the student to secure a firm commitment of research supervision from a faculty member. PhD applicants should contact faculty members whose research is of interest to them about the possibility of supervision as soon as possible. The admissions process is competitive, thus the commitment of a supervisor does not guarantee admission to the program. Alternatively, students who already have a master's degree from outside Canada can be admitted into UBC's M.Sc. program, then transfer to the Ph.D. program once they secure the commitment of a research supervisor. Per the Department: It is your responsibility to contact potential advisers and reach an agreement. This process can be challenging for international applicants, because it is difficult for a research adviser to make a 4-year funding commitment to an unknown student. If you are an international student who cannot secure the commitment of a PhD adviser, you will be considered as an MSc applicant. If you are admitted to the MSc program, it will be much easier to secure the longer-term commitment of a PhD adviser once you are on-campus, taking classes, and interning in a research group. Per UBC Graduate School: September 2027 Intake application opens October 15, 2026. Canadian and International applicants both have application deadline December 1, 2026; transcript deadline December 15, 2026; referee deadline December 31, 2026. The GRE is not required. Students in research-based programs usually require a faculty member to function as their thesis supervisor. The department is located in Vancouver, Canada.",
        "requirements": "<ul><li>Minimum M.Sc. or M.A.Sc. in physics, astronomy, or mathematics with average grade at least 80%</li><li>**CRITICAL: Direct admission to PhD requires firm commitment of research supervision from faculty member**</li><li>International students without PhD supervisor commitment: considered as MSc applicant</li><li>Alternative: admit to MSc then transfer to PhD once supervisor secured</li><li>GRE: NOT required</li><li>TOEFL iBT minimum overall 90 (Speaking 120 / Listening 115)</li><li>IELTS Academic minimum overall 6.5 (each band no less than 6.0)</li><li>ETS institution code for UBC</li><li>UBC Graduate and Postdoctoral Studies online application</li><li>Transcripts</li><li>Letters of reference</li><li>Statement of interest</li><li>CV</li><li>**Application deadline December 1, 2026** (Canadian and International same)</li><li>Application opens October 15, 2026</li><li>Transcript deadline December 15, 2026</li><li>Referee deadline December 31, 2026</li><li>January 2028 intake also available</li><li>Contact faculty members whose research is of interest as soon as possible</li><li>Supervisor commitment does not guarantee admission (competitive process)</li><li>Competitive funding package</li><li>On-campus residential (Vancouver, BC, Canada)</li></ul>",
        "research": "<ul><li>Condensed matter physics</li><li>Astrophysics and astronomy</li><li>Biophysics</li><li>Atomic, molecular, and optical physics</li><li>High energy physics</li><li>Gravity and wave cosmology</li><li>Quantum physics</li><li>Mathematical physics</li><li>Geophysics (interdisciplinary)</li><li>Interdisciplinary research with UBC departments of chemistry, earth sciences, engineering, astronomy</li></ul>",
        "source": '<a href="https://www.grad.ubc.ca/prospective-students/graduate-degree-programs/phd-physics" target="_blank">UBC Graduate School: PhD in Physics (Sept 2027 opens Oct 15, 2026; Canadian and International deadline Dec 1, 2026; transcript Dec 15; referee Dec 31; GRE not required; TOEFL Speaking 120 / Listening 115; supervision required for research-based programs)</a> | <a href="https://phas.ubc.ca/node/3179/printable/print" target="_blank">UBC Physics & Astronomy Graduate Program Prospective Students (minimum MSc/MASc in physics/astronomy/math 80%; direct PhD requires firm supervisor commitment; international students without PhD supervisor considered as MSc applicant; alternative: admit MSc then transfer to PhD once supervisor secured)</a> | <a href="https://www.grad.ubc.ca/prospective-students/application-admission" target="_blank">UBC Graduate School Application & Admission (entry to UBC is competitive; meeting minimum requirements not guarantee of admission; English proficiency required for non-Canadian university where English not primary instruction; thesis supervisor required for research-based programs)</a>',
    },
    "mcg-physics-phd": {
        "school": "McGill University, Faculty of Science, Department of Physics",
        "en": "PhD in Physics",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Physics / CIP 40.0801; Astronomy / CIP 40.0201)",
        "dur": "Typically 4-5 years; PhD1 students register SCIR 716 first Fall and SCIR 717 second Winter; PHYS 700 Preliminary PhD Examination; thesis must focus on research in area related to one of Department's research groups and produce original contributions; on-campus (Montreal, Canada); Fall and Winter intakes",
        "ddl": "Fall 2027 (September matriculation): **Application deadline December 15, 2026** (same for International and Canadian/Domestic). Applications open September 15, 2026. Winter 2027 intake deadline August 1, 2026. Note: PhD program with research emphasis on medical physics only accepts students in Fall.",
        "lang": "TOEFL iBT minimum overall 86 (each component no less than 20: Writing 20, Speaking 20, Reading 20, Listening 20); IELTS Academic minimum overall 6.5. ETS institution code for McGill. NOTE: McGill requires institutional email for letters of recommendation (gmail/yahoo/hotmail not accepted).",
        "test_cls": "GRE RECOMMENDED BUT NOT REQUIRED (McGill eCalendar: 'GRE - recommended but not required.' University-level: eligible Bachelor's degree with minimum 3.0 GPA out of 4.0. Required: online application, transcripts, personal statement, CV, thesis abstract or summary (optional), LOR via institutional email.)",
        "tui": "Competitive funding package including tuition, stipend, health insurance. Both local and international students receive competitive funding package. Research may be conducted off campus at MUHC, Jewish General Hospital, MNI, and laboratories around the world including Argonne, CERN, FermiLab, SLAC, TRIUMF, and K. Thesis must constitute original scholarship and distinct contribution to knowledge. PhD1 required to register SCIR 716 (first Fall) and SCIR 717 (second Winter).",
        "overview": "The McGill University Department of Physics, within the Faculty of Science, offers the Doctor of Philosophy in Physics. The PhD in Physics focuses on conducting research in a broad range of fields at the cutting edge of physics, which include but are not limited to astronomy, high energy physics, condensed matter physics, materials science and biophysics. The thesis must focus on research in an area related to one of the Department's research groups, and must produce original contributions to scholarship. Students admitted to PhD1 are required to register in two PhD1 research courses consecutively during their first Fall and Winter terms: SCIR 716 in their first term, followed by SCIR 717 in their second term. A thesis for the doctoral degree must constitute original scholarship and must be a distinct contribution to knowledge. It must show familiarity with previous work in the field and must demonstrate ability to plan and carry out research, organize results, and defend the approach and conclusions in a scholarly manner. The research presented must meet current standards of the discipline; as well, the thesis must clearly demonstrate how the research advances knowledge in the field. Finally, the thesis must be written in compliance with norms for academic and scholarly expression and for publication in the public domain. Per the Future Graduate Students program page: Students receive valuable guidance and develop a network of contacts. Additionally, both local and international students receive a competitive funding package. Research may also be conducted off campus at the McGill University Health Centre (MUHC), the Jewish General Hospital, the Montreal Neurological Institute (MNI), and laboratories around the world including Argonne, CERN, FermiLab, SLAC, TRIUMF, and K. University-level admission requirements: an eligible Bachelor's degree with a minimum 3.0 GPA out of possible 4.0; English-language proficiency. Available intakes: Fall and Winter. Application deadlines: Fall - September 15 open, December 15 deadline (International and Domestic same); Winter - February 15 open, August 1 deadline. The department is located in Montreal, Canada.",
        "requirements": "<ul><li>Eligible Bachelor's degree with minimum 3.0 GPA out of 4.0</li><li>GRE: recommended but not required</li><li>TOEFL iBT minimum overall 86 (each component no less than 20)</li><li>IELTS Academic minimum overall 6.5</li><li>McGill English-language university in Montreal</li><li>**LOR must use institutional email (gmail/yahoo/hotmail not accepted)**</li><li>Online application through McGill Enrolment Services</li><li>Transcripts</li><li>Personal statement</li><li>CV</li><li>Thesis abstract or summary (optional)</li><li>**Fall deadline December 15, 2026** (International and Domestic same)</li><li>Applications open September 15, 2026</li><li>Winter intake deadline August 1, 2026</li><li>Medical physics PhD: Fall only</li><li>PhD1 required to register SCIR 716 first Fall and SCIR 717 second Winter</li><li>PHYS 700 Preliminary PhD Examination required</li><li>Thesis must constitute original scholarship and distinct contribution to knowledge</li><li>Off-campus research at MUHC, Jewish General, MNI, Argonne, CERN, FermiLab, SLAC, TRIUMF</li><li>Competitive funding package (local and international)</li><li>On-campus residential (Montreal, QC, Canada)</li></ul>",
        "research": "<ul><li>Astronomy and astrophysics</li><li>High energy physics</li><li>Condensed matter physics</li><li>Materials science</li><li>Biophysics</li><li>Medical physics (Fall only intake)</li><li>Atomic, molecular, and optical physics</li><li>Off-campus research at MUHC, Jewish General Hospital, MNI</li><li>International laboratories: Argonne, CERN, FermiLab, SLAC, TRIUMF</li><li>Interdisciplinary research with McGill departments of chemistry, biology, medicine, engineering</li></ul>",
        "source": '<a href="https://www.mcgill.ca/gradapplicants/program/physics-phd" target="_blank">McGill Future Graduate Students: Physics PhD (Fall deadline Dec 15; Winter deadline Aug 1; Sept 15 open; min 3.0/4.0 GPA; English proficiency; competitive funding; off-campus research at MUHC/Jewish General/MNI/Argonne/CERN/FermiLab/SLAC/TRIUMF)</a> | <a href="https://coursecatalogue.mcgill.ca/en/graduate/science/physics/physics-phd/" target="_blank">McGill Course Catalogue: Physics PhD (research in astronomy, high energy, condensed matter, materials science, biophysics; PhD1 SCIR 716 first Fall + SCIR 717 second Winter; PHYS 700 Preliminary PhD Exam; thesis must constitute original scholarship and distinct contribution to knowledge)</a> | <a href="https://www.mcgill.ca/study/2018-2019/faculties/science/graduate/gps_sci_physics" target="_blank">McGill eCalendar: Physics (GRE recommended but not required; Fall deadline Dec 15; Winter deadline Sept 10; medical physics PhD Fall only; competitive admission; late applications not accepted)</a>',
    },
    "uw-physics-phd": {
        "school": "University of Waterloo, Faculty of Science, Department of Physics and Astronomy",
        "en": "PhD in Physics",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Physics / CIP 40.0801; Astronomy / CIP 40.0201)",
        "dur": "48 months full-time thesis-based; normally Master's degree in Physics with at least 75% standing; undergraduate students with outstanding record may apply directly to PhD; 3 academic references; Supplementary Information Form; PhD Advisory Committee at least 4 members; on-campus (Waterloo, Canada); Fall, Winter, Spring intakes",
        "ddl": "Fall 2027 (September matriculation): **Application deadline January 9, 2027**. Other intake deadlines: June 1 for January admission of following year; October 1 for May admission of following year. Supplementary Information Form required.",
        "lang": "TOEFL iBT minimum overall 90 with Writing 25 and Speaking 25; IELTS Academic minimum overall 7.0 with Writing 6.5 and Speaking 6.5. ELP required if schooling completed outside Canada and not in English-speaking country. ETS institution code for University of Waterloo.",
        "test_cls": "GRE PHYSICS SUBJECT OPTIONAL (Waterloo: 'GRE Physics subject test scores for all students who completed post-secondary education outside Canada. Due to COVID-19, Physics subject GRE test requirement is optional for admission. You may choose to include results if you have taken them, but tests are not required for admission.' Required: transcripts, 3 academic references, SIF, proof of ELP. CRITICAL: Must contact potential supervisor with 500-word statement.)",
        "tui": "Funding covering tuition and stipend. One of largest physics and astronomy graduate programs in Canada; department tradition of collaboration and innovations. Students work closely with supervisor to perform original research culminating in PhD thesis. CRITICAL: close ties to Perimeter Institute for Theoretical Physics in Waterloo; PhD Advisory Committee may include Perimeter Institute faculty with Approved Doctoral Dissertation Supervisor (ADDS) status. Accelerated Doctoral Program available for exceptional MSc students.",
        "overview": "The University of Waterloo Department of Physics and Astronomy, within the Faculty of Science, offers the Doctor of Philosophy in Physics. Be at the cutting edge of discovery in one of the largest physics and astronomy graduate programs in Canada. The department's tradition of collaboration and innovations offers a rich and varied graduate experience that is unparalleled. Students work closely with a supervisor to perform original research in an area of physics, culminating in a PhD thesis. Funding will be provided to cover tuition and stipend. Minimum admission requirements: normally a Master's degree in Physics with at least 75% standing. Students with an undergraduate degree in physics may apply for admission directly to the PhD program. Successful applicants will have an outstanding academic record, breadth of knowledge in physics, and strong letters of recommendation. Three academic references are required. Proof of English language proficiency, if applicable: TOEFL iBT 90 (writing 25, speaking 25), IELTS 7.0 (writing 6.5, speaking 6.5). Per the Department application page: Confirm you meet the admission requirements. Program GPA: MSc - an Honours Bachelor's degree (or equivalent) in Science with at least a 75% standing or equivalent in the last two years of a four-year Physics-related degree. PhD - Master's Degree in Physics with at least a 75% standing (or equivalent). Physics Graduate Record Examination (GRE) required for all students who have completed their post-secondary education outside of Canada. Minimum acceptable score is 800. Due to COVID-19, the Physics subject GRE test requirement is optional for admission. Proof of English language proficiency. Contact potential supervisors: Email faculty, adjunct faculty, and cross-appointed faculty listed on departmental website. Include 500 word statement on why you would like to work with this faculty member, status in Canada (international or domestic), research interest, previous degree and GPA. Start OUAC application. Per the Graduate Studies Academic Calendar: PhD Advisory Committee must consist of at least four members including: the student's supervisor(s) (primary supervisor acts as Committee Chair); at least one Committee member that is a regular faculty member of the Department of Physics and Astronomy at University of Waterloo (note: this requirement does not apply for PhD students supervised by a Perimeter Institute faculty member with Approved Doctoral Dissertation Supervisor (ADDS) status); at least two Committee members that are regular, adjunct, or cross-listed faculty members of Department of Physics and Astronomy at University of Waterloo or Department of Physics as the University of Guelph. The department is located in Waterloo, Ontario, Canada.",
        "requirements": "<ul><li>Master's degree in Physics with at least 75% standing</li><li>OR undergraduate degree in Physics with outstanding record (direct-entry PhD)</li><li>GRE Physics Subject: optional due to COVID-19 (originally required for non-Canadian post-secondary, min 800)</li><li>GRE General: not listed as required</li><li>TOEFL iBT minimum overall 90 (Writing 25, Speaking 25)</li><li>IELTS Academic minimum overall 7.0 (Writing 6.5, Speaking 6.5)</li><li>ELP required if schooling outside Canada and not in English-speaking country</li><li>3 academic references</li><li>Supplementary Information Form (SIF)</li><li>Transcripts from all post-secondary institutions</li><li>**CRITICAL: Must contact potential supervisor**</li><li>Email must include: 500-word statement why want to work with this faculty</li><li>Email must include: status in Canada (international or domestic)</li><li>Email must include: research interest</li><li>Email must include: previous degree and GPA</li><li>**Fall deadline January 9, 2027** for September admission</li><li>Winter admission deadline June 1</li><li>Spring admission deadline October 1</li><li>48 months full-time thesis-based</li><li>PhD Advisory Committee at least 4 members (supervisor + at least 1 regular Waterloo faculty + at least 2 regular/adjunct/cross-listed faculty)</li><li>Perimeter Institute faculty with ADDS status may serve</li><li>Accelerated Doctoral Program available for exceptional MSc students</li><li>Funding covering tuition and stipend</li><li>On-campus residential (Waterloo, ON, Canada)</li></ul>",
        "research": "<ul><li>Condensed matter physics</li><li>Astrophysics and astronomy</li><li>High energy physics</li><li>Quantum information</li><li>Biophysics</li><li>Atomic, molecular, and optical physics</li><li>Nanotechnology (collaborative PhD option)</li><li>Gravity and cosmology</li><li>Strong ties to Perimeter Institute for Theoretical Physics</li><li>Interdisciplinary research with University of Guelph Department of Physics</li></ul>",
        "source": '<a href="https://uwaterloo.ca/future-graduate-students/programs/by-faculty/science/physics-doctor-philosophy-phd" target="_blank">Waterloo Future Graduate Students: Physics PhD (Jan 9 for Sept; June 1 for Jan; Oct 1 for May; Master\'s in Physics 75%+; undergrad may direct apply; 3 academic references; TOEFL 90 W25 S25; IELTS 7.0 W6.5 S6.5; one of largest physics and astronomy graduate programs in Canada; funding covers tuition and stipend)</a> | <a href="https://uwaterloo.ca/physics-astronomy/application" target="_blank">Waterloo Physics & Astronomy Application (program GPA MSc 75%; PhD Master\'s 75%; GRE Physics Subject required for non-Canadian post-secondary min 800; TOEFL 90 W25 S25; contact supervisor with 500-word statement including status/research interest/degree/GPA)</a> | <a href="https://uwaterloo.ca/physics-astronomy/graduate-studies/how-apply" target="_blank">Waterloo How to Apply (connect with potential supervisor; transcripts; SIF; GRE Physics subject encouraged but not required due to COVID-19; ELP if schooling outside Canada; application procedures for collaborative programs may differ)</a> | <a href="https://uwaterloo.ca/graduate-studies-academic-calendar/science/department-physics-and-astronomy/doctor-philosophy-phd-physics" target="_blank">Waterloo Graduate Studies Academic Calendar: PhD in Physics (48 months; Master\'s in Physics 75%+; undergrad may direct apply; GRE Physics subject for non-Canadian post-secondary; SIF; transcripts; 3 academic references; PhD Advisory Committee at least 4 members; Perimeter Institute ADDS faculty may serve)</a>',
    },
    "uchicago-astro-phd": {
        "school": "University of Chicago, Physical Sciences Division, Department of Astronomy and Astrophysics",
        "en": "PhD in Astrophysics",
        "deg": "Doctor of Philosophy (PhD)",
        "stem_label": "STEM-designated (Astronomy / CIP 40.0201; Astrophysics / CIP 40.0201)",
        "dur": "Typically 5-6 years; leading to PhD in Astrophysics; strong backgrounds in Physical Sciences and Mathematics; research across observational, theoretical, and computational astrophysics; guaranteed access to Magellan Telescopes at Las Campanas Observatory in Chile; Chicago-Carnegie Brinson predoctoral program year at Carnegie Observatories; on-campus (Chicago, IL); Fall admission",
        "ddl": "Fall 2027-2028: **Deadline December 1, 2026 at 11:59 PM EST** per Department of Astronomy and Astrophysics. Application fee $90 (may be waived if applicant meets Physical Sciences Division fee waiver criteria). NOTE: This entry is Astronomy PhD; UChicago Physics PhD deadline is December 14, 2026 (with Physics GRE required for 2026-27 cycle).",
        "lang": "TOEFL iBT minimum 90 overall; IELTS Academic minimum 7.0 overall. Only TOEFL iBT or IELTS Academic accepted. ETS institution code 1832. Applicants who do not meet waiver criteria must submit proof of English language proficiency.",
        "test_cls": "GRE NOT REQUIRED BUT OPTIONAL (UChicago Department of Astronomy and Astrophysics: 'GRE scores are not required but may be submitted optionally.' Required: personal statement, 3 LOR, college transcript(s), CV/resume. ETS 1832. No minimum GRE score. NOTE: UChicago Physics PhD (separate) REQUIRES Physics GRE for 2026-27 cycle; Astronomy PhD does NOT require Physics GRE.)",
        "tui": "Multi-year fully-funded through RA/TA/fellowship: tuition + stipend + health insurance. Department is home of world-leaders in cosmological physics, astroparticle and high-energy physics, and computational astrophysics. Guaranteed access to Magellan Telescopes at Las Campanas Observatory in Chile - among highest per-capita access to 8-m class telescopes in the country. Chicago-Carnegie Brinson predoctoral program allows year at Carnegie Observatories.",
        "overview": "The University of Chicago Department of Astronomy and Astrophysics, within the Physical Sciences Division, offers a doctoral program for students pursuing the PhD in Astrophysics. The Department of Astronomy and Astrophysics is home to world-leaders in cosmological physics, astroparticle and high-energy physics, and computational astrophysics. As leader in astronomy and astrophysics for over a century, faculty and students engage in forefront research to advance scientific understanding of the universe. The department is a proud participant in the Vera C. Rubin First Look, Simons Observatory, and other flagship observational facilities. CRITICAL POLICY per Department How to Apply: The deadline for applications for the 2027-2028 academic year is Monday, December 1, 2026 at 11:59 pm EST. Notice regarding 2027-2028 application cycle: GRE scores are not required but may be submitted optionally. The application to the PhD program consists of: personal statement, 3 letters of recommendation, college transcript(s), a curriculum vitae (CV) or resume of past accomplishments. Applicants who do not meet the waiver criteria must submit proof of English language proficiency. Only the TOEFL iBT or IELTS Academic tests are accepted as proof of proficiency. The Department of Astronomy and Astrophysics requires a minimum TOEFL score of 90 overall, and a minimum IELTS score of 7.0 overall. An application fee of $90 is required but may be waived if the applicant meets any of the application fee waiver criteria specified by the Physical Sciences Division. Applicants to the graduate program typically have strong backgrounds in the Physical Sciences and Mathematics. Per the Department PhD program brochure: The Big Glass, Big Ideas. The Department of Astronomy & Astrophysics at the University of Chicago offers a diverse and vibrant observational research program with guaranteed access to the Magellan Telescopes at Las Campanas Observatory in Chile. Students have the opportunity to participate in a wide array of research projects, using a wide range of observational facilities. Through the Chicago-Carnegie Brinson predoctoral program, a partnership with Carnegie Observatories, students also have the opportunity to spend a year of their PhD studies working alongside outstanding staff at Carnegie Observatories to expand horizons. Our grad students enjoy what is among the highest per-capita access to 8-m class telescopes in the country. Put the Physics in Astrophysics: The Department of Astronomy and Astrophysics is the home of world-leaders in cosmological physics, astroparticle and high-energy physics. NOTE: This entry is Astronomy PhD; UChicago Physics PhD is a separate program with deadline December 14, 2026 and Physics GRE required for 2026-27 cycle. The department is located in Chicago, Illinois.",
        "requirements": "<ul><li>Strong background in Physical Sciences and Mathematics</li><li>GRE: not required but may be submitted optionally</li><li>No minimum GRE score</li><li>TOEFL iBT minimum 90 overall</li><li>IELTS Academic minimum 7.0 overall</li><li>Only TOEFL iBT or IELTS Academic accepted (no other tests)</li><li>ETS institution code 1832</li><li>UChicago Physical Sciences Division online application</li><li>Application fee $90 (waivable per PSD fee waiver criteria)</li><li>Personal statement</li><li>3 letters of recommendation</li><li>College transcript(s)</li><li>CV or resume of past accomplishments</li><li>**Deadline December 1, 2026 at 11:59 PM EST** for 2027-2028</li><li>Fall admission</li><li>Guaranteed access to Magellan Telescopes at Las Campanas Observatory, Chile</li><li>Chicago-Carnegie Brinson predoctoral program (year at Carnegie Observatories)</li><li>Multi-year fully-funded (RA/TA/fellowship)</li><li>On-campus residential (Chicago, IL)</li><li>NOTE: UChicago Physics PhD is separate (Dec 14, 2026; Physics GRE required for 2026-27 cycle)</li></ul>",
        "research": "<ul><li>Cosmological physics</li><li>Astroparticle and high-energy physics</li><li>Computational astrophysics</li><li>Extragalactic astronomy and galaxy formation</li><li>Exoplanets and planetary systems</li><li>Stellar astrophysics</li><li>Observational cosmology (CMB, large-scale structure)</li><li>Theoretical astrophysics</li><li>Instrumentation and detector development</li><li>Flagship facilities: Vera C. Rubin Observatory, Simons Observatory, Magellan Telescopes</li><li>Chicago-Carnegie Brinson predoctoral program</li></ul>",
        "source": '<a href="https://astrophysics.uchicago.edu/academics/graduate-programs/how-to-apply/" target="_blank">UChicago Department of Astronomy and Astrophysics How to Apply (2027-2028 deadline Dec 1, 2026 11:59pm EST; GRE not required but optional; personal statement, 3 LOR, transcripts, CV; TOEFL 90 / IELTS 7.0; only TOEFL iBT or IELTS Academic accepted; $90 fee waivable; strong backgrounds in Physical Sciences and Mathematics)</a> | <a href="https://physicalsciences.uchicago.edu/academics/application-requirements/" target="_blank">UChicago Physical Sciences Division Application Requirements (ETS institution code 1832; GRE scores valid within 5 years; no minimum GRE score; self-report GRE; only TOEFL iBT or IELTS Academic accepted; score level varies by program)</a> | <a href="https://astrophysics.uchicago.edu/?dir=images" target="_blank">UChicago Department of Astronomy and Astrophysics (over a century of leadership in astronomy and astrophysics; faculty and students engage in forefront research; thousands of undergraduate, graduate, and professional alumni; Simon Observatory, Vera C. Rubin First Look, John Carlstrom 2026 Jansky Lecturer)</a> | <a href="https://d3qi0qp55mx5f5.cloudfront.net/astrophysics/docs/UChicago_Astro_PhD_program_-_Google_Docs.pdf" target="_blank">UChicago Astronomy PhD Program Brochure (Magellan Telescopes Las Campanas Chile access; Chicago-Carnegie Brinson predoctoral program; highest per-capita access to 8-m class telescopes; world-leaders in cosmological physics, astroparticle and high-energy physics, computational astrophysics; Abigail Vieregg neutrino astrophysics and cosmology with CMB)</a>',
    },
}

# Write detail pages
for p in PROGRAMS:
    key = p["id"]
    d = PAGES[key]
    html = DETAIL_TEMPLATE.format(
        school=d["school"], en=d["en"], deg=d["deg"], stem_label=d["stem_label"],
        dur=d["dur"], ddl=d["ddl"], lang=d["lang"], test_cls=d["test_cls"], tui=d["tui"],
        overview=d["overview"], requirements=d["requirements"],
        research=d["research"], source=d["source"],
    )
    path = os.path.join(DET, key + ".html")
    with open(path, "w", encoding="utf-8") as f:
        f.write(html)
    print(f"Wrote: {key}.html")

# Append PROGRAMS
idx_path = os.path.join(BASE, "index_main.html")
with open(idx_path, "r", encoding="utf-8") as f:
    html = f.read()

def build_entry(p):
    return ('{{id:"{id}",s:"{s}",n:"{n}",en:"{en}",deg:"{deg}",lvl:"{lvl}",stem:{stem},'
            'dur:"{dur}",ddl:"{ddl}",lang:"{lang}",test:{{cls:"{test_cls}"}},'
            'tui:"{tui}",url:"{url}"}}').format(
        id=p["id"], s=p["s"], n=p["n"], en=p["en"], deg=p["deg"], lvl=p["lvl"],
        stem=p["stem"], dur=p["dur"], ddl=p["ddl"], lang=p["lang"],
        test_cls=p["test"]["cls"].replace('"', "'"),
        tui=p["tui"].replace('"', "'"), url=p["url"],
    )

new_entries = ",\n".join(build_entry(p) for p in PROGRAMS)

m = re.search(r'const\s+PROGRAMS\s*=\s*\[', html)
start = m.end()
depth = 1
i = start
while i < len(html) and depth > 0:
    c = html[i]
    if c == '[': depth += 1
    elif c == ']': depth -= 1
    i += 1
insert_pos = i - 1
prefix = html[:insert_pos].rstrip()
suffix = html[insert_pos:]
if prefix.endswith('{'):
    new_block = prefix + "\n" + new_entries + "\n" + suffix
else:
    new_block = prefix + ",\n" + new_entries + "\n" + suffix

# Append VD on new_block (re-locate to avoid offset)
vd_entries = ",\n".join(f'"{p["url"]}"' for p in PROGRAMS)
m2 = re.search(r'VERIFIED_DETAILS\s*=\s*new\s+Set\s*\(\s*\[', new_block)
vstart = m2.end()
vdepth = 1
j = vstart
while j < len(new_block) and vdepth > 0:
    c = new_block[j]
    if c == '[': vdepth += 1
    elif c == ']': vdepth -= 1
    j += 1
vinsert_pos = j - 1
vprefix = new_block[:vinsert_pos].rstrip()
vsuffix = new_block[vinsert_pos:]
if vprefix.endswith(','):
    new_block = vprefix + "\n" + vd_entries + "\n" + vsuffix
elif vprefix.endswith('['):
    new_block = vprefix + "\n" + vd_entries + "\n" + vsuffix
else:
    new_block = vprefix + ",\n" + vd_entries + "\n" + vsuffix

with open(idx_path, "w", encoding="utf-8") as f:
    f.write(new_block)

print(f"Appended {len(PROGRAMS)} PROGRAMS entries and {len(PROGRAMS)} VD entries")
print(f"Done. File size: {os.path.getsize(idx_path)}")
