Parametric Beijing Siheyuan An algorithmic approach for the generation of Siheyuan housing variants based on its traditional design principles

Beijing Siheyuan is a type of Chinese vernacular housing with significant cultural value. During recent decades of economic growth, many Siheyuan houses have been destroyed; preserving the few remaining ones have become a necessity. Based on a historical analysis of their design principles, this paper develops a parametric model capable of representing its known variants. Our findings include a useful design tool able to efficiently represent existing or lost housing types and thus contribute to our understanding of the typology and their preservation.


INTRODUCTION
The Beijing Siheyuan (Quadrangle courtyard house, see Figure 1) is a historic housing type, once very common in the Beijing area.As an example of Chinese traditional architecture, it is an important part of the world's architectural heritage.After the Song dynasty, Beijing had a grid plan divided by hutong alleys, most of which were given over to quadrangle courtyard houses.The peak of Siheyuan development occurred in the Ming and Qing dynasties when it became the basic unit of old Beijing.Siheyuan is recognized as a typical representative of Chinese vernacular architecture.It embodies cultural values of traditional China, as for instance in the stipulation for different sizes of Siheyuan's houses made by governments which shows feudal hierarchy in ancient Chinese society.The constraint that all courtyards in Siheyuan are enclosed by walls or rooms illustrates the characteristic of introversion of traditional Chinese culture.In the morphological view, Siheyuan is a product with the obvious cultural identity of ancient China.

Figure 1 Photograph of Beijing Siheyuan houses and Hutong alley in 1989
Despite their cultural significance, the few Siheyuan houses that remain are facing oblivion, not only are the buildings vanishing but an understanding of what they represent is not being passed on to a new generation.Recent studies (Zhang, 2015) highlight the problem of contemporary architects not understanding Siheyuan's tectonic principles and spatial qualities.Although both Chinese and international clients are willing to build and live in Siheyuan housing, due to the fact that most current Chinese architects are not trained systematically to design Siheyuan style housing and the restriction of many commercial factors in practical projects, most contemporary Siheyuan projects are recognized as fakes.The primary cause of this is the complexity of the Siheyuan design theory.The principles of its construction are written in literal text using ancient Chinese language with stick drawings and the principles of room layout and compositional pattern are passed down by craftsmen using pithy formulas, which involve lots of ancient superstitious theories which current architects find difficult to understand.To make matters worse, being timber frame structures, the houses are particularly vulnerable to ageing and problems such as fire, humidity, and pests.During the period from 1949 to 2009, more than 82 per cent of Beijing Siheyuan areas were destroyed (Ni, 2009), to the extent that it was hard to find good examples to study.However, this type of classical dwelling type is still popular today, it is useful to reinterpret its design principles for contemporary architects and students to all the authentic patterns to live on.
Although Siheyuan design principles have been explored in previous studies by Chinese scholars, most of them are focusing on construction, visual aesthetics of decoration, and layout of architectural elements on site using methods of humanities instead of natural science (e.g.Deng, 2004, Jia, 2012, Lv, 2016, Ma, 1999, Zhao, 2013), only a few studies have investigated the Siheyuan design principles as a whole to interpret the entire design process as a whole.However, computational approaches have been applied by western scholars to study Chinese architectural heritage design principles.Stiny (1977Stiny ( , 2006) ) and his followers (Chiou, 1995, Li, 2001,) em-ployed shape grammar to successfully interpret original design languages of architectural heritage, but they are focused on exploring the computational principles hidden in Chinese style decoration and construction, with an emphasis on finding simple algorithms that could generate complex forms.We are more interested in the possibilities of creating families of forms controlled by a few parameters.Li (2013Li ( , 2016)), employed algorithms to represent parametric relationships and generate examples of traditional buildings based on a Chinese architectural manual, but those buildings were generic prototypes of single buildings rather than building groups.Most dwelling types of traditional Chinese architecture are, however, groups of buildings or rooms rather than a single building.Algorithmic approaches have not been applied to study design principles of a specified dwelling type in Chinese architecture for the aims of architectural design and education.
This paper explores an algorithm able to generate Siheyuan house variants which respect traditional design principles as used by ancient craftsmen.And it also argues that such algorithms can be implemented in the Grasshopper environment for the use of teaching architectural history knowledge and redesigning Siheyuan.In particular, we are aiming to answer the following research questions: 1. How can the traditional Beijing Siheyuan design principles be translated into parametric algorithms? 2. How can such algorithms contribute to the Siheyuan's efficient three-dimensional representation?3. How can such algorithms become tools for the utilization of its principles in contemporary Chinese architecture and architectural education?
To answer these questions, Siheyuan traditional design principles from three sources were studied to build design constraints in the forms of an algorithm, which was developed in the Rhino/Grasshopper environment based on visual scripting.In addition, we have discussed the potential applications of the tool in Siheyuan design and education.

Source of design rules
The conventional approach of Siheyuan design accepted by current Chinese architects and scholars is based on several hypothetical ideal examples that only take into account a proper solution of building orientation, site location, and forms of architectural components on a rectangular site based on classifying the number of courtyards and their combinations (Ma. 1999).This objectivist theory can be criticised because the ideal prototypical Siheyuan is hypothetical, and in fact, lots of historical Siheyuan houses are variants of these ideal examples rather than themselves (Ni 2009, pp136), even though these ideal examples existing only in theory have the potential to be transformed into built variants.Instead, our approach sees Siheyuan as the product of an algorithm based on compositional rules, and we can test it by comparing its outputs with the corpus of built examples.The compositional rules underlying the algorithm are extracted from three main traditional sources: 1.The Fengshui Theory (cloud and water), an ancient Chinese geomancy, provides guidance for selecting a proper building site and efficient architectural construction.Specifically, the verse formula Ba gua qi zheng da you nian (eight hexagrams seven politics big tour calendar) founded on the concept of "cosmic resonance" helps craftsmen and householders predict and select auspicious orientations and qualitative space in the design process.2. Ancient Chinese buildings were required to follow the construction laws compiled by the government.The Beijing Siheyuan was developed during the Qing dynasty  following the Gongchengzuofazeli (Structural Regulations) compiled by the Qing government.
3. Although ancient governments required householders to follow the construction law strictly, many house variations occurred, based on the experience of the ancient craftsmen passed from each generation to the next.

Analysis of traditional design principles
Understanding the design principles as described in the Gongchengzuofazeli construction manual and passed down by craftsmen is a complicated task since valuable data is mixed with superstitious and feudal hierarchical beliefs.Nevertheless, one can derive three principle design phases, which together cover the entire design process.
The first phase focuses on the layout of architectural elements (single room, veranda, entrance, and walls) and their positioning on the site.There are many factors that shape the layout of architectural elements.In the traditional conventional approach, the first step is to use Fengshui Theory to determine a key point on the site and create a central axis crossing the key point and then determine the auspicious orientations according to the householder's birthday, site context, and site shape.In ideal cases, the orientation of the axis is a little off the north-south orientation.The second step is to determine the Siheyuan entrance.An ideal site is rectangular and orientated north-south with the north-south axis longer than the east-west and the south side connected to a hutong alley, allowing the entrance to be located at the southeast corner of the site.However, in many cases, these ideals cannot be met.Variants of site context and in the orientation of the longer sides of the site, lead to different patterns of entrance location.The most common combinations of these two criteria are illustrated in step two of stage one in Table 1, and corresponding patterns of location of the entrance are given.The third step is to divide the site into courtyards.Ideally, for most Siheyuans, the site is rectangular and there are between one and five courtyards depending on the householder's needs and the site size.The courtyards have their central points juxtaposed along the central axis (parallel grouped Siheyuan and Siheyuan with garden are infrequent, therefore they are not studied here).The fourth step is to determine the pattern layout of the rooms, the veranda, and the walls in each courtyard.Possible layouts are shown in Figure 2.
The second phase is to determine the form of each architectural element (room, wall, and veranda) that is to decide on its type, and then to calculate its dimensions.Regarding the rooms, there are seven parameters that determine their shape.These are: 1.The number of bays in the front view of the room; 2. The number of rafters in flank sides view of the room; 3. The length of the central bay in the front view of the room; 4. The ratio of two adjacent bays length in the front view of the room; 5.The ratio of the lengths of two adjacent rafters in horizontally projected orientation in flank sides view of the room; 6.The diameter of columns in the outermost row in front-back orientation; 7. Whether or not the room has a front veranda, and whether or not the room has a rear veranda.In practice, the length of the central bay is determined by craftsmen according to the size of the site.These and the value of the other parameters are determined by the ancient construction law and the householder's demands.The veranda's structural form is unique, and its unique parameter is the diameter of its column.The diameter value is determined by the craftsmen's experience based on the site's size.Using the algorithm underlies the craftsmen's mind and the ancient construction law book, forms can be determined and dimensions of them can be calculated.Walls are not parametric but come in several types, such as walls with tiled tops finished in different patterns.
The third phase concludes with locating the architectural elements.Although the location of each architectural element is abstractly given in patterns of layout diagram (rooms are located on the edges of each courtyard, verandas form an enclosed rectangle to connect each room entrance, and walls are located on the section of each courtyard edges that not occupied by rooms), we realized many elements obey this rule loosely.In fact, they can move within the court-yard.However, we always ensure all elements have general bilateral symmetry about the central axis.
These three phases are seen in the division of Table 1 into three parts.This Table summarises the generation of Siheyuan and illustrates that there are seven factors shaping their final form.These are: 1. the householder's birthday; 2. site context; 3. site shape; 4. site size; 5. choice of pattern of architectural elements layout; 6. choice of architectural elements' form and size; and 7. relocation of architectural elements.

BUILDING OF A PARAMETRIC LOGIC AND COMPUTER IMPLEMENTATION
Based on the analysis of Siheyuan's traditional design principles as described above, we can list the main parameters under the following headings: 1.The site shape, site context, site size, the location of the key point, and the orientation of its central axis, 2. The number of courtyards, the dimensions of each courtyard, the patterns of the layout of its architectural elements of each courtyard, 3.For rooms, the number of the bays in front view of each room, the number of rafters in flank sides view of each room, the length of the central bay in front view of each room, the ratio of two adjacent bays in front view of each room, the ratio of the lengths of two adjacent rafters in horizontally projected orientation in flank sides view of the room, the diameter of columns in outermost row in front-back orientation, 4. Whether the building has a veranda or not, and for that veranda, the diameter its columns, 5.For walls, its pattern, e.g., internal or external walls.
The relationships between the parameters are shown in Figure 3.They formed the input to the visual scripting components in our Rhino/Grasshopper model.As well as being used for dwellings they can easily be converted into restaurants or hotels or adapted for modern commercial use.Thus, Siheyuan can still be identified as an architectural type in contem-Figure 3 Parametric logic of the algorithm porary society.Although many superficially similar projects are still being built, people believe they are not authentic unless they follow the original design and construction principles.The algorithm described here, in the form of a Grasshopper script, can, therefore, serve as a tool to both design genuine Siheyuan and explain their design knowledge in a new way.By using our Grasshopper script and a digital model, virtual Siheyuan can be generated rapidly and efficiently.Previously, in order to design a Siheyuan, architects needed to follow the design principles to determine dimensions of each component before drawing plans and elevations, however, using this tool, architects just need to input the parameters and then the three-dimensional representations will be created automatically.Compared with the conventional method of design and modelling which take many hours, our tool takes only a few seconds to generate models after inputting parameters.
The algorithm can also be used to impart the principles of Siheyuan design.Parametric design is a globally accepted method in architecture, and for many students, the representation of design principles in the form of scripts is easier than to follow the text in the ancient Chinese language with accompanying stick drawings.To test this, we plan to introduce this tool to Xihua University architecture students, who study Siheyuan design principles in an ar-chitectural history course, to see if they can look at Siheyuan in a new way, and we will analyze their responses.
Other uses of our algorithms will come from the mass production of virtual historic environments in an architecturally realistic way for use in gaming and documentation of the historic Siheyuan houses by encoding their parameters for use in heritage preservation.

