text:
# Switchable photovoltaic windows enabled by reversible photothermal complex dissociation from methylammonium lead iodide

## Abstract

Materials with switchable absorption properties have been widely used for smart window applications to reduce energy consumption and enhance occupant comfort in buildings. In this work, we combine the benefits of smart windows with energy conversion by producing a photovoltaic device with a switchable absorber layer that dynamically responds to sunlight. Upon illumination, photothermal heating switches the absorber layer—composed of a metal halide perovskite-methylamine complex—from a transparent state (68% visible transmittance) to an absorbing, photovoltaic colored state (less than 3% visible transmittance) due to dissociation of methylamine. After cooling, the methylamine complex is re-formed, returning the absorber layer to the transparent state in which the device acts as a window to visible light. The thermodynamics of switching and performance of the device are described. This work validates a photovoltaic window technology that circumvents the fundamental tradeoff between efficient solar conversion and high visible light transmittance that limits conventional semitransparent PV window designs.

## Introduction

Myriad materials that adopt the oxide and halide forms of the perovskite crystal structure are known to readily accommodate intercalating species to form a rich array of unique compounds1,2. The intercalated compounds are stabilized by the formation of ionic3,4, charge-transfer complex5,6, van der Waals7,8 and π-stacked fluorylaryl-aryl bonds9. The weaker of these bonds are reversibly formed and dissociated with small energy input. Lead halide perovskites (APbX3, where A is an organic or alkali metal cation and X is a halide) have demonstrated unprecedented potential as a photovoltaic (PV) absorber10 and have also shown to reversibly form hydrates11,12,13,14 and other compounds stabilized by charge-transfer complex bonds with nitrogen-15,16,17 and oxygen-donor molecules18,19,20.

In this work, we leverage the low formation/dissociation energy of the methylammonium lead iodide-methylamine complex (CH3NH3PbI3xCH3NH2)18 to demonstrate a cohesive switchable PV window that adapts its absorption properties to solar conditions without pairing separate electrochromic and PV devices21. The PV window device utilizes solar photothermal heating to dissociate CH3NH2 from the CH3NH3PbI3 layer, thereby switching from its complexed, bleached (visibly transparent) state to its dissociated, colored (visibly opaque) state. The device is sealed in a closed atmosphere of dilute (2%) CH3NH2 gas in argon and thus returns to its complexed, bleached state upon removing the solar irradiation and cooling to re-form CH3NH3PbI3xCH3NH2. This phenomenon circumvents the fundamental tradeoff observed in conventional semitransparent PV window designs22,23,24, which sacrifice solar-to-electricity power conversion efficiency (PCE) for the high visible light transmittance critical for window performance25. Coupled with the cost-effective, scalable solution-phase processing of lead halide perovskites, this technology widely expands the opportunity for energy-efficient PV deployment beyond solar farms and rooftops to glass building facades and vehicles.

## Results

### Switchable PV window design and performance

The switchable PV window device design and reversible switching mechanism is shown in Fig. 1a, and fabrication details are outlined in the Methods section. Briefly, CH3NH3PbI3 was deposited using established methods26 on titanium dioxide (TiO2) as the electron transport layer and fluorine-doped tin oxide (FTO) as the transparent bottom contact. In order to demonstate switching in a PV device, a number of hole transport and top contact layers were explored. Four complementary layers were required in order to provide the necessary combination of high electrical conductivity, favorable energetic alignment with the CH3NH3PbI3 layer, significant transparency in the visible portion of the solar spectrum, and permeability to CH3NH2 gas (Supplementary Table 1 and Supplementary Fig. 1). We first coated the CH3NH3PbI3 with a bilayer of single-walled carbon nanotubes (SWCNTs). SWCNTs wrapped in poly(3-hexylthiophene) (SWCNT/P3HT) provide favorable energetic alignment to the CH3NH3PbI3 for hole extraction27,28, and a second layer of electronically sorted SWCNTs doped with 2,3,5,6-tetrafluoro-7,7,8,8-tetracyanoquinodimethane (SWCNTF4TCNQ) was spray-coated to improve lateral electrical transport to the top contact29. This layer was then chemically treated with trifluoroacetic acid after deposition to de-polymerize and remove the wrapping polymer to enhance electrical conductivity between the SWCNTs30. The device was completed by laminating Ni micromesh31 coated with poly(3,4-ethylenedioxythiophene):poly(styrenesulfonate) (PEDOT:PSS), an electrically conductive polymer and effective hole transport layer (Supplementary Fig. 2)32, doped with d-sorbitol that serves as an “electric glue”33. Optical and scanning electron microscopy characterization of the device stack is shown in Supplementary Fig. 3.

Figure 1b shows the transmittance of the full device stack spanning the UV to IR portions of the electromagnetic spectrum. The visible portion is highlighted to illustrate reversible switching in this region of the spectrum. The device is highly absorbing in the visible portion in its colored state with an average visible light transmittance of 3%. The visible light transmittance increases to 68% when in the bleached state. The observed decrease in transmittance for both colored and bleached states of the device in the infrared region is due to thin film interference and FTO absorption. Reduced transmittance in this range is desirable for the thermal performance of windows and is the primary function of low-emissivity films used in current high-performance window technology.

Figure 1c shows the current density–voltage curve scanned from high to low positive voltage of the switchable PV device in the dark (dashed) and under 1-sun illumination (solid). The champion device exhibits a PCE of 11.3% with an average of 10.3 ± 0.9% in five devices. A table with the performance metrics of the champion device are inset to Fig. 1c. For comparison, control devices were fabricated with Li-doped 2,2′,7,7′-tetrakis(N,N-di-p-methoxyphenylamine)-9,9′-spirobifluorene (spiro-OMeTAD) as the hole transport layer and gold as the top contact to mimic conventional CH3NH3PbI3-based PV devices26. The control devices, which do not exhibit dynamic switching behavior since gold is not permeable to CH3NH2 gas, exhibit an average PCE of 16.3 ± 0.1%. The short-circuit current density (J SC) of 21.2 mA cm−2 for the champion switchable device is identical to the control device, whereas the open-circuit voltage (V OC) and fill factor (FF) are moderately reduced in the switchable PV window device. Additional characterization of the switchable device (forward and reverse voltage sweeps, stabilized power output, and external quantum efficiency) is included in Supplementary Figs. 46.

We next demonstrate dynamic photothermal modulation of the PV window device while generating photocurrent under illumination. Figure 1d is a plot of short-circuit current output as a function of time for a device enclosed in an atmosphere of 2% CH3NH2 gas balanced with argon to atmospheric pressure. The initial complexed, bleached device was held at ambient temperature from time zero until the device was exposed to solar-simulated illumination at 30 s, indicated by gray boxes in Fig. 1d. Current was immediately observed from the device after illumination, which increased and began to plateau after 1 min. The current dropped to zero when the lamp was turned off after 3 min. The lamp was turned back on after 5 min, and this cycle was repeated 20 times in the closed atmosphere (no additional CH3NH2 gas was introduced) to demonstrate repeated cycling.

Optical images extracted from Supplementary Movie 1 in Fig. 1e show reversible color changes correlate with current during the cycling process. The exception to this correlation occurred during the initial stages of each illumination cycle, when the device produced current but did not exhibit visible color. After illumination, the current increased at a near-linear rate until 40 s of illumination when the current increased at a higher rate. This sharp rise in current was sustained for another 40 s and was accompanied by a visible color change. After 3 min, the color gradually changed from yellow-orange to dark red, corresponding to complete switching after 3 min. When the lamp was turned off, the device cooled in the chamber, which caused CH3NH2 gas to intercalate back into the CH3NH3PbI3 layer to re-form the CH3NH3PbI3xCH3NH2 complex and return the device to the bleached state after 3 min. The maximum current decreased monotonically from nearly 1 to 0.18 mA after 20 cycles. Supplementary Fig. 7 provides the same analysis as Fig. 1e for the 15th cycle, which exhibits a similar kinetic profile but at a lower current output. Whereas decreased current output may be due to delamination or degradation of transport layers, optical images show inconsistent coloration across the device compared to that following the first cycle, which suggests degradation or morphological changes to the CH3NH3PbI3 layer. The source of decreased current after cycling is discussed at length in a following section.

### Thermodynamics of complex formation and dissociation

We explain the observed reversible complex formation and dissociation process that drives photothermal switching of the PV window device using a simple thermodynamic model. The complexed state is stabilized by weak hydrogen bonds between CH3NH2 and the organic sublattice of CH3NH3PbI3 17, and its conversion to the dissociated state is dependant on the partial pressure (P) of CH3NH2 gas (g) and temperature (T) of the solid (s) phase described by

$${\mathrm{CH}}_3{\mathrm{NH}}_3{\mathrm{PbI}}_3 \bullet x{\mathrm{CH}}_3{\mathrm{NH}}_2{\mathrm{(}}s{\mathrm{)}}\mathop{\longleftrightarrow}\limits^{{P,T}}{\mathrm{CH}}_3{\mathrm{NH}}_3{\mathrm{PbI}}_3{\mathrm{(}}s{\mathrm{)}} + x{\mathrm{CH}}_3{\mathrm{NH}}_2{\mathrm{(}}g{\mathrm{)}}$$
(1)

The methylamine complex CH3NH3PbI3xCH3NH2 has been shown to form a solid at lower x values (x ≈ 1, 2 based on prior work on hydrates11) and a second glassy solvate (liquid) phase at higher values of x 17,34,35. Here we will focus on the solid complex observed at low CH3NH2 pressures that keeps x low and the complex in the solid regime17. As demonstrated in previous work on thermochemical energy storage36,37, the thermodynamics of Eq. (1) are described by the Clausius–Clapeyron relation where the volume is constant and assumed to be equal to the volume of gas37,38:

$${\mathrm{ln}}\,P(T) = \frac{{{\mathrm{\Delta }}G_{\mathrm{i}}}}{{xRT}} = - \left( {\frac{{{\mathrm{\Delta }}H_{\mathrm{i}}}}{{xR}}} \right)\left( {\frac{1}{T}} \right) + \frac{{{\mathrm{\Delta }}S_{\mathrm{i}}}}{{xR}}$$
(2)

where R is the ideal gas constant (8.31 mol–1 K–1), ΔG i, ΔH i, and ΔS i are the Gibb’s energy change, enthalpy change, and entropy change, respectively. The subscript $$i$$ corresponds to the formation of the complexed bleached state or dissociated colored state. Contributions to ΔG i thus include complex formation and dissociation, ionic bond formation or destruction in the CH3NH3PbI3 lattice, sublimation or condensation, and mixing.

Lines of constant ΔG Colored and ΔG Bleached are shown in the Clausius–Clapeyron diagram, which plots CH3NH2 gas pressure vs. reciprocal temperature (Fig. 2). The lines are separated by a regime of pseudo-equilibrium, which depends on the rates of the forward and reverse reactions37. If one of the free parameters (e.g., P) is fixed, the variance is zero and phase transition occurs at a certain temperature T. The line from point A to point B shows the isothermal transition from the colored state (CH3NH3PbI3(s)+xCH3NH2(g)) to the bleached state (CH3NH3PbI3xCH3NH2(s)) at room temperature (T 0). P Min is the minimum pressure of CH3NH2 gas needed for full transition to the bleached state. The line from B to C shows an isobaric transition back to the phase-segregated state, which requires a minimum temperature T Min. For window applications, the transition temperature must be below what can be practically attained by solar photothermal heating. This is typically less than 75 °C for most climates5, so this temperature defines T Solar (shaded region in Fig. 2). The switching temperature of conventional vanadium dioxide thermochromic window technology is thus engineered closer to 45 °C for practical application7.

We investigate the thermodynamics of reversible complex formation illustrated in Fig. 3 using in situ differential Fourier transform infrared spectroscopy (FTIR). A film of CH3NH3PbI3 having thickness W 1 was deposited onto an attenuated total reflectance (ATR) crystal, and the differential FTIR spectra were monitored by varying CH3NH2 gas pressure at ambient temperature as well as modulating temperature at a constant partial pressure (Fig. 3a). Before CH3NH2 gas was introduced, the film was placed under static vacuum (approximately 40 × 10−3 Torr), and the FTIR intensity from this film was zeroed at room temperature to give the red baseline spectrum in Fig. 3b (point A in Fig. 2). CH3NH3PbI3xCH3NH2 formation was not observed by eye or in the FTIR spectrum after the addition of 2 Torr (orange spectrum) and 7 Torr (green spectrum) of CH3NH2 gas. At 11 Torr, the film bleached and produced positive and negative peaks in the differential FTIR spectrum (point B in Fig. 2, data not shown). The intensity of these peaks remained constant between 11 and 41 Torr CH3NH2 (blue spectrum, point D in Fig. 2), indicating a P Min of approximately 11 Torr of CH3NH2 for the room-temperature transition from the colored state to the bleached state. The positive peaks in the 41 Torr spectrum are due to vibrational modes of complexed CH3NH2. Negative peaks are attributed to loss of intensity from CH3NH3 + due to film thickness increase (W 2 > W 1) as a result of CH3NH2 intercalation into the film39.

Figure 3c shows the isobaric (41 Torr CH3NH2) evolution of the CH3NH3PbI3xCH3NH2 film as temperature is increased from T 0 to 65 °C. We focus on the N–H stretching vibrations of the perovskite A-site cation CH3NH3 + and complexed CH3NH2. Positive intensity from CH3NH2 is centered at 3250 cm−1, and negative intensity due to CH3NH3 + is centered at 3130 cm−1. The FTIR spectrum is constant from T 0 (point D in Fig. 2) up to 35 °C, showing the expected large negative intensity CH3NH3 + and positive intensity CH3NH2 peaks for the CH3NH3PbI3xCH3NH2 film relative to the dissociated CH3NH3PbI3 film (baseline). At 40 °C, a threefold reduction in negative CH3NH3 + intensity was observed in conjunction with a nearly twofold reduction in positive CH3NH2 intensity, which both indicate significant dissociation of CH3NH3PbI3xCH3NH2 into CH3NH2(g) and CH3NH3PbI3(s) phases. Intensity from all species was further reduced as the temperature was increased to 65 °C (point E in Fig. 2), though the intensity never returned to the baseline level, suggesting that complete dissociation does not occur under these conditions. However, the presence of a clear isosbestic point at 3225 cm−1 during this isobaric experiment suggests the lack of intermediates between these two phases. This evidence supports nearly complete and rapid CH3NH2 dissociation at the threshold temperature, consistent with the Clausius–Clapeyron diagram in Fig. 2 in which the pseudo-equilibrium region is narrow.

Finally, in Fig. 3d we show the isobaric temperature-driven complex formation and dissociation during repeated cycling as demonstrated in the PV window device described in Fig. 1. Two bleached-to-colored cycles were completed by heating the ATR crystal to 60 °C (red spectra) and allowing it to cool to 25 °C (blue spectra) under 11 Torr CH3NH2. It is clear from the inset optical images that the film visible transmittance switching behavior is correlated to the intensity changes of the N–H stretching vibrations. Importantly, the cumulative observations from these isobaric experiments indicate that for reasonable CH3NH2 pressures (11–41 Torr), solar thermal temperatures only need to exceed a T Min of ca. 35 °C for switching the PV window into the colored state to generate photocurrent. Such temperatures are readily achievable in most climate zones5 and can be tuned by the pressure of CH3NH2 gas to accommodate a desired switching threshold.

### Mechanism of switchable device degradation

Building-integrated PV must be durable. For instance, existing dynamic smart window technologies are tested out to 50,000 switching cycles using standard durability evaluation methods. Figure 1d shows the performance of our demonstration PV device was reduced over the course of 20 switching cycles. We fabricated photoresistors in order to elucidate the degradation mechanism (Fig. 4a). The symmetric FTO lateral contact architecture allows monitoring changes in electrical performance, morphology, and chemistry of the CH3NH3PbI3 film without complications arising from the additional gas-porous top contact layers required for a switchable PV device.

Figure 4b shows current as a function of time for a photoresistor composed of CH3NH3PbI3 in the absence of CH3NH2 (0 Torr CH3NH2) to investigate the effects of photothermal cycling without CH3NH3PbI3xCH3NH2 formation and dissociation. The photoresistor was biased at the maximum power point voltage of the PV devices shown in Fig. 1 (0.65 V) and cycled using 3-min photothermal heating followed by 5-min cooling. Current output of the device decreases monotonically by 39% over the course of 20 cycles. X-ray photoelectron spectroscopy (XPS) analysis suggests that this is due to chemical degradation since the film becomes more Pb-rich after cycling (Supplementary Table 2). CH3NH3PbI3 is known to evolve CH3NH2 and hydrogen iodide at elevated temperatures to yield PbI2 within the CH3NH3PbI3 film40, and this degradation pathway is consistent with our observations.

In contrast to CH3NH3PbI3, the switchable photoresistor composed of CH3NH3PbI3xCH3NH2 (11 Torr CH3NH2, Fig. 4c) did not show decreased current output after 20 cycles. The presence of CH3NH2 is likely beneficial to the stability of the device current output, as CH3NH2 gas is thought to “heal” defects in CH3NH3PbI3 films18. XPS analysis shows the switchable photodector maintains stoichiometry closer to the control sample that was not cycled, suggesting that CH3NH2 suppresses decomposition to PbI2 via Le Chatelier’s principle. The longer switching onset (by ~30 s) and non-saturated current for the CH3NH3PbI3xCH3NH2 (Fig. 4c) relative to the switchable PV device shown in Fig. 1d appears to be due to lower light absorption (~10%, compared to 20–40% for the PV stack), which produces slower photothermal heating for the photoresistor. Longer illumination times led to current saturation and reduced current output that more closely resemble the trend observed in the PV device (Supplementary Fig. 9).

Optical microscopy of the devices after 20 cycles provides the most illustrative insight into the decreased PV device performance. Figure 4d shows an optical microscope image of the 0 Torr CH3NH2 photoresistor, which is morphologically unchanged from when it was deposited at the scale that can be observed with the microscope. In contrast, the switchable photoresistor (11 Torr CH3NH2, Fig. 4e) shows roughness on the order of microns to tens of microns. This is an interesting result in comparison to established practice17,18,35 where CH3NH3PbI3 films are briefly exposed to CH3NH2 gas and annealed in a  CH3NH2-free environment to yield higher quality films. In contrast, CH3NH3PbI3 quality is decreased when annealed in presence of a significant partial pressure of CH3NH2. Morphology is further disrupted with longer illumination times (Supplementary Fig. 9). The loss of current with cycle number provides the most compelling evidence of decreased PV performance, whereas the microscope images provide the best window into the mechanism underlying the decrease in performance. Morphology changes likely lead to delamination of adjacent SWCNT and Ni grid hole transport layers, dewetting from the TiO2 layer, and formation of paths for electrical shorting through the device. It is clear that morphological control using device architecture, patterning, or compositional additives, for example, will be necessary in the future development of switchable PV devices based on CH3NH3PbI3xCH3NH2 films.

## Discussion

In this work, we demonstrated a PV window device with optical properties that are photothermally modulated using solar illumination. The devices feature solar energy conversion efficiencies as high as 11.3% in the colored state, high visible light transmittance (68%) in the bleached state, reversible switching over 20 cycles, low switching temperature accessible by solar irradiation in most climates, and fast switching time (less than 3 min). Switching is enabled by reversible dissociation of a methylamine complex with CH3NH3PbI3 using solar photothermal energy. The thermodynamics of complex formation and dissociation were described by the Clausius–Clapeyron relation and empirically supported by in situ differential FTIR spectroscopy of the pressure–temperature dependance of the associated phase transitions. Photoresistor studies show the switchable CH3NH3PbI3•xCH3NH2 layer has potential for long-term chemical stability, but physical changes to the film during switching leads to decreased PV device performance over time due to CH3NH2 loss and disruption of the film morphology. Switchable PV technology circumvents the fundamental tradeoff between power conversion and visible transmittance of conventional semitransparent PV windows and facilitates deployment strategies beyond the current paradigm of rooftops and solar farms.

## Methods

### Absorber layer solution

The solution used to solubilize CH3NH3PbI3 precursors was obtained by charging acetonitrile with CH3NH2 gas. Acetonitrile was de-gassed using three freeze–pump–thaw cycles and placed in an airtight flask. CH3NH2 gas was flown into the vessel through a Schlenk-line assembly. The acetonitrile was charged until a 10% by mass CH3NH2 solution was achieved. The flask was sealed and stored in a −20 °C freezer. Solution was removed with a needle through the septum to keep the solution isolated from air exposure. Adding 1 ml CH3NH2-charged acetonitrile to 261 mg PbI2 and 87 mg methylammonium iodide formed a typical 0.55 M precursor solution used for devices.

### FTIR measurements

A Bruker Alpha FTIR spectrometer outfitted with a diamond ATR crystal attachment was used in the study. A CH3NH3PbI3 film was deposited onto an ATR crystal by drop-casting a 55 mM solution. Diluting a 0.55 M solution with acetonitrile charged with 10% CH3NH2 by mass formed the solution. The film was annealed at 100 °C for 30 min in Ar. Securing a custom glass chamber over the ATR crystal stage with a Viton O-ring enclosed the film. The film was pumped down with a roughing pump overnight to obtain a base pressure of 90 mTorr (12 Pa). CH3NH2 was introduced into the glass jar at varying pressure measured with a Varian type 0531 vacuum gauge. The vacuum gauge was calibrated to measure CH3NH2 using a 100 Torr range MKS Barotron pressure transducer. In Fig. 3d, the atmosphere was balanced with argon to slightly above atmospheric pressure (627 Torr (83,593 Pa) measured on a 1000 Torr range MKS Barotron pressure transducer). The temperatures reported are those measured and delivered to the ATR stage with OPUS 7.2 software. Spectra shown at 60 °C were taken after the 3 min it took to ramp to that temperature. Spectra shown at 25 °C were taken after 21 min, which is the time needed to cool and stabilize at that temperature. The backgrounds of the resulting spectra were nonlinear due to thin film diffraction from change in the CH3NH3PbI3 film thickness. The background was subtracted using a third-order polynomial fit using IGOR Pro version 6.37. One fit was used to subtract the baseline at each temperature. The raw data and polynomial fits are shown in Supplementary Fig. 2.

### Photothermal switching of CH3NH3PbI3•xCH3NH2(s) films

Glass was cut into a 1-mm-thick 2.5 cm × 2.5 cm square, sonicated in acetone for 15 min, and blown dry with dry air. The substrates were treated in a UV-ozone cleaner for 15 min before spin-coating a 0.55 M solution composed of methylammonium iodide and PbI2 (5% excess) and the 10% CH3NH2 in acetonitrile solution onto the substrate at 2000 rpm for 20 s. The film was annealed at 100 °C for 30 min on a hot plate. Photothermal switching of CH3NH3PbI3 films was measured in a custom-built glass chamber outfitted with optical ports and feedthroughs for gas input/output and a pressure gauge. The glass substrate with CH3NH3PbI3 was cut into 1 cm × 1 cm square. Note: The thermal mass, and thus size, of the substrates plays an important role in switching kinetics. The sample was secured in the chamber with a clip facing the optical port, sealed with a Viton O-ring and clamp, and pumped down overnight to reach a base pressure of 70–90 mTorr (12 Pa), which was measured with a Varian type 0531 vacuum gauge. CH3NH2 was introduced into the chamber and backfilled with argon to reach slight overpressure above atmospheric pressure (~720 Torr = 95,992 Pa). A Cole-Palmer Illuminator 41,720-series was used for solar-simulated illumination. The lamp was used to approximate solar conditions by adjusting the intensity to between 500 and 1500 W m−2 using a Newport power meter (model 841-PE) with a model 818P-015-19 sensor head.

### SWCNT/P3HT ink preparation

This procedure follows directly from ref.7. Powdered SWCNTs produced by the CoMoCAT process, SWeNT CG200, were purchased from Sigma-Aldrich. The producers of this material report a diameter range of 0.7–1.4 nm and a relative purity of 90% as the percentage of carbon that is present as SWNTs. rr-P3HT (3.0 mg; Rieke Metals Inc.; average molecular weight of 50,000 g mol−1 and regioregularity of 95%) was dissolved in 5.00 ml of chlorobenzene and sonicated in a bath sonicator for 60 min. SWCNTs (2.5 mg) were added, as purchased, to the dissolved polymer solution and treated with a Cole Parmer 750 W ultrasonic probe, operating at 100% power, for 10 min. After sonication, 5 ml of chlorobenzene was added to improve the solubility of the polymer–nanotube hybrids. The mixture was subsequently centrifuged for 8 min at 10,000 g (Beckman Coulter ultracentrifuge, SW32Ti rotor) to remove unfunctionalized SWCNTs and other carbonaceous particles. The precipitate was discarded, and the supernatant was recovered. Ten milliliters toluene was added in order to remove the excess polymer. The mixture was then mildly heated for 60 min to induce aggregation of the functionalized SWNTs. The aggregates were then removed by centrifugation (4 min at 16,000 g). The supernatant containing excess polymer was discarded, and the precipitate was recovered. The pellet consisted of 1.5–1.6 mg of polymer-wrapped nanotubes, which were dispersed in 6 ml of chloroform. Immediately prior to spin-coating, the chloroform dispersion was sonicated with an ultrasonic probe for 1 min at low intensity (10% of amplitude) to break up clusters and bundles.

### SWCNTF4TCNQ ink preparation

SWCNTs were synthesized in-house at NREL via laser vaporization of a graphite target at a furnace temperature of 1125 °C. The imine-based polyfluorene dispersing polymer, poly[(9,9-di-n-dodecyl-2,7-fluorendiyl-dimethine)-(1,4-phenylene-dinitrilomethine)] (PFPD), was synthesized in-house as described in ref.41. To disperse the SWCNTs, 1.4 mg ml−1 SWCNTs and 2 mg ml−1 PFPD were added to toluene and processed using an ultrasonic probe for 15 min while the vial was submerged in a bath of dry ice and methanol. Following ultrasonication, the undispersed material is pelleted out via 5 min ultracentrifugation (13,200 rpm, 20°C) using a Beckman Coulter SW32Ti rotor. The supernatant was retained and underwent further ultracentrifugation (20 h, 24,100 rpm, 0 °C) to remove excess PFPD. The resulting pellet, containing highly enriched semiconducting SWCNTs wrapped with PFPD (SWCNT/PFPD), was re-dispersed in neat toluene. The SWCNT/PFPD ink was doped in solution phase by adding 250 μg ml−1 using 2,3,5,6-tetrafluoro-7,7,8,8-tetracyanoquinodimethane (F4TCNQ). The bleach of the S11 transition in the optical absorption spectrum of the ink after adding F4TCNQ indicates successful doping (Supplementary Fig. 3).

### Switchable PV device fabrication

Substrates with pre-patterned FTO deposited on glass were purchased from Thin Film Devices, Inc. The glass was 1 mm thick. Thicker glass leads to longer switching kinetics. The substrates were sonicated in acetone for 15 min and blown dry with dry air. The substrates were treated in a UV-ozone cleaner for 15 min before spin-coating 100 μl of a presursor solution prepared by diluting 0.5 ml 75 wt. %  titanium diisopropoxide bis(acetylacetonate) in 2-propanol with 6.65 ml 1-butanol   at 700 rpm for 10 s, followed by 1000 rpm for 10 s, and finally 2000 rpm for 30 s. The resulting film is placed on a hot plate at 125 °C for at least 2 min to evaporate solvent and then placed in a 500 °C furnace to sinter into TiO2. 100 μL of the absorber layer solution was spin-coated onto the substrate at 2000 rpm for 20 s in an inert atmosphere glovebox. The film was annealed at 100 °C for 30 min in the glovebox to yield a CH3NH3PbI3 layer. The SWCNT/P3HT were deposited onto the CH3NH3PbI3 layer by spinning the substrate at 3000 rpm and dropping 300 μl of the SWCNT/P3HT dispersion at a rate of approximately 1 drop every 3 s. SWCNTF4TCNQ thin films were deposited onto the device according to a procedure developed by Tenent et al.42 using ultrasonic spray deposition. Briefly, CH3NH3PbI3 films on TiO2/glass substrates were heated to 130 °C on the stage in the spray chamber. Then, the SWCNTF4TCNQ ink was sprayed using dispersion flow rate of 0.25 ml min−1, gas flow rate of 7.0 std l min−1, and nozzle power at 0.8 W for 30 coats. After deposition, the films were soaked at 80 °C in a solution of 10 μl ml−1 of trifluoroacetic acid (Sigma-Aldrich) in toluene for 30 s, followed by a rinse in neat toluene to fully remove the wrapping polymer, PFPD. Ni micromesh composed of a square network of 14 μm × 14 μm Ni bars with 268 μm × 268 μm holes was purchased from Precision Eforming, Inc. A 2-inch × 4-inch piece of mesh was attached to an aluminum plate using polyimide tape. The aluminum plate is attached to a hot plate with polyimide tape and set to 120 °C. PEDOT:PSS (CLEVIOS PH1000, 1.3% weight aqueous suspension) was purchased from Heraeus. Three milliliters of undiluted PEDOT:PSS was combined with 450 mg d-sorbitol and 136 μl dimethylsulfoxide and stirred with a magnetic stir bar for 15 min. The solution was sprayed onto the micromesh on the hot plate using an airbrush (Master Airbrush Model S68). The PEDOT layer is sprayed with 10 passes at a rate of approximately 1 in. s−1 at a distance of 6 in. from the mesh with the airbrush throttle fully open. The PEDOT:PSSD-Sorbitol was annealed for 10 min after spraying and then cooled to room temperature before being cut into ~3 mm × 11 mm strips. Transferring the strips with a tweezers to cover the active area and pressing with gentle finger pressure through a flexible polyethylene terephthalate substrate completes the switchable PV device.

### Photoresistor fabrication

Substrates with FTO deposited on glass were purchased from Thin Film Devices, Inc. A 100 μm channel was scribed into the FTO using a Q-switched, 532 nm Nd:YAG laser scribing system. The substrates were sonicated in acetone for 15 min and blown dry with dry air. The substrates were treated in a UV-ozone cleaner for 15 min before spin-coating CH3NH3PbI3 using the same procedure as the PV devices.

### UV–vis–NIR transmittance measurements

Measurements were carried out on a Cary-6000i spectrometer with an integrating sphere attachment. Devices were scored and cleaved to roughly 1 cm wide to fit into cuvettes. Silicone oil was placed on the back side of the device to adhere it to the cuvette and avoid additional thin film interference. The cuvette was sealed with a septum, and the atmosphere was removed with a roughing pump through a needle. For the bleached state measurement, 5% CH3NH2 partial pressure was added to the cuvette and backfilled with argon. The cuvette was filled with argon for the colored state measurement.

### XPS measurements

XPS data were obtained on a Physical Electronics 5600 photoemission system using monochromatic Al K α (1486.7 eV) radiation.

