Hi I am trying to build a simple model of a gas field. At the moment I have these objects: GasWell represents the behaviour of a gas well GasFluid represents the thermodynamic behaviour of the gas GasField represents the field itself
The GasField object defines properties such as pressure and volume. The fluid within it is represented by the GasFluid object which also defines the properties of the fluid flowing through GasWell objects associated with a particular GasField. GasWell can be moved from one GasField object to another, so take the appropriate fluid behaviour from the GasFluid associated with the GasField to which it belongs. At the moment, the GasField definition looks something like this Class GasField(Object): def __init__(name, pres, vol, fluid, wells): self.name=name self.pres=pres self.vol=vol self.fluid=fluid # GasFluid object self.wells=wells # List of GasWell objects No problems with creating the WELL list since I just append a bunch of GasWell objects to a new list. The problem I have is how a particular GasWell knows which field it belongs to. The only way I can think of so far involves some form of cross referencing where we define the GasField with an empty WELL list, define the GasWells by setting the field it belongs to explicitly then updating the WELL list "externally". For example wells = [] stuff = GasFluid( params ) field = GasField("My field", p, V, stuff, wells) well1 = GasWell(params, field) well2 = GasWell(params, field) well3 = GasWell(params, field) wells.append(well1) wells.append(well2) wells.append(well2) new_field.wells = wells This cross-referencing of GasField and GasWells doesn't seem right to me - if we move a well from one field to another we have to update the GasWell object and the GasField.wells list. Is there a more pythonic (or more sensible) way of doing this? Thanks in advance Alun Griffiths _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor