How do I make a transformer in LTspice?
Although it is very possible to make to make dedicated subcircuits for specific transformers, in LTspice the preferred method of making a generic transformer when drafting a simulation schematic is to simply place a separate inductor for each separate transformer winding and then couple them all together magnetically with a single mutual inductance (K) statement placed as a SPICE directive on the schematic. See the Help file Circuit Element section on Mutual Inductance for detailed syntax. Inductors called out in a mutual inductance statement will be automatically given a phasing dot if one does not already exist.
When creating a new transformer this way, especially for use in a switched mode power circuit, it is generally best to first specify the mutual coupling coefficient to be exactly 1. By starting with 100 percent coupling there will be no leakage inductance in any winding and this will minimize the likelihood of the windings ringing at extremely high frequencies (which can slow the simulation to a crawl at each switching edge). However, be aware that a mutual inductance value of plus (or minus) unity may lead to simulation difficulties if "Skip the initial operating point solution" is specified for the .tran command.
Note that when coupled inductors are used as transformer windings, individual winding inductances rather than turns ratios must be specified (turns ratios are proportional to the square root of inductance ratios).