### PV device measurements

Devices were tested in a nitrogen-filled glovebox using a Newport Oriel Sol3A solar simulator with a xenon lamp. A calibrated reference solar cell (either GaAs or KG5 filtered Si to minimize the spectral mismatch) was used to set the intensity of the lamp to 1000 W m−2 AM1.5 conditions. Current density–voltage scans were taken in both directions with a scan rate of 225 mV s−1, step size of 10 mV, delay time of 10 ms, and number of power line cycles of 1. Device area was 0.10 cm2. Devices were measured with and without a metal aperture (0.056 cm2) and produced equivalent current densities. Stabilized power output was measured by holding the device at a constant voltage corresponding to the voltage at the maximum power point of the JV scan. External quantum efficiency (EQE) measurements were taken using a Newport Oriel IQE200.

### Photocurrent measurement in switching devices

Dynamic photoresponse of PV or photoresistor devices was measured in a custom-built glass chamber outfitted with optical ports, feedthroughs for gas input/output, electrical connection, and a pressure gauge. A PV or photoresistor device was cut into 1 cm × 1 cm squares and secured in the chamber with a clip. The electrical connection to the device was made with alligator clips and fed through the chamber to a Kiethley 2400 sourcemeter interfaced to a computer. The chamber is sealed with a Viton O-ring and clamp and pumped down overnight to reach a base pressure of 70–90 mTorr measured with a Varian type 0531 vacuum gauge. Five percent CH3NH2 partial pressure is introduced into the chamber and backfilled with argon to reach slight overpressure above atmospheric pressure of ~720 Torr. A Cole-Palmer Illuminator 41,720-series is used for solar-simulated illumination. The lamp was used to approximate solar conditions by adjusting the intensity to between 500 and 1500 W m−2 using a Newport power meter (model 841-PE) with a model 818P-015-19 sensor head.

### Crystal structures

Crystal structures in Fig. 1a were for illustrative purposes only, as the actual structure of CH3NH3PbI3xCH3NH2 was not determined. The images were generated from a .cif file of CH3NH3PbI3•H2O from ref. 11 using Jmol open-source software. Hydrogen is not shown.

### Data availability

All data used in this study are available from the corresponding authors upon reasonable request.

## References

1. 1.

Nicolosi, V., Chhowalla, M., Kanatzidis, M. G., Strano, M. S. & Coleman, J. N. Liquid exfoliation of layered materials. Science 340, 1226419 (2013).

2. 2.

Smith, I. C., Smith, M. D., Jaffe, A., Lin, Y. & Karunadasa, H. I. Between the sheets: postsynthetic transformations in hybrid perovskites. Chem. Mater. 29, 1868–1884 (2017).

3. 3.

Xia, H.-R., Sun, W.-T. & Peng, L.-M. Hydrothermal synthesis of organometal halide perovskites for Li-ion batteries. Chem. Commun. 51, 13787–13790 (2015).

4. 4.

Bohnke, O., Bohnke, C. & Fourquet, J. L. Mechanism of ionic conduction and electrochemical intercalation of lithium into the perovskite lanthanum lithium titanate. Solid State Ionics 91, 21–31 (1996).

5. 5.

Lee, E. S., Pang, X., Hoffmann, S., Goudey, H. & Thanachareonkit, A. An empirical study of a full-scale polymer thermochromic window and its implications on material science development objectives. Sol. Energy Mater Sol. Cells 116, 14–26 (2013).

6. 6.

Schaak, R. E. & Mallouk, T. E. Perovskites by design: a toolbox of solid-state reactions. Chem. Mater. 14, 1455–1471 (2002).

7. 7.

Takahashi, I., Hibino, M. & Kudo, T. Thermochromic properties of double-doped VO2 thin films prepared by a wet coating method using polyvanadate-based sols containing W and Mo or W and Ti. Jpn. J. Appl. Phys. 40, 1391–1395 (2001).

8. 8.

Quan, L. N. et al. Ligand-stabilized reduced-dimensionality perovskites. J. Am. Chem. Soc. 138, 2649–2655 (2016).

9. 9.

Mitzi, D. B., Medeiros, D. R. & Malenfant, P. R. L. Intercalated organic−inorganic perovskites stabilized by fluoroaryl−aryl interactions. Inorg. Chem. 41, 2134–2145 (2002).

10. 10.

Zhang, W., Eperon, G. E. & Snaith, H. J. Metal halide perovskites for energy applications. Nat. Energy 1, 16048 (2016).

11. 11.

Vincent, B. R., Robertson, K. N., Cameron, T. S. & Knop, O. Alkylammonium lead halides. Part 1. Isolated PbI6 4− ions in (CH3NH3)4PbI6•2H2O. Can. J. Chem. 65, 1042–1046 (1987).

12. 12.

Halder, A., Choudhury, D., Ghosh, S., Subbiah, A. S. & Sarkar, S. K. Exploring thermochromic behavior of hydrated hybrid perovskites in solar cells. J. Phys. Chem. Lett. 6, 3180–3184 (2015).

13. 13.

Leguy, A. M. A. et al. Reversible hydration of CH3NH3PbI3 in films, single crystals, and solar cells. Chem. Mater. 27, 3397–3407 (2015).

14. 14.

Christians, J. A., Miranda Herrera, P. A. & Kamat, P. V. Transformation of the excited state and photovoltaic efficiency of CH3NH3PbI3 perovskite upon controlled exposure to humidified air. J. Am. Chem. Soc. 137, 1530–1538 (2015).

15. 15.

Jeon, N. J. et al. Solvent engineering for high-performance inorganic–organic hybrid perovskite solar cells. Nat. Mater. 13, 897–903 (2014).

16. 16.

Hao, F., Stoumpos, C. C., Liu, Z., Chang, R. P. H. & Kanatzidis, M. G. Controllable perovskite crystallization at a gas–solid interface for hole conductor-free solar cells with steady power conversion efficiency over 10%. J. Am. Chem. Soc. 136, 16411–16419 (2014).

17. 17.

Zhao, T. et al. Design rules for the broad application of fast (<1 s) methylamine vapor based, hybrid perovskite post deposition treatments. RSC Adv. 6, 27475–27484 (2016).

18. 18.

Zhou, Z. et al. Methylamine-gas-induced defect-healing behavior of CH3NH3PbI3 thin films for perovskite solar cells. Angew. Chem. Int. Ed. 54, 9705–9709 (2015).

19. 19.

Huang, W., Manser, J. S., Sadhu, S., Kamat, P. V. & Ptasinska, S. Direct observation of reversible transformation of CH3NH3PbI3 and NH4PbI3 induced by polar gaseous molecules. J. Phys. Chem. Lett. 7, 5068–5073 (2016).

20. 20.

Zhao, Y. & Zhu, K. Optical bleaching of perovskite (CH3NH3)PbI3 through room-temperature phase transformation induced by ammonia. Chem. Commun. 50, 1605 (2014).

21. 21.

Davy, N. C. et al. Pairing of near-ultraviolet solar cells with electrochromic windows for smart management of the solar spectrum. Nat. Energy 2, 17104–17110 (2017).

22. 22.

Jung, J. W., Chueh, C.-C. & Jen, A. K. Y. High-performance semitransparent perovskite solar cells with 10% power conversion efficiency and 25% average visible transmittance based on transparent CuSCN as the hole-transporting material. Adv. Energy Mater. 5, 1500486 (2015).

23. 23.

Forberich, K., Guo, F., Bronnbauer, C. & Brabec, C. J. Efficiency limits and color of semitransparent organic solar cells for application in building-integrated photovoltaics. Energy Technol. 3, 1051–1058 (2015).

24. 24.

Chen, K.-S. et al. Semi-transparent polymer solar cells with 6% PCE, 25% average visible transmittance and a color rendering index close to 100 for power generating window applications. Energy Environ. Sci. 5, 9551 (2012).

25. 25.

Treml, B. E. & Hanrath, T. Quantitative framework for evaluating semitransparent photovoltaic windows. ACS Energy Lett. 1, 391–394 (2016).

26. 26.

Noel, N. K. et al. A low viscosity, low boiling point, clean solvent system for the rapid crystallisation of highly specular perovskite films. Energy Environ. Sci. 10, 145–152 (2017).

27. 27.

Habisreutinger, S. N. et al. Carbon nanotube/polymer composites as a highly stable hole collection layer in perovskite solar cells. Nano Lett. 14, 5561–5568 (2014).

28. 28.

Habisreutinger, S. N., Wenger, B., Snaith, H. J. & Nicholas, R. J. Dopant-free planar n–i–p perovskite solar cells with steady-state efficiencies exceeding 18%. ACS Energy Lett. 2, 622–628 (2017).

29. 29.

Pfeiffer, M., Beyer, A., Fritz, T. & Leo, K. Controlled doping of phthalocyanine layers by cosublimation with acceptor molecules: a systematic Seebeck and conductivity study. Appl. Phys. Lett. 73, 3202–3204 (1998).

30. 30.

Norton-Baker, B. et al. Polymer-free carbon nanotube thermoelectrics with improved charge carrier transport and power factor. ACS Energy Lett. 1, 1212–1220 (2016).

31. 31.

Bryant, D. et al. A transparent conductive adhesive laminate electrode for high-efficiency organic-inorganic lead halide perovskite solar cells. Adv. Mater. 26, 7499–7504 (2014).

32. 32.

You, J. et al. Low-temperature solution-processed perovskite solar cells with high efficiency and flexibility. ACS Nano 8, 1674–1680 (2014).

33. 33.

Ouyang, J. & Yang, Y. Conducting polymer as transparent electric glue. Adv. Mater. 18, 2141–2144 (2006).

34. 34.

Pang, S. et al. Transformative evolution of organolead triiodide perovskite thin films from strong room-temperature solid–gas interaction between HPbI3-CH3NH2 precursor pair. J. Am. Chem. Soc. 138, 750–753 (2016).

35. 35.

Zong, Y. et al. Thin-film transformation of NH4PbI3 to CH3NH3PbIPerovskite: a methylamine-induced conversion-healing process. Angew. Chem. 128, 14943–14947 (2016).

36. 36.

Cot-Gores, J., Castell, A. & Cabeza, L. F. Thermochemical energy storage and conversion: a-state-of-the-art review of the experimental research under practical conditions. Renew. Sustain. Energy Rev. 16, 5207–5224 (2012).

37. 37.