DISCUSSION AND CONCLUSION
The algorithms to parametrically generate Siheyuan are consistent with Fengshui Theory, Gongchengzuofazeli, and craftsmen's experience that works with the constraints of the primary design principles.The script is their implementation in Grasshopper; the three-dimensional representations are digitally built in Rhino when scripting is done.Since the formulated algorithms save time to design for modelling and modifying Siheyuan houses, the tool will be useful to today's architects who wish to work in the Siheyuan idiom.On the other hand, as the Grasshopper algorithm is strictly in correspondence with the original design principles, it can easily illustrate the Siheyuan design knowledge.Rather than having to study the ancient Chinese literal text or verbal pithy formulas, this tool exploits the design Table 1 The generation process of Siheyuan based on traditional design principles principles in the form of algorithmic script, which is more understandable for contemporary architects and students.By modifying these sliders of parameters, the impact that each parameter has on the Siheyuan's design can be easily explored.In other words, the knowledge about how principles and factors shape Siheyuan design are demonstrated in a graphic way.That new design experience, in combination with the popularity of the Rhinoceros/-Grasshopper software in architects and students, will contribute to preserve and distribute the Siheyuan design knowledge in a broader audience.
However, the potential of the generated Siheyuan variations by this tool has not been fully ex-Challenges -CULTURAL HERITAGE -Volume 1 -eCAADe 37 / SIGraDi 23 | 525 plored.First, the model gives only general massing and structural frame, more architectural details, such as constructional joint, have not been incorporated.Adding these parts will be subject to further research.Second, we note there are some extant and disappeared historical examples which cannot be generated by our tool.Our algorithm is based on the hypothesis that craftsmen strictly follow Fengshui Theory to design the layout of architectural components, however, in many cases, since the site is physically restricted by an irregular shape or the household's budget was limited, craftsmen cannot strictly follow these design principles.Therefore, our generated models are representations of ideal examples.Nevertheless, more rules can be embedded in the algorithm, so it will be able to represent more complex and irregular variants.In particular, comparing all generated variants with built precedents recorded on the map Qianlong Jingcheng Quantu (Qianlong Capital Map, 1748-1750), which presents all the buildings of Beijing at a scale of 1: 650, we discovered a few houses, (for instance the house in the square box in Figure 4), that cannot be generated by our tool.What can we make of these outliers?While we are alert to the possibility that there might be more tacit rules than we are aware of, we view these pathological cases as illuminating the normal: since the shapes of sites are usually irregular and there are many other uncertain factors shaping the results, craftsmen often improvised but always tried to be as close as possible to what would occur with no constraint, so that even in irregular circumstances something approximating an ideal form was produced.This explains the common view that Siheyuan is based on an ideal model.We hope, in future work, to use the tool to recreate ancient Beijing as a VR reconstruction of the Qianlong Capital Map, dealing with the few exceptions as special cases.A reconstruction of the ancient capital is thus feasible and may have commercial possibilities in gaming and urban studies.Third, non-existing variants are generated by our tool.When we compared houses produced by our algorithm with surveys of existing houses such as Ma, 1999, Ni, 2009, and Duan, 2016, we found that not all variants developed by our algorithm have in fact ever been built, although we cannot be sure that these surveys cover all types in the real world.We can interpret these discrepancies in two ways.They might represent types yet to be discovered.This is difficult to verify since records of these old houses are rather incomplete.Alternatively, our non-existing Siheyuan variants might indicate that there are hitherto undiscovered constraints, in other words, unknown Siheyuan design rules.For example, it is certain that following Fengshui rules reduces the number of possible forms, and that houses in designed according to Fengshui are preferred, and plan forms that are not in accord with it might be seen as disadvantageous.The study of the relation between what is possible and what actually exists gives us a better understanding of the balance between cultural and physical constraints on architecture.
Figure 4 A Siheyuan house in the Qianlong Jingcheng Quantu plan of Beijing that cannot be generated by our algorithm Meanwhile, the potential of the purposed algorithmic approach to investigate Siheyuan design principles has not been fully explored.Although the original design principles are revealed through our algorithm, the corresponding generated designs are historical ones, of which it is believed the spaces and forms do not adapt to the contemporary way of daily life and aesthetics.However, our algorithm can serve as a starting point to solve the difficulty of designing new Siheyuan houses that both adapt to contemporary architectural function and aesthetics and respect the original design principles and forms.The approach based on shape grammar studies, where original grammars are utilized to create new styles of designs "from scratch" (Duarte, 2005) can be borrowed to re-design Siheyuan by partly modifying our algorithms in order to make the new design solutions adapt to contemporary architecture but not entirely ignoring original principles.
Furthermore, another important finding is that the ratio of dimensions of Siheyuan is constrained by some parameters we have listed above (which figure?).For example, the depth and width of each courtyard plan.By dividing the site into courtyards, since the width of each courtyard been determined already (the same with site width) and the value of each courtyard depth must be greater than a constant value, the number of courtyards influences the depth of each courtyard, and thus it influences the ratio between the depth and width of each courtyard plan.Based on Duan's measured drawings, we observe that, for most Siheyuan containing more than three courtyards, the ratio between depth and width of front courtyard is 0.2-0.4: 1, however, the ratio of courtyards in the middle is 0.6-1: 1.The reason for this is to create a narrow space as an architectural promenade for guests in front courtyard in order to hide the primary spaces of Siheyuan (usually, they are middle courtyards) but make the primary spaces capacious for hosts (usually, in olden days guests were only admitted to the front courtyard, leaving the main bedrooms and living rooms in middle courtyards for the host), which embodies connotation of traditional Chinese culture, as shown in Figure 5.The proportional ratio of the front and middle courtyard dimensions Finally, we note that the rules for Siheyuan are a way of controlling the standard of buildings, and those rules were applied more rigorously in Beijing than further afield in China.The fact that an algorithmic model of a house is even possible is a reflection of an attempt to control houses by means of rules, which is then reflected in their typology.

APPLICATION
Figure 2 Patterns of the layout of architectural elements

Figure 5
Figure 5The proportional ratio of the front and middle courtyard dimensions