Bevers, E. R. T., van Ekeren, P. J., Haije, W. G. & Oonk, H. A. J. Thermodynamic properties of lithium chloride ammonia complexes for application in a high-lift high temperature chemical heat pump. J. Therm. Anal. Calorim. 86, 825–832 (2006).

38. 38.

Goetz, V. & Marty, A. A model for reversible solid-gas reactions submitted to temperature and pressure constraints: simulation of the rate of reaction in solid-gas reactor used as chemical heat pump. Chem. Eng. Sci. 47, 4445–4454 (1992).

39. 39.

Idígoras, J. et al. The interaction between hybrid organic-inorganic halide perovskite and selective contacts in perovskite solar cells: an infrared spectroscopy study. Phys. Chem. Chem. Phys. 18, 13583–13590 (2016).

40. 40.

Nenon, D. P. et al. Structural and chemical evolution of methylammonium lead halide perovskites during thermal processing from solution. Energy Environ. Sci. 9, 2072–2082 (2016).

41. 41.

Lei, T., Chen, X., Pitner, G., Wong, H. S. P. & Bao, Z. Removable and recyclable conjugated polymers for highly selective and high-yield dispersion and release of low-cost carbon nanotubes. J. Am. Chem. Soc. 138, 802–805 (2016).

42. 42.

Tenent, R. C. et al. Ultrasmooth, large-area, high-uniformity, conductive transparent single-walled-carbon-nanotube films for photovoltaics produced by ultrasonic spraying. Adv. Mater. 21, 3210–3216 (2009).

## Acknowledgements

The authors would like to thank Bobby To for SEM data, Severin Habisreutinger for SWNT/P3HT preparation, and Talysa Klein for photoresistor substrates. We also thank Jao Van De Lagemaat, Jeff Christians, and Joey Luther for helpful guidance and discussion. D.T.M. acknowledges support from NREL’s LDRD Director’s Fellowship program. The National Renewable Energy Laboratory’s Laboratory Directed Research and Development Program funded R.C.T., D.T.M., and L.M.W. for degradation studies. The U.S. Department of Energy, Office of Science, Office of Basic Energy Sciences, Division of Chemical Sciences, Geosciences, and Biosciences supported all other work under contract number DE-AC36-08GO28308 to NREL.

## Author information

Authors

### Contributions

L.M.W. designed experiments and thermodynamic model, developed hole transport layers, fabricated and tested PV window devices, performed in situ FTIR experiments, interpreted data, and wrote the manuscript. D.T.M. prepared absorber layer solution, fabricated and tested control PV devices, performed optical microscopy, and contributed to design of photoresistor studies. R.I. developed solution-doped SWCNT ink, spray-coated SWCNT films, and performed subsequent film treatment. N.J.S. prepared the SWCNT ink. J.L.B. contributed to experimental design and top contact development. E.M.M. performed and interpreted XPS experiments. R.C.T. contributed to experimental design and data interpretation. N.R.N. designed experiments, interpreted data, and wrote the manuscript. All authors contributed to editing the manuscript.

### Corresponding authors

Correspondence to Lance M. Wheeler or Nathan R. Neale.

## Ethics declarations

### Competing interests

The authors declare no competing financial interests.

Publisher's note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

Reprints and Permissions

Wheeler, L.M., Moore, D.T., Ihly, R. et al. Switchable photovoltaic windows enabled by reversible photothermal complex dissociation from methylammonium lead iodide. Nat Commun 8, 1722 (2017). https://doi.org/10.1038/s41467-017-01842-4

• Accepted:

• Published:

• ### A temperature gradient-induced directional growth of a perovskite film

• Lianzheng Hao
• , Zhipeng Li
• , Li Wang
• , Ranran Liu
• , Zhipeng Shao
• , Zhongmin Zhou
• , Xin Guo
• , Guanglei Cui
• , Shengzhong Frank Liu
•  & Shuping Pang

Journal of Materials Chemistry A (2020)

• ### The effect of urban morphology on the solar capacity of three-dimensional cities

• Rui Zhu
• , Man Sing Wong
• , Linlin You
• , Paolo Santi
• , Janet Nichol
• , Hung Chak Ho
• , Lin Lu
•  & Carlo Ratti

Renewable Energy (2020)

• ### First-Principles Investigations to Evaluate the Spin-Polarized Metal-to-Insulator Transition of Halide Cuprite Perovskites for Smart Windows

• June Ho Lee
• , Seong Hun Kim
• , Kyung-Yeon Doh
• , Eun Ho Kim
•  & Donghwa Lee

Journal of the American Chemical Society (2020)

• ### Ultrathin Nano-Absorbers in Photovoltaics: Prospects and Innovative Applications

• Maximilian Götz
• , Norbert Osterthun
• , Kai Gehrke
• , Martin Vehse
•  & Carsten Agert

Coatings (2020)

• ### Temperature-modulating rectifier behavior and photovoltaic response of VOx /Nb:SrTiO3 heterojunctions

• Ya Bin Zhu
• , Yi Xuan Liu
• , Ji Wang
• , Li Zhao
• , Kuo Zhan
•  & Yun Lin Chen

Journal of Physics D: Applied Physics (2020)


text:
Now showing items 242-261 of 1345

• #### Eigenmode analysis of compressional poloidal modes in a self‐consistent magnetic field

(2017)
In this study, we simulate a self‐consistent magnetic field that satisfies force balance with a model ring current that is radially localized, axisymmetric, and has anisotropic plasma pressure. We find that the magnetic ...
• #### Elastic and inelastic collisions of 6Li atoms in magnetic and optical traps

(1998)
We use a full coupled-channels method to calculate collisional properties of magnetically or optically trapped ultracold 6Li. The magnetic-field dependence of the s-wave scattering lengths of several mixtures of hyperfine ...
• #### Electric and magnetic radial diffusion coefficients using the Van Allen probes data

(2016)
ULF waves are a common occurrence in the inner magnetosphere and they contribute to particle motion, significantly, at times. We used the magnetic and the electric field data from the Electric and Magnetic Field Instrument ...
• #### Electrically tunable hot-silicon terahertz attenuator

(2014)
We have developed a continuously tunable, broadband terahertz attenuator with a transmission tuning range greater than 103. Attenuation tuning is achieved electrically, by simply changing the DC voltage applied to a heating ...

(2012)
• #### Electron correlation in solids via density embedding theory

(2014)
Density matrix embeddingtheory[G. Knizia and G. K.-L. Chan,Phys. Rev. Lett.109, 186404 (2012)] and density embeddingtheory[I. W. Bulik, G. E. Scuseria, and J. Dukelsky,Phys. Rev. B89, 035140 (2014)] have recently ...
• #### Electron doping evolution of structural and antiferromagnetic phase transitions in NaFe1−xCoxAs iron pnictides

(2016)
We use transport and neutron diffraction to study the electronic phase diagram of NaFe1−xCoxAs. In the undoped state, NaFeAs exhibits a tetragonal-to-orthorhombic structural transition below Tsfollowed by a collinear ...
• #### Electron doping evolution of the magnetic excitations in NaFe1−xCoxAs

(2016)
We use time-of-flight (TOF) inelastic-neutron-scattering (INS) spectroscopy to investigate the doping dependence of magnetic excitations across the phase diagram of NaFe 1 − x Co x As with x = 0 , 0.0175, ...
• #### Electron doping evolution of the neutron spin resonance in NaFe1−xCoxAs

(2016)
Neutron spin resonance, a collective magnetic excitation coupled to superconductivity, is one of the most prominent features shared by a broad family of unconventional superconductors including copper oxides, iron pnictides, ...
• #### Electron Screening and Kinetic-Energy Oscillations in a Strongly Coupled Plasma

(2004-12-20)
• #### Electron-Spin Polarization at Single-Crystalline Cr and Ni Surfaces Determined with Electron-Capture Spectroscopy

(1981)
The spin polarization P of electrons at Cr and Ni surfaces is measured with electron-capture spectroscopy. With use of one-electron capture at magnetized Cr(100)-c(2×2) surfaces at 293 K (TN=310 K), P values up to -18% are ...
• #### Electron-Temperature Evolution in Expanding Ultracold Neutral Plasmas

(2007-08-17)
• #### Electronic correlation without double counting via a combination of spin projected Hartree-Fock and density functional theories

(2014)
Several schemes to avoid the double counting of correlations in methods that merge multireference wavefunctions with density functional theory (DFT) are studied and here adapted to a combination of spin-projected Hartree-Fock ...
• #### Electronic nematic correlations in the stress-free tetragonal state of BaFe2−xNixAs2

(2015)
We use transport and neutron scattering to study electronic, structural, and magnetic properties of the electron-doped BaFe2−xNixAs2 iron pnictides in uniaxial-strained and external-stress-free detwinned states. Using a ...
• #### Electronic specific heat in BaFe2−xNixAs2

(2016)
We have systematically studied the low-temperature specific heat of the BaFe2−xNixAs2 single crystals covering the whole superconducting dome. Using the nonsuperconducting heavily overdoped x=0.3 sample as a reference for ...
• #### Elliptic Flow of Charm and Strange Hadrons in High-Multiplicity $p+\mathrm{Pb}$ Collisions at $\sqrt{{s}_{\mathrm{NN}}}=8.16\text{ }\text{ }\mathrm{TeV}$

(2018)
The elliptic azimuthal anisotropy coefficient (v2) is measured for charm (D0) and strange (K0S, Λ, Ξ−, and Ω−) hadrons, using a data sample of p+Pb collisions collected by the CMS experiment, at a nucleon-nucleon center-of-mass ...
• #### Elliptic flow of identified hadrons in Au+Au collisions at √sNN =7.7–62.4 GeV

(2013)
Measurements of the elliptic flow, v2, of identified hadrons (π±, K±, K0s, p, p¯, ϕ, Λ, Λ¯¯¯, Ξ−, Ξ¯¯¯+, Ω−, Ω¯¯¯+) in Au+Au collisions at √sNN=7.7, 11.5, 19.6, 27, 39, and 62.4 GeV are presented. The measurements were ...
• #### Elucidating the Metabolic Plasticity of Cancer: Mitochondrial Reprogramming and Hybrid Metabolic States

(2018)
Aerobic glycolysis, also referred to as the Warburg effect, has been regarded as the dominant metabolic phenotype in cancer cells for a long time. More recently, it has been shown that mitochondria in most tumors are not ...
• #### Emergence of kinetic behavior in streaming ultracold neutral plasmas

(2015)
We create streaming ultracold neutral plasmas by tailoring the photoionizing laser beam that creates the plasma. By varying the electron temperature, we control the relative velocity of the streaming populations, and, in ...
• #### Emergence of topological and strongly correlated ground states in trapped Rashba spin-orbit-coupled Bose gases

(2013)
We theoretically study an interacting few-body system of Rashba spin-orbit-coupled two-component Bose gases confined in a harmonic trapping potential. We solve the interacting Hamiltonian at large Rashba coupling strengths ...

format: plain


text:
# Complicated trigonometric integral proof

$$r>1$$

The following is applying gauss' law by explicit integration.

$$\int_0^{\pi } \frac{\sin (\theta )}{\sqrt{r^2-2 r \cos (\theta )+1}} \, d\theta=\frac{2}{r}$$

The following is finding the potential of a charged spherical shell by explicit integration. Mathematica takes forever to solve this and I cannot figure out how it would be done.

$$\int _0^{2 \pi }\int _0^{\pi }\frac{\sin (\theta ) \cos (\theta )}{\sqrt{r^2-2 r (\cos (\psi )\cos (\theta ) +\sin (\psi )\sin (\theta ) \cos (\phi ))+1}}d\theta d\phi=\frac{4 \pi }{3}\frac{\cos(\psi)}{r^2}$$

• Actually, your first integral's evaluation is incomplete: see my question here. – Chappers Oct 1 '15 at 16:46
• The divergence theorem (en.wikipedia.org/wiki/Divergence_theorem) may give a great help. – Jack D'Aurizio Oct 1 '15 at 17:07
• Why is there a $\cos \theta$ term in the numerator? – Mark Viola Oct 1 '15 at 18:01
• The integrand; why is the term $\cos \theta$ implicated here? – Mark Viola Oct 1 '15 at 18:17
• I believe that the final answer has a typographical error. The exponent on $r$ is $2$, not $1$. – Mark Viola Oct 1 '15 at 18:48

We begin with the integral $I(r,\psi)$ given by

$$I(r,\psi)=\int_{0}^{2\pi}\int_{0}^{\pi}\frac{\sin \theta \cos \theta}{\sqrt{r^2-2r\left(\cos \theta \cos \psi+\sin \theta \sin \psi \cos \phi\right)+1}}\,d\theta\,d\phi$$

Using spherical harmonics, we can expand the denominator of the integrand as

$$\frac{1}{\sqrt{r^2-2r\left(\cos \theta \cos \psi+\sin \theta \sin \psi \cos \phi\right)+1}}=4\pi\sum_{\ell=0}^{\infty}\sum_{m=-\ell}^{\ell}\frac{1}{2\ell +1}\frac{r_{<}^{\ell}}{r_{>}^{\ell+1}}Y_{\ell m}(\theta,\phi)Y_{\ell m}(\psi,0)$$

The integration over $\phi$ is trivial and reveals

\begin{align} I(r,\psi)&=2\pi \int_{0}^{\pi}\sin \theta \cos \theta \sum_{\ell=0}^{\infty}\frac{r_{<}^{\ell}}{r_{>}^{\ell+1}}P_{\ell}(\cos \theta)P_{\ell}(\cos \psi)\,d\theta\\\\&=2\pi \sum_{\ell=0}^{\infty}\frac{r_{<}^{\ell}}{r_{>}^{\ell+1}}P_{\ell}(\cos \psi)\int_{0}^{\pi}\sin \theta \cos \theta P_{\ell}(\cos \theta)\,d\theta \tag 1 \end{align}

Noting that $P_1(\cos \theta)=\cos \theta$ and exploiting the orthogonality of the Legendre Polynomials, we obtain

\begin{align} I(r,\psi)&=2\pi\sum_{\ell=0}^{\infty}\frac{r_{<}^{\ell}}{r_{>}^{\ell+1}}P_{\ell}(\cos \psi)\left(\frac{2}{2\ell +1}\delta_{\ell,1}\right)\\\\ &=\frac{4\pi}{3}\frac{r_{<}}{r_{>}^{2}}P_{1}(\cos \psi)\\\\ &=\frac{4\pi}{3}\frac{r_{<}}{r_{>}^{2}}\cos \psi\\\\ \end{align}

For $r>1$, $r_{<}=1$ and $r_{>}=r$. Finally, we have

$$\bbox[5px,border:2px solid #C0A000]{I(r,\psi)=\frac{4\pi}{3} \frac{\cos \psi}{r^2}}$$

• It's always a bit disappointing when we have to resort to orthogonal polynomials. But I can't see a better way, so (+1). – Chappers Oct 1 '15 at 19:04
• @rongordon In my former life, I was a scientist also. And you're correct. The use herein is a bit mind-numbing. But, as I stated earlier, brute force works well when it works. Mark – Mark Viola Oct 1 '15 at 19:29
• @mickep Well, pleased that this warmed you. ;-))... Mark – Mark Viola Oct 1 '15 at 19:40
• @Chappers Well, I confess .... I took the easy way here. There might be much more creative approaches, but brute force works when it works. And thank you for the up vote! Much appreciative. – Mark Viola Oct 1 '15 at 21:05
• @grdgfgr The square root term is a Green Function (or Green's Function, depending on whom you wish to believe). It is a solution to Laplace's Equation for $r\ne 1$, $\theta \ne \psi$, $\phi \ne 0$. It can be decomposed, therefore, in terms of spherical harmonics, which one can show by using separation of variables (for example). – Mark Viola Oct 1 '15 at 21:37

Substitution Method

Let $r^2-2r\cos \theta+1=u^2\implies 2r\sin\theta d\theta=2udu$ or $\sin\theta d\theta=\frac{udu}{r}$ $$\int_{0}^{\pi}\frac{\sin\theta}{\sqrt{r^2-2r\cos \theta+1}}d\theta=\int_{r-1}^{r+1}\frac{1}{u}\frac{udu}{r}$$ $$=\frac{1}{r}\int_{r-1}^{r+1}du=\frac{2}{r}$$

• Given already ? – Narasimham Oct 1 '15 at 17:27
• Unfortunately, this doesn't begin to answer the question. – Mark Viola Oct 1 '15 at 18:49


text:
# Sensitivity analysis: Removing one decision variable or constraint from the previous problem.

I'm studying linear optimization from Hillier's book and it teach us how to perform sensitivity analysis regarding several changes in respect to the initial problem. One of these changes are adding a new constraint or variable. However, I didnt find any reference teaching how to proceed if one wants to remove one decision variable from the initial problem or remove one constraint.

I think that if the decision variable is non-basic in the previous optimal solution, then you can remove it without changing anything. But what if the decision variable is basic??

Similarly, if the constraint is unactive, I think you can remove it just fine, but what if it's active?

To remove a variable that is basic, I multiply $-1$ to the simplex row that corresponds to that variable.

This will make the current solution dual feasible but primal infeasible.

We then proceed to perform dual simplex to drive out the variable that you want to remove to make it nonbasic.

• I didnt understand the ''removing a constraint''' part, could you explain better, please? Oct 9, 2016 at 19:27
• I just realized what I wrote doesn't make sense too. Back to thinking... Oct 9, 2016 at 19:40
• Hello, sorry for bothering you again, but I have a test tomorrow at 10 am (now is 10:30 pm) and I have one more question here, math.stackexchange.com/questions/1961583/… Please, help me.. Oct 10, 2016 at 1:29
• answered based on muscle memory, hopefully it makes sense. Good luck. Oct 10, 2016 at 6:32

You can simulate removing constraints and variables by adding them in specific ways.

• Removing a constraint is the same as adding a free variable to only that constraint, which in practice means two new variables: $$\cdots=b\to\cdots+x_0^+-x_0^-=b$$ If the associated reduced costs indicate non-optimality, perform primal simplex iterations.
• Removing a nonbasic variable, as you said, is as simple as removing it from the optimal solution.
• To remove a basic variable $$x_i$$, for every constraint that features it: $$\cdots+a_{ji}x_i+\cdots=b_j$$ add a new variable $$x_0$$ with a negated coefficient: $$\cdots+a_{ji}x_i+\cdots-a_{ji}x_0=b_j$$ Then add a new constraint $$x_i-x_0=0$$ with associated variable $$x_0$$, performing row operations on it to get back an identity matrix. If the solution for $$x_0$$ is negative, perform dual simplex iterations to reach the new optimal solution.


text:
# pgRouting Concepts¶

## Getting Started¶

This is a simple guide to walk you through the steps of getting started with pgRouting. In this guide we will cover:

### Create a routing Database¶

The first thing we need to do is create a database and load pgrouting in the database. Typically you will create a database for each project. Once you have a database to work in, your can load your data and build your application in that database. This makes it easy to move your project later if you want to to say a production server.

For Postgresql 9.2 and later versions

createdb mydatabase
psql mydatabase -c "create extension postgis"
psql mydatabase -c "create extension pgrouting"

How you load your data will depend in what form it comes it. There are various OpenSource tools that can help you, like:

osm2pgrouting: this is a tool for loading OSM data into postgresql with pgRouting requirements this is the postgresql shapefile loader this is a vector data conversion utility this is a tool for loading OSM data into postgresql

So these tools and probably others will allow you to read vector data so that you may then load that data into your database as a table of some kind. At this point you need to know a little about your data structure and content. One easy way to browse your new data table is with pgAdmin3 or phpPgAdmin.

### Build a Routing Topology¶

Next we need to build a topology for our street data. What this means is that for any given edge in your street data the ends of that edge will be connected to a unique node and to other edges that are also connected to that same unique node. Once all the edges are connected to nodes we have a graph that can be used for routing with pgrouting. We provide a tool that will help with this:

Note

this step is not needed if data is loaded with osm2pgrouting

select pgr_createTopology('myroads', 0.000001);

### Check the Routing Topology¶

There are lots of possible sources for errors in a graph. The data that you started with may not have been designed with routing in mind. A graph has some very specific requirements. One is that it is NODED, this means that except for some very specific use cases, each road segment starts and ends at a node and that in general is does not cross another road segment that it should be connected to.

There can be other errors like the direction of a one-way street being entered in the wrong direction. We do not have tools to search for all possible errors but we have some basic tools that might help.

select pgr_analyzegraph('myroads', 0.000001);
t_in_rules, t_out_rules
direction)

### Compute a Path¶

Once you have all the preparation work done above, computing a route is fairly easy. We have a lot of different algorithms that can work with your prepared road network. The general form of a route query is:

select pgr_dijkstra(SELECT * FROM myroads', 1, 2)

As you can see this is fairly straight forward and you can look and the specific algorithms for the details of the signatures and how to use them. These results have information like edge id and/or the node id along with the cost or geometry for the step in the path from start to end. Using the ids you can join these result back to your edge table to get more information about each step in the path.

## Group of Functions¶

A function might have different overloads. Across this documentation, to indicate which overload we use the following terms:

Depending on the overload are the parameters used, keeping consistency across all functions.

### One to One¶

When routing from:

• From one starting vertex
• to one ending vertex

### One to Many¶

When routing from:

• From one starting vertex
• to many ending vertices

### Many to One¶

When routing from:

• From many starting vertices
• to one ending vertex

### Many to Many¶

When routing from:

• From many starting vertices
• to many ending vertices

### Combinations¶

When routing from:

• From many different starting vertices
• to many different ending vertices
• Every tuple specifies a pair of a start vertex and an end vertex
• Users can define the combinations as desired.

## Inner Queries¶

There are several kinds of valid inner queries and also the columns returned are depending of the function. Which kind of inner query will depend on the function(s) requirements. To simplify variety of types, ANY-INTEGER and ANY-NUMERICAL is used.

Where:

ANY-INTEGER: SMALLINT, INTEGER, BIGINT SMALLINT, INTEGER, BIGINT, REAL, FLOAT

### Description of the edges_sql query for dijkstra like functions¶

Column Type Default Description
id ANY-INTEGER   Identifier of the edge.
source ANY-INTEGER   Identifier of the first end point vertex of the edge.
target ANY-INTEGER   Identifier of the second end point vertex of the edge.
cost ANY-NUMERICAL

Weight of the edge (source, target)

• When negative: edge (source, target) does not exist, therefore it’s not part of the graph.
reverse_cost ANY-NUMERICAL -1

Weight of the edge (target, source),

• When negative: edge (target, source) does not exist, therefore it’s not part of the graph.

Where:

ANY-INTEGER: SMALLINT, INTEGER, BIGINT SMALLINT, INTEGER, BIGINT, REAL, FLOAT

Description of the edges_sql query (id is not necessary)

edges_sql: an SQL query, which should return a set of rows with the following columns:
Column Type Default Description
source ANY-INTEGER   Identifier of the first end point vertex of the edge.
target ANY-INTEGER   Identifier of the second end point vertex of the edge.
cost ANY-NUMERICAL

Weight of the edge (source, target)

• When negative: edge (source, target) does not exist, therefore it’s not part of the graph.
reverse_cost ANY-NUMERICAL -1

Weight of the edge (target, source),

• When negative: edge (target, source) does not exist, therefore it’s not part of the graph.

Where:

ANY-INTEGER: SMALLINT, INTEGER, BIGINT SMALLINT, INTEGER, BIGINT, REAL, FLOAT

## Parameters¶

Parameter Type Default Description
edges_sql TEXT   SQL query as described above.
via_vertices ARRAY[ANY-INTEGER]   Array of ordered vertices identifiers that are going to be visited.
directed BOOLEAN true
• When true Graph is considered Directed
• When false the graph is considered as Undirected.
strict BOOLEAN false
• When false ignores missing paths returning all paths found
• When true if a path is missing stops and returns EMPTY SET
U_turn_on_edge BOOLEAN true
• When true departing from a visited vertex will not try to avoid using the edge used to reach it. In other words, U turn using the edge with same id is allowed.
• When false when a departing from a visited vertex tries to avoid using the edge used to reach it. In other words, U turn using the edge with same id is used when no other path is found.

### edges_sql query for aStar - Family of functions and aStar - Family of functions functions¶

edges_sql: an SQL query, which should return a set of rows with the following columns:
Column Type Default Description
id ANY-INTEGER   Identifier of the edge.
source ANY-INTEGER   Identifier of the first end point vertex of the edge.
target ANY-INTEGER   Identifier of the second end point vertex of the edge.
cost ANY-NUMERICAL

Weight of the edge (source, target)

• When negative: edge (source, target) does not exist, therefore it’s not part of the graph.
reverse_cost ANY-NUMERICAL -1

Weight of the edge (target, source),

• When negative: edge (target, source) does not exist, therefore it’s not part of the graph.
x1 ANY-NUMERICAL   X coordinate of source vertex.
y1 ANY-NUMERICAL   Y coordinate of source vertex.
x2 ANY-NUMERICAL   X coordinate of target vertex.
y2 ANY-NUMERICAL   Y coordinate of target vertex.

Where:

ANY-INTEGER: SMALLINT, INTEGER, BIGINT SMALLINT, INTEGER, BIGINT, REAL, FLOAT
Edges SQL: an SQL query of a directed graph of capacities, which should return a set of rows with the following columns:
Column Type Default Description
id ANY-INTEGER   Identifier of the edge.
source ANY-INTEGER   Identifier of the first end point vertex of the edge.
target ANY-INTEGER   Identifier of the second end point vertex of the edge.
capacity ANY-INTEGER

Weight of the edge (source, target)

• When negative: edge (source, target) does not exist, therefore it’s not part of the graph.
reverse_capacity ANY-INTEGER -1

Weight of the edge (target, source),

• When negative: edge (target, source) does not exist, therefore it’s not part of the graph.

Where:

ANY-INTEGER: SMALLINT, INTEGER, BIGINT
Edges SQL: an SQL query of a directed graph of capacities, which should return a set of rows with the following columns:
Column Type Default Description
id ANY-INTEGER   Identifier of the edge.
source ANY-INTEGER   Identifier of the first end point vertex of the edge.
target ANY-INTEGER   Identifier of the second end point vertex of the edge.
capacity ANY-INTEGER

Capacity of the edge (source, target)

• When negative: edge (source, target) does not exist, therefore it’s not part of the graph.
reverse_capacity ANY-INTEGER -1

Capacity of the edge (target, source),

• When negative: edge (target, source) does not exist, therefore it’s not part of the graph.
cost ANY-NUMERICAL   Weight of the edge (source, target) if it exists.
reverse_cost ANY-NUMERICAL 0 Weight of the edge (target, source) if it exists.

Where:

ANY-INTEGER: SMALLINT, INTEGER, BIGINT smallint, int, bigint, real, float

Description of the Points SQL query

points_sql: an SQL query, which should return a set of rows with the following columns:
Column Type Description
pid ANY-INTEGER

(optional) Identifier of the point.

• If column present, it can not be NULL.
• If column not present, a sequential identifier will be given automatically.
edge_id ANY-INTEGER Identifier of the “closest” edge to the point.
fraction ANY-NUMERICAL Value in <0,1> that indicates the relative postition from the first end point of the edge.
side CHAR

(optional) Value in [‘b’, ‘r’, ‘l’, NULL] indicating if the point is:

• In the right, left of the edge or
• If it doesn’t matter with ‘b’ or NULL.
• If column not present ‘b’ is considered.

Where:

ANY-INTEGER: smallint, int, bigint smallint, int, bigint, real, float

### Description of the combinations_sql query for dijkstra like functions¶

Column Type Default Description
source ANY-INTEGER   Identifier of the first end point vertex of the edge.
target ANY-INTEGER   Identifier of the second end point vertex of the edge.

Where:

ANY-INTEGER: SMALLINT, INTEGER, BIGINT

## Return columns & values¶

There are several kinds of columns returned are depending of the function.

### Return values for a path¶

Returns set of (seq, path_seq [, start_vid] [, end_vid], node, edge, cost, agg_cost)

Column Type Description
seq INT Sequential value starting from 1.
path_seq INT Relative position in the path. Has value 1 for the beginning of a path.
start_vid BIGINT

Identifier of the starting vertex. Returned when multiple starting vetrices are in the query.

end_vid BIGINT

Identifier of the ending vertex. Returned when multiple ending vertices are in the query.

node BIGINT Identifier of the node in the path from start_vid to end_vid.
edge BIGINT Identifier of the edge used to go from node to the next node in the path sequence. -1 for the last node of the path.
cost FLOAT Cost to traverse from node using edge to the next node in the path sequence.
agg_cost FLOAT Aggregate cost from start_v to node.

### Return values for multiple paths from the same source and destination¶

Returns set of (seq, path_id, path_seq [, start_vid] [, end_vid], node, edge, cost, agg_cost)

Column Type Description
seq INT Sequential value starting from 1.
path_id INT Path identifier. Has value 1 for the first of a path. Used when there are multiple paths for the same start_vid to end_vid combination.
path_seq INT Relative position in the path. Has value 1 for the beginning of a path.
start_vid BIGINT

Identifier of the starting vertex. Returned when multiple starting vetrices are in the query.

end_vid BIGINT

Identifier of the ending vertex. Returned when multiple ending vertices are in the query.

node BIGINT Identifier of the node in the path from start_vid to end_vid.
edge BIGINT Identifier of the edge used to go from node to the next node in the path sequence. -1 for the last node of the path.
cost FLOAT Cost to traverse from node using edge to the next node in the path sequence.
agg_cost FLOAT Aggregate cost from start_v to node.

### Description of the return values for a Cost Matrix - Category function¶

Returns SET OF (start_vid, end_vid, agg_cost)

Column Type Description
start_vid BIGINT Identifier of the starting vertex. Used when multiple starting vetrices are in the query.
end_vid BIGINT Identifier of the ending vertex. Used when multiple ending vertices are in the query.
agg_cost FLOAT Aggregate cost from start_vid to end_vid.

### Description of the Return Values¶

Column Type Description
seq INT Sequential value starting from 1.
edge BIGINT Identifier of the edge in the original query(edges_sql).
start_vid BIGINT Identifier of the first end point vertex of the edge.
end_vid BIGINT Identifier of the second end point vertex of the edge.
flow BIGINT Flow through the edge in the direction (start_vid, end_vid).
residual_capacity BIGINT Residual capacity of the edge in the direction (start_vid, end_vid).
Column Type Description
seq INT Sequential value starting from 1.
edge BIGINT Identifier of the edge in the original query(edges_sql).
source BIGINT Identifier of the first end point vertex of the edge.
target BIGINT Identifier of the second end point vertex of the edge.
flow BIGINT Flow through the edge in the direction (source, target).
residual_capacity BIGINT Residual capacity of the edge in the direction (source, target).
cost FLOAT The cost of sending this flow through the edge in the direction (source, target).
agg_cost FLOAT The aggregate cost.

### Routing Topology¶

Overview

Typically when GIS files are loaded into the data database for use with pgRouting they do not have topology information associated with them. To create a useful topology the data needs to be “noded”. This means that where two or more roads form an intersection there it needs to be a node at the intersection and all the road segments need to be broken at the intersection, assuming that you can navigate from any of these segments to any other segment via that intersection.

You can use the graph analysis functions to help you see where you might have topology problems in your data. If you need to node your data, we also have a function pgr_nodeNetwork() that might work for you. This function splits ALL crossing segments and nodes them. There are some cases where this might NOT be the right thing to do.

For example, when you have an overpass and underpass intersection, you do not want these noded, but pgr_nodeNetwork does not know that is the case and will node them which is not good because then the router will be able to turn off the overpass onto the underpass like it was a flat 2D intersection. To deal with this problem some data sets use z-levels at these types of intersections and other data might not node these intersection which would be ok.

For those cases where topology needs to be added the following functions may be useful. One way to prep the data for pgRouting is to add the following columns to your table and then populate them as appropriate. This example makes a lot of assumption like that you original data tables already has certain columns in it like one_way, fcc, and possibly others and that they contain specific data values. This is only to give you an idea of what you can do with your data.

ALTER TABLE edge_table

SELECT pgr_createTopology('edge_table', 0.000001, 'the_geom', 'id');

The function pgr_createTopology will create the vertices_tmp table and populate the source and target columns. The following example populated the remaining columns. In this example, the fcc column contains feature class code and the CASE statements converts it to an average speed.

UPDATE edge_table SET x1 = st_x(st_startpoint(the_geom)),
y1 = st_y(st_startpoint(the_geom)),
x2 = st_x(st_endpoint(the_geom)),
y2 = st_y(st_endpoint(the_geom)),
cost_len  = st_length_spheroid(the_geom, 'SPHEROID["WGS84",6378137,298.25728]'),
rcost_len = st_length_spheroid(the_geom, 'SPHEROID["WGS84",6378137,298.25728]'),
len_km = st_length_spheroid(the_geom, 'SPHEROID["WGS84",6378137,298.25728]')/1000.0,
len_miles = st_length_spheroid(the_geom, 'SPHEROID["WGS84",6378137,298.25728]')
/ 1000.0 * 0.6213712,
speed_mph = CASE WHEN fcc='A10' THEN 65
WHEN fcc='A15' THEN 65
WHEN fcc='A20' THEN 55
WHEN fcc='A25' THEN 55
WHEN fcc='A30' THEN 45
WHEN fcc='A35' THEN 45
WHEN fcc='A40' THEN 35
WHEN fcc='A45' THEN 35
WHEN fcc='A50' THEN 25
WHEN fcc='A60' THEN 25
WHEN fcc='A61' THEN 25
WHEN fcc='A62' THEN 25
WHEN fcc='A64' THEN 25
WHEN fcc='A70' THEN 15
WHEN fcc='A69' THEN 10
ELSE null END,
speed_kmh = CASE WHEN fcc='A10' THEN 104
WHEN fcc='A15' THEN 104
WHEN fcc='A20' THEN 88
WHEN fcc='A25' THEN 88
WHEN fcc='A30' THEN 72
WHEN fcc='A35' THEN 72
WHEN fcc='A40' THEN 56
WHEN fcc='A45' THEN 56
WHEN fcc='A50' THEN 40
WHEN fcc='A60' THEN 50
WHEN fcc='A61' THEN 40
WHEN fcc='A62' THEN 40
WHEN fcc='A64' THEN 40
WHEN fcc='A70' THEN 25
WHEN fcc='A69' THEN 15
ELSE null END;

-- UPDATE the cost information based on oneway streets

UPDATE edge_table SET
cost_time = CASE
WHEN one_way='TF' THEN 10000.0
ELSE cost_len/1000.0/speed_kmh::numeric*3600.0
END,
rcost_time = CASE
WHEN one_way='FT' THEN 10000.0
ELSE cost_len/1000.0/speed_kmh::numeric*3600.0
END;

-- clean up the database because we have updated a lot of records

VACUUM ANALYZE VERBOSE edge_table;

Now your database should be ready to use any (most?) of the pgRouting algorithms.

### Graph Analytics¶

Overview

It is common to find problems with graphs that have not been constructed fully noded or in graphs with z-levels at intersection that have been entered incorrectly. An other problem is one way streets that have been entered in the wrong direction. We can not detect errors with respect to “ground” truth, but we can look for inconsistencies and some anomalies in a graph and report them for additional inspections.

We do not current have any visualization tools for these problems, but I have used mapserver to render the graph and highlight potential problem areas. Someone familiar with graphviz might contribute tools for generating images with that.

### Analyze a Graph¶

With pgr_analyzeGraph the graph can be checked for errors. For example for table “mytab” that has “mytab_vertices_pgr” as the vertices table:

SELECT pgr_analyzeGraph('mytab', 0.000002);
NOTICE:  Performing checks, pelase wait...
NOTICE:  Analyzing for gaps. Please wait...
NOTICE:  Analyzing for isolated edges. Please wait...
NOTICE:  Analyzing for ring geometries. Please wait...
NOTICE:  Analyzing for intersections. Please wait...
NOTICE:              ANALYSIS RESULTS FOR SELECTED EDGES:
NOTICE:                    Isolated segments: 158
NOTICE:  Potential gaps found near dead ends: 527
NOTICE:               Intersections detected: 2560
NOTICE:                      Ring geometries: 0
pgr_analyzeGraph
----------
OK
(1 row)

In the vertices table “mytab_vertices_pgr”:

• Deadends are identified by cnt=1
• Potencial gap problems are identified with chk=1.
SELECT count(*) as deadends  FROM mytab_vertices_pgr WHERE cnt = 1;
----------
20028
(1 row)

SELECT count(*) as gaps  FROM mytab_vertices_pgr WHERE chk = 1;
gaps
-----
527
(1 row)

For isolated road segments, for example, a segment where both ends are deadends. you can find these with the following query:

SELECT *
FROM mytab a, mytab_vertices_pgr b, mytab_vertices_pgr c
WHERE a.source=b.id AND b.cnt=1 AND a.target=c.id AND c.cnt=1;

If you want to visualize these on a graphic image, then you can use something like mapserver to render the edges and the vertices and style based on cnt or if they are isolated, etc. You can also do this with a tool like graphviz, or geoserver or other similar tools.

### Analyze One Way Streets¶

pgr_analyzeOneWay analyzes one way streets in a graph and identifies any flipped segments. Basically if you count the edges coming into a node and the edges exiting a node the number has to be greater than one.

This query will add two columns to the vertices_tmp table ein int and eout int and populate it with the appropriate counts. After running this on a graph you can identify nodes with potential problems with the following query.

The rules are defined as an array of text strings that if match the col value would be counted as true for the source or target in or out condition.

#### Example¶

Lets assume we have a table “st” of edges and a column “one_way” that might have values like:

• ‘FT’ - oneway from the source to the target node.
• ‘TF’ - oneway from the target to the source node.
• ‘B’ - two way street.
• ‘’ - empty field, assume twoway.
• <NULL> - NULL field, use two_way_if_null flag.

Then we could form the following query to analyze the oneway streets for errors.

SELECT pgr_analyzeOneway('mytab',
ARRAY['', 'B', 'TF'],
ARRAY['', 'B', 'FT'],
ARRAY['', 'B', 'FT'],
ARRAY['', 'B', 'TF'],
);

-- now we can see the problem nodes
SELECT * FROM mytab_vertices_pgr WHERE ein=0 OR eout=0;

-- and the problem edges connected to those nodes
SELECT gid FROM mytab a, mytab_vertices_pgr b WHERE a.source=b.id AND ein=0 OR eout=0
UNION
SELECT gid FROM mytab a, mytab_vertices_pgr b WHERE a.target=b.id AND ein=0 OR eout=0;

Typically these problems are generated by a break in the network, the one way direction set wrong, maybe an error related to z-levels or a network that is not properly noded.

The above tools do not detect all network issues, but they will identify some common problems. There are other problems that are hard to detect because they are more global in nature like multiple disconnected networks. Think of an island with a road network that is not connected to the mainland network because the bridge or ferry routes are missing.

## Performance Tips¶

### For the Routing functions¶

To get faster results bound your queries to the area of interest of routing to have, for example, no more than one million rows.

Use an inner query SQL that does not include some edges in the routing function

SELECT id, source, target from edge_table WHERE
id < 17 and
the_geom  && (select st_buffer(the_geom,1) as myarea FROM  edge_table where id = 5)

Integrating the inner query to the pgRouting function:

SELECT * FROM pgr_dijkstra(
'SELECT id, source, target from edge_table WHERE
id < 17 and
the_geom  && (select st_buffer(the_geom,1) as myarea FROM  edge_table where id = 5)',
1, 2)

### For the topology functions:¶

When “you know” that you are going to remove a set of edges from the edges table, and without those edges you are going to use a routing function you can do the following:

Analize the new topology based on the actual topology:

pgr_analyzegraph('edge_table',rows_where:='id < 17');

Or create a new topology if the change is permanent:

pgr_createTopology('edge_table',rows_where:='id < 17');
pgr_analyzegraph('edge_table',rows_where:='id < 17');
`

Wiki


text:
Vol. 1, No. 4, 2007

 Recent Issues
 The Journal About the Journal Editorial Board Subscriptions Editors' Interests Submission Guidelines Submission Form Editorial Login Ethics Statement ISSN: 1944-7833 (e-only) ISSN: 1937-0652 (print) Author Index To Appear Other MSP Journals
The zeta function of monomial deformations of Fermat hypersurfaces

Remke Kloosterman

Vol. 1 (2007), No. 4, 421–450
Abstract

This paper intends to give a mathematical explanation for results on the zeta function of some families of varieties recently obtained in the context of mirror symmetry. In the process we obtain concrete and explicit examples for some results recently used in algorithms to count points on smooth hypersurfaces in ${ℙ}^{n}$.

In particular, we extend the monomial-motive correspondence of Kadir and Yui and we give explicit solutions to the $p$-adic Picard–Fuchs equation associated with monomial deformations of Fermat hypersurfaces.

As a byproduct we obtain Poincaré duality for the rigid cohomology of certain singular affine varieties.

Keywords
zeta function, $p$-adic Picard–Fuchs equation, Monsky–Washnitzer cohomology
Mathematical Subject Classification 2000
Primary: 14G10
Secondary: 14G15, 11G25